Merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote into lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party

Proposed by Eduardo Mucelli Rezende Oliveira
Status: Merged
Merged at revision: 133
Proposed branch: lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins-extras/third-party
Diff against target: 188 lines (+76/-14)
5 files modified
Quote/ChangeLog (+1/-0)
Quote/Quote (+21/-10)
Quote/Quote.conf (+2/-2)
Quote/VidademerdaParser.py (+50/-0)
Quote/auto-load.conf (+2/-2)
To merge this branch: bzr merge lp:~eduardo-mucelli/cairo-dock-plug-ins-extras/Quote
Reviewer Review Type Date Requested Status
Cairo-Dock Devs Pending
Review via email: mp+47691@code.launchpad.net

Description of the change

Fixing the message when there were no translation for only one word. Adding Vidademerda.com.br. Adding next quote button in the PopupDialog.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Quote/ChangeLog' (properties changed: -x to +x)
2--- Quote/ChangeLog 2010-12-22 14:19:10 +0000
3+++ Quote/ChangeLog 2011-01-27 16:54:12 +0000
4@@ -1,3 +1,4 @@
5+0.0.7:(January/27/2010): Fixing the message when there were no translation for only one word. Adding Vidademerda.com.br. Adding next quote button in the PopupDialog.
6 0.0.6:(December/22/2010): Automatic fetch more quotes when all of them were already showed to the user, except for Quotationspage.com.
7 0.0.5:(December/2/2010): Added Jokes2go.com.
8 0.0.4:(November/23/2010): Added Danstonchat.com. Changed the icon, now the lamp was turned on :¬) Huge code modularization.
9
10=== modified file 'Quote/Quote'
11--- Quote/Quote 2010-12-22 14:19:10 +0000
12+++ Quote/Quote 2011-01-27 16:54:12 +0000
13@@ -16,8 +16,8 @@
14 # GNU General Public License for more details.
15
16 # This applet provides a "Quote of the day" feature from some internet sources
17-# such as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.fr, and
18-# Jokes2go.com
19+# such as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.fr,
20+# Jokes2go.com, and Vidademerda.com.br
21
22 import gobject, dbus, os, urllib, gtk, ConfigParser, itertools
23 from dbus.mainloop.glib import DBusGMainLoop
24@@ -32,10 +32,11 @@
25 from QuotationspageParser import QuotationspageParser # Quotationspage.com
26 from DanstonchatParser import DanstonchatParser # Danstonchat.fr
27 from JokestogoParser import JokestogoParser # Jokes2go.com
28+from VidademerdaParser import VidademerdaParser # Vidademerda.com.br
29
30 DBusGMainLoop(set_as_default=True)
31
32-quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo = range(6) # quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5
33+quotationspage, bash, xkcdb, qdb, danstonchat, jokestogo, vidademerda = range(7) # quotationspage = 0, bash = 1, xkcdb = 2, qdb = 3, danstonchat = 4, jokestogo = 5, vidademerda = 6
34
35 class AgentOpener(FancyURLopener):
36 """Masked user-agent otherwise the access would be forbidden"""
37@@ -59,8 +60,10 @@
38 parser = QdbParser() # QdbParser.py
39 elif (self.source == danstonchat):
40 parser = DanstonchatParser() # DanstonchatParser.py
41- else:
42+ elif (self.source == jokestogo):
43 parser = JokestogoParser()
44+ else:
45+ parser = VidademerdaParser()
46
47 opener = AgentOpener() # opens the web connection with masked user-agent
48
49@@ -76,8 +79,11 @@
50 self.author = parser.author
51 elif (self.source == bash or self.source == xkcdb or self.source == qdb or self.source == danstonchat):
52 self.quote = filter(None, parser.quote) # retira os '' do array
53- else: # jokestogo
54+ elif self.source == jokestogo: # jokestogo
55 self.quote = filter(self.breakline, parser.quote)
56+ else: # vidademerda
57+ self.quote = [''.join(parser.quote)]
58+ self.author = parser.author
59 return self.quote, self.author
60
61 def breakline(self, item):
62@@ -110,6 +116,7 @@
63 self.quotation = ""
64 self.dialog_active_time = 30 # time in seconds that the dialog window will be active
65 self.copy_current_quote_key = 0
66+ self.go_next_quote_key = 1
67 self.source = quotationspage
68
69 def start(self):
70@@ -139,6 +146,8 @@
71 def action_on_answer_dialog(self, key, content):
72 if (key == self.copy_current_quote_key): # cancel button = 1, and copy_current_quote_key = 0
73 self.set_to_clipboard(self.quotation) # copia para a area de transferencia a quotation atual
74+ elif (key == self.go_next_quote_key):
75+ self.show_quote()
76
77 def set_to_clipboard(self, sentence):
78 clipboard = gtk.clipboard_get() # get the clipboard
79@@ -166,13 +175,15 @@
80 self.get_quotes_from_web() # buscar mais
81 current = self.quotes.next() # posicionar na primeira para mostra-la
82 self.quotation = "%s" % current
83- else: # jokestogo provides only one quote per request ...
84+ elif (self.source == jokestogo): # jokestogo provides only one quote per request ...
85 self.quotation = "%s" % self.quotes.next().rstrip()
86- self.get_quotes_from_web() # ... so it is necessary to request it again
87+ self.get_quotes_from_web() # ... so it is necessary to request it again
88+ else:
89+ self.quotation = "%s ~ %s" % (self.quotes.next(), self.authors.next()) # vidademerda provides only one quote per request ...
90+ self.get_quotes_from_web() # ... so it is necessary to request it again
91 try:
92- self.icon.PopupDialog({'message':self.quotation, "buttons":"stock_copy;cancel"}, {})
93- except Exception:
94- log("Error caused PopupDialog not be shown, ShowDialog was used instead") # back-compatibility with CD < 2.2.0
95+ self.icon.PopupDialog({'message':self.quotation, "buttons":"stock_copy;go-next;cancel"}, {})
96+ except Exception: # back-compatibility with CD < 2.2.0
97 self.icon.ShowDialog(self.quotation, self.dialog_active_time)
98
99 def inform_start_of_waiting_process(self):
100
101=== modified file 'Quote/Quote.conf'
102--- Quote/Quote.conf 2010-12-22 14:19:10 +0000
103+++ Quote/Quote.conf 2011-01-27 16:54:12 +0000
104@@ -1,4 +1,4 @@
105-#!en;0.0.6
106+#!en;0.0.7
107
108 #[gtk-about]
109 [Icon]
110@@ -89,5 +89,5 @@
111
112 #[gtk-preferences]
113 [Configuration]
114-#l[Quotationspage.com;Bash.org;Xkcdb.com;Qdb.us;Danstonchat.com;Jokes2go.com] Quote source:
115+#l[Quotationspage.com;Bash.org;Xkcdb.com;Qdb.us;Danstonchat.com;Jokes2go.com;Vidademerda.com.br] Quote source:
116 source = 0
117
118=== added file 'Quote/VidademerdaParser.py'
119--- Quote/VidademerdaParser.py 1970-01-01 00:00:00 +0000
120+++ Quote/VidademerdaParser.py 2011-01-27 16:54:12 +0000
121@@ -0,0 +1,50 @@
122+# This is a part of the external Quote applet for Cairo-Dock
123+#
124+# Author: Eduardo Mucelli Rezende Oliveira
125+# E-mail: edumucelli@gmail.com or eduardom@dcc.ufmg.br
126+
127+from sgmllib import SGMLParser
128+
129+class VidademerdaParser(SGMLParser):
130+
131+ def reset(self):
132+ SGMLParser.reset(self)
133+ self.url = "http://vidademerda.com.br/aleatorias"
134+ self.quote = []
135+ self.author = []
136+ self.inside_div_element = False # indica se o parser esta dentro de <div></div> tag
137+ self.inside_div_p_element = False
138+ self.inside_b_element = False
139+
140+ def start_div(self, attrs):
141+ for name, value in attrs:
142+ if name == "class" and value == "vdmContent": # <dt class="vdmContent">...</dt>
143+ self.inside_div_element = True
144+
145+ def end_div(self):
146+ self.inside_div_element = False
147+
148+ def start_p(self, attrs):
149+ if self.inside_div_element:
150+ self.inside_div_p_element = True
151+
152+ def end_p(self):
153+ self.inside_div_p_element = False
154+
155+ def start_b(self, attrs):
156+ for name, value in attrs:
157+ if name == "class" and value == "ajustM6": # <dt class="ajustM6">...</dt>
158+ self.inside_b_element = True
159+
160+ def end_b(self):
161+ self.inside_b_element = False
162+
163+ def handle_data(self, text):
164+ if self.inside_div_p_element: # estamos dentro de <div><p>...</p></div>
165+ self.quote.append(text)
166+ if self.inside_b_element:
167+ self.author.append(text)
168+
169+ def parse(self, page):
170+ self.feed(page) # feed the parser with the page's html
171+ self.close()
172
173=== modified file 'Quote/auto-load.conf' (properties changed: -x to +x)
174--- Quote/auto-load.conf 2010-12-22 14:19:10 +0000
175+++ Quote/auto-load.conf 2011-01-27 16:54:12 +0000
176@@ -4,10 +4,10 @@
177 author = Eduardo Mucelli Rezende Oliveira
178
179 # A short description of the applet and how to use it.
180-description = This applet provides a "Quote of the day" feature from some internet sources \nsuch as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.com, and Jokes2go.com
181+description = This applet provides a "Quote of the day" feature from some internet sources \nsuch as Quotationspage.com, Bash.org, Xkcdb.com, Qdb.us, Danstonchat.com, Jokes2go.com, and Vidademerda.com.br
182
183 # Category of the applet : 2 = files, 3 = internet, 4 = Desktop, 5 = accessory, 6 = system, 7 = fun
184 category = 7
185
186 # Version of the applet; change it everytime you change something in the config file. Don't forget to update the version both in this file and in the config file.
187-version = 0.0.6
188+version = 0.0.7

Subscribers

People subscribed via source and target branches