Merge lp:~vr123456/leo-editor/detect_urls into lp:leo-editor/old-trunk
- detect_urls
- Merge into trunk
Proposed by
Viktor Ransmayr
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~vr123456/leo-editor/detect_urls |
Merge into: | lp:leo-editor/old-trunk |
Diff against target: |
162 lines (+45/-20) 2 files modified
leo/plugins/detect_urls.py (+34/-9) leo/plugins/leoPluginsRef.leo (+11/-11) |
To merge this branch: | bzr merge lp:~vr123456/leo-editor/detect_urls |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
The Leo editor team | Pending | ||
Review via email: mp+17100@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Viktor Ransmayr (vr123456) wrote : | # |
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'leo/plugins/detect_urls.py' | |||
2 | --- leo/plugins/detect_urls.py 2010-01-09 13:50:47 +0000 | |||
3 | +++ leo/plugins/detect_urls.py 2010-01-10 15:58:16 +0000 | |||
4 | @@ -3,8 +3,7 @@ | |||
5 | 3 | #@<< docstring >> | 3 | #@<< docstring >> |
6 | 4 | #@+node:vpe.20060426084738:<< docstring >> | 4 | #@+node:vpe.20060426084738:<< docstring >> |
7 | 5 | """ | 5 | """ |
10 | 6 | Colorizes URLs everywhere in node's body on node selection | 6 | Colorizes URLs everywhere in node's body on node selection or saving. |
9 | 7 | or saving. | ||
11 | 8 | 7 | ||
12 | 9 | Double click on any URL launches it in default browser. | 8 | Double click on any URL launches it in default browser. |
13 | 10 | 9 | ||
14 | @@ -16,13 +15,45 @@ | |||
15 | 16 | #@nl | 15 | #@nl |
16 | 17 | #@@language python | 16 | #@@language python |
17 | 18 | #@@tabwidth -4 | 17 | #@@tabwidth -4 |
18 | 18 | |||
19 | 19 | __version__ = "0.3" | ||
20 | 20 | #@<< version history >> | ||
21 | 21 | #@+node:RV20090910.20100110154407.7439:<< version history >> | ||
22 | 22 | #@+at | ||
23 | 23 | # | ||
24 | 24 | # Originally written by ??? | ||
25 | 25 | # | ||
26 | 26 | # 0.1 ???: Initial version. | ||
27 | 27 | # | ||
28 | 28 | # 0.2 VR: Detect URLs with protocol type 'file' and detect a new URL also | ||
29 | 29 | # after a save operation. | ||
30 | 30 | # | ||
31 | 31 | # 0.3 VR: Display info about this plugin, when executing cmd | ||
32 | 32 | # 'print-plugins-info'. | ||
33 | 33 | #@-at | ||
34 | 34 | #@-node:RV20090910.20100110154407.7439:<< version history >> | ||
35 | 35 | #@nl | ||
36 | 36 | #@<< imports >> | ||
37 | 37 | #@+node:RV20090910.20100110154407.7437:<< imports >> | ||
38 | 19 | import leo.core.leoGlobals as g | 38 | import leo.core.leoGlobals as g |
39 | 20 | import leo.core.leoPlugins as leoPlugins | 39 | import leo.core.leoPlugins as leoPlugins |
40 | 21 | import re | 40 | import re |
42 | 22 | #VR20100108: url_regex = re.compile(r"""(http|https|ftp)://[^\s'"]+[\w=/]""") | 41 | #@-node:RV20090910.20100110154407.7437:<< imports >> |
43 | 42 | #@nl | ||
44 | 43 | |||
45 | 23 | url_regex = re.compile(r"""(http|https|file|ftp)://[^\s'"]+[\w=/]""") | 44 | url_regex = re.compile(r"""(http|https|file|ftp)://[^\s'"]+[\w=/]""") |
46 | 24 | 45 | ||
47 | 25 | #@+others | 46 | #@+others |
48 | 47 | #@+node:RV20090910.20100110154407.7438:init() | ||
49 | 48 | def init(): | ||
50 | 49 | ok = not g.app.unitTesting | ||
51 | 50 | if ok: | ||
52 | 51 | leoPlugins.registerHandler("bodydclick1", openURL) | ||
53 | 52 | leoPlugins.registerHandler("select2", colorizeURLs) | ||
54 | 53 | leoPlugins.registerHandler("save2", colorizeURLs) | ||
55 | 54 | g.plugin_signon(__name__) | ||
56 | 55 | return ok | ||
57 | 56 | #@-node:RV20090910.20100110154407.7438:init() | ||
58 | 26 | #@+node:vpe.20060305064323.5:openURL() | 57 | #@+node:vpe.20060305064323.5:openURL() |
59 | 27 | def openURL(tag,keywords): | 58 | def openURL(tag,keywords): |
60 | 28 | c = keywords.get("c") | 59 | c = keywords.get("c") |
61 | @@ -69,11 +100,5 @@ | |||
62 | 69 | n += len(line) + 1 | 100 | n += len(line) + 1 |
63 | 70 | #@-node:vpe.20060426062042:colorizeURLs() | 101 | #@-node:vpe.20060426062042:colorizeURLs() |
64 | 71 | #@-others | 102 | #@-others |
65 | 72 | |||
66 | 73 | if 1: | ||
67 | 74 | leoPlugins.registerHandler("bodydclick1", openURL) | ||
68 | 75 | leoPlugins.registerHandler("select2", colorizeURLs) | ||
69 | 76 | leoPlugins.registerHandler("save2", colorizeURLs) #VR20100108 | ||
70 | 77 | g.plugin_signon(__name__) | ||
71 | 78 | #@-node:ekr.20060506070443.1:@thin detect_urls.py | 103 | #@-node:ekr.20060506070443.1:@thin detect_urls.py |
72 | 79 | #@-leo | 104 | #@-leo |
73 | 80 | 105 | ||
74 | === modified file 'leo/plugins/leoPluginsRef.leo' | |||
75 | --- leo/plugins/leoPluginsRef.leo 2010-01-09 19:51:52 +0000 | |||
76 | +++ leo/plugins/leoPluginsRef.leo 2010-01-10 15:58:16 +0000 | |||
77 | @@ -3,7 +3,7 @@ | |||
78 | 3 | <leo_file> | 3 | <leo_file> |
79 | 4 | <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/> | 4 | <leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/> |
80 | 5 | <globals body_outline_ratio="0.5"> | 5 | <globals body_outline_ratio="0.5"> |
82 | 6 | <global_window_position top="48" left="25" height="692" width="996"/> | 6 | <global_window_position top="48" left="10" height="692" width="1024"/> |
83 | 7 | <global_log_window_position top="0" left="0" height="0" width="0"/> | 7 | <global_log_window_position top="0" left="0" height="0" width="0"/> |
84 | 8 | </globals> | 8 | </globals> |
85 | 9 | <preferences/> | 9 | <preferences/> |
86 | @@ -32,9 +32,9 @@ | |||
87 | 32 | <v t="ekr.20090430075506.4"><vh>Notes & to-do</vh> | 32 | <v t="ekr.20090430075506.4"><vh>Notes & to-do</vh> |
88 | 33 | <v t="ekr.20090430075506.3"><vh>@thin leoPluginNotes.txt</vh></v> | 33 | <v t="ekr.20090430075506.3"><vh>@thin leoPluginNotes.txt</vh></v> |
89 | 34 | </v> | 34 | </v> |
91 | 35 | <v t="edream.110203113231.618"><vh>Plugins</vh> | 35 | <v t="edream.110203113231.618" a="E"><vh>Plugins</vh> |
92 | 36 | <v t="EKR.20040517090508"><vh> Enable plugins using @enabled-plugins nodes</vh></v> | 36 | <v t="EKR.20040517090508"><vh> Enable plugins using @enabled-plugins nodes</vh></v> |
94 | 37 | <v t="ekr.20050303051035"><vh> Templates: these show recommended ways of defining plugins.</vh> | 37 | <v t="ekr.20050303051035" a="E"><vh> Templates: these show recommended ways of defining plugins.</vh> |
95 | 38 | <v t="ekr.20041114102139"><vh>Notes</vh> | 38 | <v t="ekr.20041114102139"><vh>Notes</vh> |
96 | 39 | <v t="ekr.20041114103913"><vh>About comments in the style guide</vh></v> | 39 | <v t="ekr.20041114103913"><vh>About comments in the style guide</vh></v> |
97 | 40 | <v t="ekr.20041114102139.1"><vh>About the root node</vh></v> | 40 | <v t="ekr.20041114102139.1"><vh>About the root node</vh></v> |
98 | @@ -64,7 +64,7 @@ | |||
99 | 64 | <v t="ekr.20091118065749.5261"><vh>@thin ctagscompleter.py</vh></v> | 64 | <v t="ekr.20091118065749.5261"><vh>@thin ctagscompleter.py</vh></v> |
100 | 65 | <v t="ville.20091204224145.5355"><vh>@thin codewisecompleter.py</vh></v> | 65 | <v t="ville.20091204224145.5355"><vh>@thin codewisecompleter.py</vh></v> |
101 | 66 | </v> | 66 | </v> |
103 | 67 | <v t="ekr.20040722135402.1"><vh>Body pane</vh> | 67 | <v t="ekr.20040722135402.1" a="E"><vh>Body pane</vh> |
104 | 68 | <v t="edream.110403140857.8"><vh>@thin color_markup.py</vh></v> | 68 | <v t="edream.110403140857.8"><vh>@thin color_markup.py</vh></v> |
105 | 69 | <v t="ekr.20060506070443.1"><vh>@thin detect_urls.py</vh></v> | 69 | <v t="ekr.20060506070443.1"><vh>@thin detect_urls.py</vh></v> |
106 | 70 | <v t="edream.110203113231.753"><vh>@thin image.py</vh></v> | 70 | <v t="edream.110203113231.753"><vh>@thin image.py</vh></v> |
107 | @@ -364,7 +364,7 @@ | |||
108 | 364 | <v t="edream.110203113231.873"><vh>@thin at_folder.py</vh></v> | 364 | <v t="edream.110203113231.873"><vh>@thin at_folder.py</vh></v> |
109 | 365 | <v t="ekr.20040915085351"><vh>@thin at_produce.py</vh></v> | 365 | <v t="ekr.20040915085351"><vh>@thin at_produce.py</vh></v> |
110 | 366 | <v t="ktenney.20041211072654.1"><vh>@thin at_view.py</vh></v> | 366 | <v t="ktenney.20041211072654.1"><vh>@thin at_view.py</vh></v> |
112 | 367 | <v t="tbrown.20091029123555.5319" descendentVnodeUnknownAttributes="7d71005803000000302e3571017d710258040000007465737471037d710458050000005f6564697471057d7106580400000074686973710758120000006f6b20686f77206120626f757420746869737108737373732e"><vh>@thin attrib_edit.py</vh></v> | 367 | <v t="tbrown.20091029123555.5319" descendentVnodeUnknownAttributes="7d71005503302e3571017d710258040000007465737471037d710458050000005f6564697471057d7106580400000074686973710758120000006f6b20686f77206120626f757420746869737108737373732e"><vh>@thin attrib_edit.py</vh></v> |
113 | 368 | <v t="mork.20041020082242.1"><vh>@thin base64Packager.py</vh></v> | 368 | <v t="mork.20041020082242.1"><vh>@thin base64Packager.py</vh></v> |
114 | 369 | <v t="tbrown.20070322113635"><vh>@thin bookmarks.py</vh></v> | 369 | <v t="tbrown.20070322113635"><vh>@thin bookmarks.py</vh></v> |
115 | 370 | <v t="ekr.20060807103814.1"><vh>@thin datenodes.py</vh></v> | 370 | <v t="ekr.20060807103814.1"><vh>@thin datenodes.py</vh></v> |
116 | @@ -801,8 +801,7 @@ | |||
117 | 801 | </v> | 801 | </v> |
118 | 802 | <v t="ekr.20100103093121.5329" | 802 | <v t="ekr.20100103093121.5329" |
119 | 803 | marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes.py</vh></v> | 803 | marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes.py</vh></v> |
122 | 804 | <v t="ekr.20100103093121.5339" | 804 | <v t="ekr.20100103093121.5339"><vh>@thin stickynotes_plus.py</vh></v> |
121 | 805 | marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes_plus.py</vh></v> | ||
123 | 806 | <v t="ekr.20070119094733.1"><vh>@thin dtest.py</vh></v> | 805 | <v t="ekr.20070119094733.1"><vh>@thin dtest.py</vh></v> |
124 | 807 | </v> | 806 | </v> |
125 | 808 | <v t="ekr.20061023142737"><vh>UNL plugin</vh> | 807 | <v t="ekr.20061023142737"><vh>UNL plugin</vh> |
126 | @@ -814,7 +813,7 @@ | |||
127 | 814 | </v> | 813 | </v> |
128 | 815 | <v t="rogererens.20041013082304"><vh>@thin UNL.py</vh></v> | 814 | <v t="rogererens.20041013082304"><vh>@thin UNL.py</vh></v> |
129 | 816 | </v> | 815 | </v> |
131 | 817 | <v t="ekr.20040915073259"><vh>Windows</vh> | 816 | <v t="ekr.20040915073259" a="E"><vh>Windows</vh> |
132 | 818 | <v t="tbrown.20090322083202.1"><vh>NOTE: todo.py is qt verion of cleo.py (which is tk)</vh></v> | 817 | <v t="tbrown.20090322083202.1"><vh>NOTE: todo.py is qt verion of cleo.py (which is tk)</vh></v> |
133 | 819 | <v t="tbrown.20090119215428.2"><vh>@thin todo.py</vh></v> | 818 | <v t="tbrown.20090119215428.2"><vh>@thin todo.py</vh></v> |
134 | 820 | <v t="ekr.20050227071948"><vh> cleo</vh> | 819 | <v t="ekr.20050227071948"><vh> cleo</vh> |
135 | @@ -861,7 +860,7 @@ | |||
136 | 861 | <v t="pap.20041020001240"><vh>@thin footprints.py</vh></v> | 860 | <v t="pap.20041020001240"><vh>@thin footprints.py</vh></v> |
137 | 862 | </v> | 861 | </v> |
138 | 863 | <v t="mork.20041018162155.1"><vh>@thin EditAttributes.py</vh></v> | 862 | <v t="mork.20041018162155.1"><vh>@thin EditAttributes.py</vh></v> |
140 | 864 | <v t="ekr.20040915073259.1"><vh>@thin maximizeNewWindows.py</vh></v> | 863 | <v t="ekr.20040915073259.1" a="E"><vh>@thin maximizeNewWindows.py</vh></v> |
141 | 865 | <v t="mork.20041022155742.1"><vh>@thin nodebar.py</vh></v> | 864 | <v t="mork.20041022155742.1"><vh>@thin nodebar.py</vh></v> |
142 | 866 | <v t="edream.110203113231.924"><vh>@thin redirect_to_log.py</vh></v> | 865 | <v t="edream.110203113231.924"><vh>@thin redirect_to_log.py</vh></v> |
143 | 867 | <v t="ekr.20040915075530"><vh>@thin UASearch.py</vh></v> | 866 | <v t="ekr.20040915075530"><vh>@thin UASearch.py</vh></v> |
144 | @@ -870,7 +869,8 @@ | |||
145 | 870 | <v t="ekr.20060506070443.1"></v> | 869 | <v t="ekr.20060506070443.1"></v> |
146 | 871 | <v t="ville.20090310191936.10"><vh>@thin colorize_headlines.py</vh></v> | 870 | <v t="ville.20090310191936.10"><vh>@thin colorize_headlines.py</vh></v> |
147 | 872 | <v t="ville.20090314215508.4"><vh>@thin quicksearch.py</vh></v> | 871 | <v t="ville.20090314215508.4"><vh>@thin quicksearch.py</vh></v> |
149 | 873 | <v t="ville.20091008210853.5241"><vh>@thin stickynotes.py</vh></v> | 872 | <v t="ville.20091008210853.5241" |
150 | 873 | marks="vivainio2.20091008133028.5823,vivainio2.20091008140054.14555,ville.20091008210853.7616,ville.20091023181249.5264,vivainio2.20091008133028.5825,ville.20091023181249.5266,"><vh>@thin stickynotes.py</vh></v> | ||
151 | 874 | </v> | 874 | </v> |
152 | 875 | </v> | 875 | </v> |
153 | 876 | </vnodes> | 876 | </vnodes> |
154 | @@ -4496,7 +4496,7 @@ | |||
155 | 4496 | <t tx="ekr.20041114103913.1">PLEASE define each function or method in a separate node! To make this work, | 4496 | <t tx="ekr.20041114103913.1">PLEASE define each function or method in a separate node! To make this work, |
156 | 4497 | just put @others in the root of your plugin as shown. Note that @others may be | 4497 | just put @others in the root of your plugin as shown. Note that @others may be |
157 | 4498 | nested, as shown in class myClass.</t> | 4498 | nested, as shown in class myClass.</t> |
159 | 4499 | <t tx="ekr.20041211035618" str_leo_pos="2"></t> | 4499 | <t tx="ekr.20041211035618" str_leo_pos="2,3,1"></t> |
160 | 4500 | <t tx="ekr.20041231134702"># This is called from plugins_menu plugin. | 4500 | <t tx="ekr.20041231134702"># This is called from plugins_menu plugin. |
161 | 4501 | 4501 | ||
162 | 4502 | # It should only be defined if the extension has been registered. | 4502 | # It should only be defined if the extension has been registered. |
I have made one more improvement, that I think is important.
I have introduced an explicit 'init' function, so that info plugins- info'
about the plugin is published, when the cmd 'print-
is executed.
I have used the style found in plugin 'maximizeNewWin dows.py' .
Please check especially the section << version history >>
and my 'version' choice. - I do not know if there is any
established convention, that I should follow ...