• R/O
  • SSH
  • HTTPS

shibuya-trac: Commit


Commit MetaInfo

Revision864 (tree)
Zeit2015-04-25 07:44:04
Autorjun66j5

Log Message

NewWikiPageButton: refactored

- bump up the version to 1.1.0
- transfer newwikipagebutton.js file by Trac core rather than Genshi template rendering
- use type=submit instead of type=button in order to use styles
- removed unused imports
- removed unused files

Ändern Zusammenfassung

Diff

--- plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/entry_points.txt (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/entry_points.txt (nonexistent)
@@ -1,3 +0,0 @@
1-[trac.plugins]
2-NewWikiPageButton = newwikipagebutton
3-
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/dependency_links.txt (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/dependency_links.txt (nonexistent)
@@ -1 +0,0 @@
1-
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/SOURCES.txt (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/SOURCES.txt (nonexistent)
@@ -1,8 +0,0 @@
1-setup.py
2-NewWikiPageButton.egg-info/PKG-INFO
3-NewWikiPageButton.egg-info/SOURCES.txt
4-NewWikiPageButton.egg-info/dependency_links.txt
5-NewWikiPageButton.egg-info/entry_points.txt
6-NewWikiPageButton.egg-info/top_level.txt
7-newwikipagebutton/__init__.py
8-newwikipagebutton/newwikipagebutton.py
\ No newline at end of file
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/top_level.txt (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/NewWikiPageButton.egg-info/top_level.txt (nonexistent)
@@ -1 +0,0 @@
1-newwikipagebutton
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/setup.py (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/setup.py (revision 864)
@@ -3,15 +3,18 @@
33 from setuptools import setup
44
55 PACKAGE = 'NewWikiPageButton'
6-VERSION = '1.01'
6+VERSION = '1.1.0'
77
8-setup(name=PACKAGE,
9-version=VERSION,
10-packages=['newwikipagebutton'],
11-entry_points={'trac.plugins': '%s = newwikipagebutton' % PACKAGE},
12-package_data={'newwikipagebutton': [ 'htdocs/*.js','htdocs/*.css','htdocs/*.png','htdocs/images/*.png','htdocs/images/*.gif','templates/*.js']},
13-author = "Tomohito Ozaki",
14-author_email = "ozaki@yuroyoro.com",
15-description = "",
16-url = "http://d.hatena.ne.jp/yuroyoro/",
8+setup(
9+ name = PACKAGE,
10+ version = VERSION,
11+ packages = ['newwikipagebutton'],
12+ entry_points = {'trac.plugins': ['newwikipagebutton = newwikipagebutton']},
13+ package_data = {
14+ 'newwikipagebutton': ['htdocs/*.js'],
15+ },
16+ author = "Tomohito Ozaki",
17+ author_email = "ozaki@yuroyoro.com",
18+ description = "",
19+ url = "http://d.hatena.ne.jp/yuroyoro/",
1720 )
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/newwikipagebutton/templates/newwikipagebutton.js (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/newwikipagebutton/templates/newwikipagebutton.js (nonexistent)
@@ -1,17 +0,0 @@
1-
2-$(document).ready(function(){
3-
4- html = '<form><input type="button" value="新しいページを作成する" name="newwikipagebutton" id = "newwikipagebutton"/></form>'
5-
6- $("form#attachfile").after(html);
7- $("input#newwikipagebutton").click(function(){
8- ret = prompt("新しいページ名", "");
9- url = location.href.replace(/\/$/,"");
10- if (url.match(/\/wiki/) == null){
11- url = url + "/wiki";
12- }
13- if( ret){
14- location.href= url + "/" + ret;
15- }
16- });
17-});
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/newwikipagebutton/htdocs/newwikipagebutton.js (nonexistent)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/newwikipagebutton/htdocs/newwikipagebutton.js (revision 864)
@@ -0,0 +1,17 @@
1+jQuery(document).ready(function($) {
2+ var html = $('<form onsubmit="return false">' +
3+ '<input type="submit" value="新しいページを作成する" name="newwikipagebutton" />' +
4+ '</form>');
5+ $("form#attachfile").after(html);
6+ html.click(function(){
7+ var ret = prompt("新しいページ名", "");
8+ if (ret) {
9+ var url = location.href.replace(/\/$/,"");
10+ if (url.match(/\/wiki/) == null){
11+ url = url + "/wiki";
12+ }
13+ location.href = url + "/" + ret;
14+ }
15+ return false;
16+ });
17+});
--- plugins/NewWikiPageButtonPlugin/trunk/0.11/newwikipagebutton/newwikipagebutton.py (revision 863)
+++ plugins/NewWikiPageButtonPlugin/trunk/0.11/newwikipagebutton/newwikipagebutton.py (revision 864)
@@ -1,57 +1,31 @@
11 # -*- coding: utf-8 -*-
22 # NewWikiPageButton plugin
3-import re
4-
5-from trac.core import *
6-from trac.web.chrome import ITemplateProvider, add_stylesheet, add_script
7-from trac.web.api import IRequestFilter, IRequestHandler
8-from trac.util import escape, Markup
9-from trac.perm import IPermissionRequestor
103
114 from pkg_resources import resource_filename
125
6+from trac.core import Component, implements
7+from trac.web.api import IRequestFilter
8+from trac.web.chrome import ITemplateProvider, add_script
139
10+
1411 class NewWikiPageButtonPlugin(Component):
15- implements( IRequestHandler ,ITemplateProvider ,IRequestFilter)
1612
13+ implements(ITemplateProvider, IRequestFilter)
14+
1715 # ITemplateProvider methods
1816
1917 def get_templates_dirs(self):
20- yield resource_filename(__name__, 'templates')
18+ return ()
2119
2220 def get_htdocs_dirs(self):
2321 yield 'newwikipagebutton', resource_filename(__name__, 'htdocs')
24-
2522
26- # IRequestHandler methods
27-
28- def match_request(self, req):
29- return re.match(r'^/NewWikiPageButton/newwikipagebutton.js', req.path_info) is not None
30-
31- def process_request(self, req):
32-
33- if re.match(r'^/NewWikiPageButton/newwikipagebutton.js',req.path_info) :
34- if 'WIKI_CREATE' in req.perm('wiki') or 'WIKI_ADMIN' in req.perm('wiki'):
35-
36- return 'newwikipagebutton.js',{},'text/plain'
37-
38-
3923 # IRequestFilter methods
40-
41- def post_process_request(self, req, template, data, content_type):
42- path = req.path_info
43-
44- def uses_newwikipagebutton(req):
45- if template == 'wiki_view.html' :
46- return True
47- return False
48-
49- if uses_newwikipagebutton(req) :
50- if 'WIKI_CREATE' in req.perm('wiki') or 'WIKI_ADMIN' in req.perm('wiki'):
51- add_script(req, '/NewWikiPageButton/newwikipagebutton.js')
5224
53- return template, data, content_type
54-
5525 def pre_process_request(self, req, handler):
5626 return handler
5727
28+ def post_process_request(self, req, template, data, content_type):
29+ if template == 'wiki_view.html' and 'WIKI_CREATE' in req.perm('wiki'):
30+ add_script(req, 'newwikipagebutton/newwikipagebutton.js')
31+ return template, data, content_type
Show on old repository browser