Show More
@@ -0,0 +1,16 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import request, response, session, tmpl_context as c, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | ||
|
8 | log = logging.getLogger(__name__) | |
|
9 | ||
|
10 | class BranchesController(BaseController): | |
|
11 | ||
|
12 | def index(self): | |
|
13 | # Return a rendered template | |
|
14 | #return render('/branches.mako') | |
|
15 | # or, return a string | |
|
16 | return 'Hello World' |
@@ -0,0 +1,29 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import tmpl_context as c, app_globals as g, session, request, config, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | from pylons_app.lib.utils import get_repo_slug | |
|
8 | from pylons_app.model.hg_model import HgModel | |
|
9 | from webhelpers.paginate import Page | |
|
10 | ||
|
11 | log = logging.getLogger(__name__) | |
|
12 | ||
|
13 | class ChangelogController(BaseController): | |
|
14 | def __before__(self): | |
|
15 | c.repos_prefix = config['repos_name'] | |
|
16 | c.staticurl = g.statics | |
|
17 | c.repo_name = get_repo_slug(request) | |
|
18 | ||
|
19 | ||
|
20 | def index(self): | |
|
21 | hg_model = HgModel() | |
|
22 | p = int(request.params.get('page', 1)) | |
|
23 | repo = hg_model.get_repo(c.repo_name) | |
|
24 | c.repo_changesets = Page(repo, page=p, items_per_page=20) | |
|
25 | c.shortlog_data = render('shortlog_data.html') | |
|
26 | if request.params.get('partial'): | |
|
27 | return c.shortlog_data | |
|
28 | r = render('/shortlog.html') | |
|
29 | return r |
@@ -0,0 +1,16 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import request, response, session, tmpl_context as c, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | ||
|
8 | log = logging.getLogger(__name__) | |
|
9 | ||
|
10 | class FileController(BaseController): | |
|
11 | ||
|
12 | def index(self): | |
|
13 | # Return a rendered template | |
|
14 | #return render('/file.mako') | |
|
15 | # or, return a string | |
|
16 | return 'Hello World' |
@@ -0,0 +1,16 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import request, response, session, tmpl_context as c, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | ||
|
8 | log = logging.getLogger(__name__) | |
|
9 | ||
|
10 | class FilesController(BaseController): | |
|
11 | ||
|
12 | def index(self): | |
|
13 | # Return a rendered template | |
|
14 | #return render('/files.mako') | |
|
15 | # or, return a string | |
|
16 | return 'Hello World' |
@@ -0,0 +1,16 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import request, response, session, tmpl_context as c, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | ||
|
8 | log = logging.getLogger(__name__) | |
|
9 | ||
|
10 | class GraphController(BaseController): | |
|
11 | ||
|
12 | def index(self): | |
|
13 | # Return a rendered template | |
|
14 | #return render('/graph.mako') | |
|
15 | # or, return a string | |
|
16 | return 'Hello World' |
@@ -0,0 +1,16 b'' | |||
|
1 | import logging | |
|
2 | ||
|
3 | from pylons import request, response, session, tmpl_context as c, url | |
|
4 | from pylons.controllers.util import abort, redirect | |
|
5 | ||
|
6 | from pylons_app.lib.base import BaseController, render | |
|
7 | ||
|
8 | log = logging.getLogger(__name__) | |
|
9 | ||
|
10 | class TagsController(BaseController): | |
|
11 | ||
|
12 | def index(self): | |
|
13 | # Return a rendered template | |
|
14 | #return render('/tags.mako') | |
|
15 | # or, return a string | |
|
16 | return 'Hello World' |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestBranchesController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='branches', action='index')) | |
|
7 | # Test response... |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestChangelogController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='changelog', action='index')) | |
|
7 | # Test response... |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestFileController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='file', action='index')) | |
|
7 | # Test response... |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestFilesController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='files', action='index')) | |
|
7 | # Test response... |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestGraphController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='graph', action='index')) | |
|
7 | # Test response... |
@@ -0,0 +1,7 b'' | |||
|
1 | from pylons_app.tests import * | |
|
2 | ||
|
3 | class TestTagsController(TestController): | |
|
4 | ||
|
5 | def test_index(self): | |
|
6 | response = self.app.get(url(controller='tags', action='index')) | |
|
7 | # Test response... |
@@ -1,127 +1,128 b'' | |||
|
1 | 1 | ################################################################################ |
|
2 | 2 | ################################################################################ |
|
3 | 3 | # pylons_app - Pylons environment configuration # |
|
4 | 4 | # # |
|
5 | 5 | # The %(here)s variable will be replaced with the parent directory of this file# |
|
6 | 6 | ################################################################################ |
|
7 | 7 | |
|
8 | 8 | [DEFAULT] |
|
9 | 9 | debug = true |
|
10 | 10 | ############################################ |
|
11 | 11 | ## Uncomment and replace with the address ## |
|
12 | 12 | ## which should receive any error reports ## |
|
13 | 13 | ############################################ |
|
14 | 14 | #email_to = marcin.kuzminski@etelko.pl |
|
15 | 15 | #smtp_server = mail.etelko.pl |
|
16 | 16 | #error_email_from = paste_error@localhost |
|
17 | 17 | #smtp_username = |
|
18 | 18 | #smtp_password = |
|
19 | 19 | #error_message = 'mercurial crash !' |
|
20 | 20 | |
|
21 | 21 | [server:main] |
|
22 | 22 | ##nr of threads to spawn |
|
23 | 23 | threadpool_workers = 5 |
|
24 | 24 | |
|
25 | 25 | ##max request before |
|
26 | 26 | threadpool_max_requests = 2 |
|
27 | 27 | |
|
28 | 28 | ##option to use threads of process |
|
29 | 29 | use_threadpool = true |
|
30 | 30 | |
|
31 | 31 | use = egg:Paste#http |
|
32 | 32 | host = 127.0.0.1 |
|
33 | 33 | port = 5000 |
|
34 | 34 | |
|
35 | 35 | [app:main] |
|
36 | 36 | use = egg:pylons_app |
|
37 | 37 | full_stack = true |
|
38 | 38 | static_files = true |
|
39 | 39 | lang=en |
|
40 | 40 | cache_dir = %(here)s/data |
|
41 | 41 | repos_name = Python-works |
|
42 | 42 | |
|
43 | 43 | #################################### |
|
44 | 44 | ### BEAKER CACHE #### |
|
45 | 45 | #################################### |
|
46 | 46 | beaker.cache.data_dir=/tmp/cache/data |
|
47 | 47 | beaker.cache.lock_dir=/tmp/cache/lock |
|
48 | 48 | beaker.cache.regions=short_term |
|
49 | 49 | beaker.cache.short_term.type=memory |
|
50 |
beaker.cache.short_term.expire= |
|
|
50 | beaker.cache.short_term.expire=60 | |
|
51 | 51 | |
|
52 | 52 | ################################################################################ |
|
53 | 53 | ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ## |
|
54 | 54 | ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ## |
|
55 | 55 | ## execute malicious code after an exception is raised. ## |
|
56 | 56 | ################################################################################ |
|
57 | 57 | #set debug = false |
|
58 | 58 | |
|
59 | 59 | ################################## |
|
60 | 60 | ### LOGVIEW CONFIG ### |
|
61 | 61 | ################################## |
|
62 | 62 | logview.sqlalchemy = #faa |
|
63 | 63 | logview.pylons.templating = #bfb |
|
64 | 64 | logview.pylons.util = #eee |
|
65 | 65 | |
|
66 | 66 | ######################################################### |
|
67 | 67 | ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### |
|
68 | 68 | ######################################################### |
|
69 | 69 | sqlalchemy.db1.url = sqlite:///%(here)s/hg_app.db |
|
70 |
#sqlalchemy.db1.echo = |
|
|
70 | #sqlalchemy.db1.echo = False | |
|
71 | 71 | #sqlalchemy.db1.pool_recycle = 3600 |
|
72 | 72 | sqlalchemy.convert_unicode = true |
|
73 | 73 | |
|
74 | 74 | ################################ |
|
75 | 75 | ### LOGGING CONFIGURATION #### |
|
76 | 76 | ################################ |
|
77 | 77 | [loggers] |
|
78 | 78 | keys = root, routes, pylons_app, sqlalchemy |
|
79 | 79 | |
|
80 | 80 | [handlers] |
|
81 | 81 | keys = console |
|
82 | 82 | |
|
83 | 83 | [formatters] |
|
84 | 84 | keys = generic |
|
85 | 85 | |
|
86 | 86 | ############# |
|
87 | 87 | ## LOGGERS ## |
|
88 | 88 | ############# |
|
89 | 89 | [logger_root] |
|
90 | 90 | level = NOTSET |
|
91 | 91 | handlers = console |
|
92 | 92 | |
|
93 | 93 | [logger_routes] |
|
94 | 94 | level = DEBUG |
|
95 | 95 | handlers = console |
|
96 | 96 | qualname = routes.middleware |
|
97 | 97 | # "level = DEBUG" logs the route matched and routing variables. |
|
98 | 98 | |
|
99 | 99 | [logger_pylons_app] |
|
100 | 100 | level = DEBUG |
|
101 | 101 | handlers = console |
|
102 | 102 | qualname = pylons_app |
|
103 | 103 | |
|
104 | 104 | |
|
105 | 105 | [logger_sqlalchemy] |
|
106 |
level = |
|
|
106 | level = INFO | |
|
107 | 107 | handlers = console |
|
108 | 108 | qualname = sqlalchemy.engine |
|
109 | propagate = 0 | |
|
109 | 110 | |
|
110 | 111 | ############## |
|
111 | 112 | ## HANDLERS ## |
|
112 | 113 | ############## |
|
113 | 114 | |
|
114 | 115 | [handler_console] |
|
115 | 116 | class = StreamHandler |
|
116 | 117 | args = (sys.stderr,) |
|
117 | 118 | level = NOTSET |
|
118 | 119 | formatter = generic |
|
119 | 120 | |
|
120 | 121 | ################ |
|
121 | 122 | ## FORMATTERS ## |
|
122 | 123 | ################ |
|
123 | 124 | |
|
124 | 125 | [formatter_generic] |
|
125 | 126 | format = %(asctime)s,%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s |
|
126 | 127 | datefmt = %Y-%m-%d %H:%M:%S |
|
127 | 128 |
@@ -1,65 +1,84 b'' | |||
|
1 | 1 | #!/usr/bin/python |
|
2 | 2 | # -*- coding: utf-8 -*- |
|
3 | import logging | |
|
3 | from mako.template import Template | |
|
4 | from mercurial.hg import repository | |
|
5 | from mercurial.hgweb import hgweb | |
|
6 | from mercurial.hgweb.request import wsgiapplication | |
|
7 | from mercurial.localrepo import localrepository | |
|
8 | from operator import itemgetter | |
|
4 | 9 | from pylons import tmpl_context as c, app_globals as g, session, request, config |
|
10 | from pylons.controllers.util import abort | |
|
5 | 11 | from pylons_app.lib import helpers as h |
|
6 | 12 | from pylons_app.lib.base import BaseController, render |
|
7 | from mako.template import Template | |
|
8 | from pylons.controllers.util import abort | |
|
9 | 13 | from pylons_app.lib.utils import get_repo_slug |
|
10 | from operator import itemgetter | |
|
11 | 14 | from pylons_app.model.hg_model import HgModel |
|
15 | import logging | |
|
16 | import os | |
|
17 | from beaker.cache import cache_region | |
|
12 | 18 | log = logging.getLogger(__name__) |
|
13 | 19 | |
|
14 | 20 | class HgController(BaseController): |
|
15 | 21 | |
|
16 | 22 | def __before__(self): |
|
17 | 23 | c.repos_prefix = config['repos_name'] |
|
18 | 24 | c.staticurl = g.statics |
|
19 | 25 | c.repo_name = get_repo_slug(request) |
|
20 | 26 | |
|
21 | 27 | def index(self): |
|
28 | ||
|
29 | ||
|
22 | 30 | hg_model = HgModel() |
|
23 | c.repos_list = list(hg_model.get_repos()) | |
|
31 | @cache_region('short_term', 'repo_list') | |
|
32 | def _list(): | |
|
33 | return list(hg_model.get_repos()) | |
|
34 | ||
|
35 | c.repos_list = _list() | |
|
24 | 36 | c.current_sort = request.GET.get('sort', 'name') |
|
25 | 37 | |
|
26 | 38 | cs = c.current_sort |
|
27 | 39 | c.cs_slug = cs.replace('-', '') |
|
28 | 40 | sortables = ['name', 'description', 'last_change', 'tip', 'contact'] |
|
29 | 41 | |
|
30 | 42 | if cs and c.cs_slug in sortables: |
|
31 | 43 | sort_key = c.cs_slug + '_sort' |
|
32 | 44 | if cs.startswith('-'): |
|
33 | 45 | c.repos_list.sort(key=itemgetter(sort_key), reverse=True) |
|
34 | 46 | else: |
|
35 | 47 | c.repos_list.sort(key=itemgetter(sort_key), reverse=False) |
|
36 | 48 | |
|
37 | 49 | return render('/index.html') |
|
38 | 50 | |
|
39 | def view(self, *args, **kwargs): | |
|
40 | #TODO: reimplement this not tu use hgwebdir | |
|
51 | def view(self, environ, start_response, path_info): | |
|
52 | print path_info | |
|
53 | ||
|
54 | def app_maker(): | |
|
41 | 55 | |
|
42 | response = g.hgapp(request.environ, self.start_response) | |
|
56 | path = os.path.join(g.base_path, c.repo_name) | |
|
57 | repo = repository(g.baseui, path) | |
|
58 | hgwebapp = hgweb(repo, c.repo_name) | |
|
59 | return hgwebapp | |
|
60 | ||
|
61 | a = wsgiapplication(app_maker) | |
|
62 | resp = a(environ, start_response) | |
|
43 | 63 | |
|
44 | 64 | http_accept = request.environ.get('HTTP_ACCEPT', False) |
|
45 | 65 | if not http_accept: |
|
46 | 66 | return abort(status_code=400, detail='no http accept in header') |
|
47 | 67 | |
|
48 | 68 | #for mercurial protocols and raw files we can't wrap into mako |
|
49 | 69 | if http_accept.find("mercurial") != -1 or \ |
|
50 | 70 | request.environ['PATH_INFO'].find('raw-file') != -1: |
|
51 |
return resp |
|
|
71 | return resp | |
|
52 | 72 | try: |
|
53 |
tmpl = u''.join(resp |
|
|
73 | tmpl = u''.join(resp) | |
|
54 | 74 | template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
|
55 | 75 | .config['pylons.app_globals'].mako_lookup) |
|
56 | 76 | |
|
57 | 77 | except (RuntimeError, UnicodeDecodeError): |
|
58 | 78 | log.info('disabling unicode due to encoding error') |
|
59 |
resp |
|
|
60 |
tmpl = ''.join(resp |
|
|
79 | resp = g.hgapp(request.environ, self.start_response) | |
|
80 | tmpl = ''.join(resp) | |
|
61 | 81 | template = Template(tmpl, lookup=request.environ['pylons.pylons']\ |
|
62 | 82 | .config['pylons.app_globals'].mako_lookup, disable_unicode=True) |
|
63 | 83 | |
|
64 | ||
|
65 | 84 | return template.render(g=g, c=c, session=session, h=h) |
@@ -1,34 +1,29 b'' | |||
|
1 | 1 | import logging |
|
2 | 2 | |
|
3 | 3 | from pylons import tmpl_context as c, app_globals as g, session, request, config, url |
|
4 | 4 | from pylons.controllers.util import abort, redirect |
|
5 | 5 | |
|
6 | 6 | from pylons_app.lib.base import BaseController, render |
|
7 | 7 | from pylons_app.lib.utils import get_repo_slug |
|
8 | 8 | from pylons_app.model.hg_model import HgModel |
|
9 | 9 | from webhelpers.paginate import Page |
|
10 | 10 | |
|
11 | 11 | log = logging.getLogger(__name__) |
|
12 | 12 | |
|
13 | 13 | class ShortlogController(BaseController): |
|
14 | 14 | def __before__(self): |
|
15 | 15 | c.repos_prefix = config['repos_name'] |
|
16 | 16 | c.staticurl = g.statics |
|
17 | 17 | c.repo_name = get_repo_slug(request) |
|
18 | 18 | |
|
19 | 19 | |
|
20 | 20 | def index(self): |
|
21 | 21 | hg_model = HgModel() |
|
22 | lim = 20 | |
|
23 | 22 | p = int(request.params.get('page', 1)) |
|
24 | 23 | repo = hg_model.get_repo(c.repo_name) |
|
25 | cnt = repo.revisions[-1] | |
|
26 | gen = repo.get_changesets(None) | |
|
27 | repo_changesets = list(gen) | |
|
28 | ||
|
29 | c.repo_changesets = Page(repo_changesets, page=p, item_count=cnt, items_per_page=lim) | |
|
24 | c.repo_changesets = Page(repo, page=p, items_per_page=20) | |
|
30 | 25 | c.shortlog_data = render('shortlog_data.html') |
|
31 | 26 | if request.params.get('partial'): |
|
32 | 27 | return c.shortlog_data |
|
33 | 28 | r = render('/shortlog.html') |
|
34 | 29 | return r |
@@ -1,74 +1,92 b'' | |||
|
1 | 1 | """The application's Globals object""" |
|
2 | 2 | #uncomment the following if you want to serve a single repo |
|
3 | 3 | #from mercurial.hgweb.hgweb_mod import hgweb |
|
4 | 4 | from mercurial.hgweb.hgwebdir_mod import hgwebdir |
|
5 | 5 | from mercurial import templater |
|
6 | 6 | from mercurial.hgweb.request import wsgiapplication |
|
7 | 7 | from mercurial import ui, config |
|
8 | 8 | import os |
|
9 | 9 | from beaker.cache import CacheManager |
|
10 | 10 | from beaker.util import parse_cache_config_options |
|
11 | 11 | |
|
12 | 12 | class Globals(object): |
|
13 | 13 | |
|
14 | 14 | """Globals acts as a container for objects available throughout the |
|
15 | 15 | life of the application |
|
16 | 16 | |
|
17 | 17 | """ |
|
18 | 18 | |
|
19 | 19 | def __init__(self, config): |
|
20 | 20 | """One instance of Globals is created during application |
|
21 | 21 | initialization and is available during requests via the |
|
22 | 22 | 'app_globals' variable |
|
23 | 23 | |
|
24 | 24 | """ |
|
25 | 25 | self.cache = CacheManager(**parse_cache_config_options(config)) |
|
26 | self.hgapp = wsgiapplication(self.make_web_app) | |
|
26 | self.baseui = self.make_ui('hgwebdir.config') | |
|
27 | ||
|
28 | ||
|
29 | def make_ui(self, path='hgwebdir.config'): | |
|
30 | """ | |
|
31 | A funcion that will read python rc files and make an ui from read options | |
|
27 | 32 | |
|
28 | def make_web_app(self): | |
|
29 | repos = "hgwebdir.config" | |
|
33 | @param path: path to mercurial config file | |
|
34 | """ | |
|
35 | #propagated from mercurial documentation | |
|
36 | sections = [ | |
|
37 | 'alias', | |
|
38 | 'auth', | |
|
39 | 'decode/encode', | |
|
40 | 'defaults', | |
|
41 | 'diff', | |
|
42 | 'email', | |
|
43 | 'extensions', | |
|
44 | 'format', | |
|
45 | 'merge-patterns', | |
|
46 | 'merge-tools', | |
|
47 | 'hooks', | |
|
48 | 'http_proxy', | |
|
49 | 'smtp', | |
|
50 | 'patch', | |
|
51 | 'paths', | |
|
52 | 'profiling', | |
|
53 | 'server', | |
|
54 | 'trusted', | |
|
55 | 'ui', | |
|
56 | 'web', | |
|
57 | ] | |
|
58 | ||
|
59 | repos = path | |
|
30 | 60 | baseui = ui.ui() |
|
31 | 61 | cfg = config.config() |
|
32 | 62 | cfg.read(repos) |
|
33 | paths = cfg.items('paths') | |
|
34 | self.paths = paths | |
|
35 | self.check_repo_dir(paths) | |
|
36 | ||
|
63 | self.paths = cfg.items('paths') | |
|
64 | self.base_path = self.paths[0][1].replace('*', '') | |
|
65 | self.check_repo_dir(self.paths) | |
|
37 | 66 | self.set_statics(cfg) |
|
38 | 67 | |
|
39 | for k, v in cfg.items('web'): | |
|
40 | baseui.setconfig('web', k, v) | |
|
41 | #magic trick to make our custom template dir working | |
|
42 | templater.path.append(cfg.get('web', 'templates', None)) | |
|
43 | self.baseui = baseui | |
|
44 | #baseui.setconfig('web', 'description', '') | |
|
45 | #baseui.setconfig('web', 'name', '') | |
|
46 | #baseui.setconfig('web', 'contact', '') | |
|
47 | #baseui.setconfig('web', 'allow_archive', '') | |
|
48 | #baseui.setconfig('web', 'style', 'monoblue_plain') | |
|
49 | #baseui.setconfig('web', 'baseurl', '') | |
|
50 | #baseui.setconfig('web', 'staticurl', '') | |
|
68 | for section in sections: | |
|
69 | for k, v in cfg.items(section): | |
|
70 | baseui.setconfig(section, k, v) | |
|
51 | 71 | |
|
52 | hgwebapp = hgwebdir(paths, baseui=baseui) | |
|
53 | return hgwebapp | |
|
54 | ||
|
72 | return baseui | |
|
55 | 73 | |
|
56 | 74 | def set_statics(self, cfg): |
|
57 | 75 | ''' |
|
58 | 76 | set's the statics for use in mako templates |
|
59 | 77 | @param cfg: |
|
60 | 78 | ''' |
|
61 | 79 | self.statics = cfg.get('web', 'staticurl', '/static') |
|
62 | 80 | if not self.statics.endswith('/'): |
|
63 | 81 | self.statics += '/' |
|
64 | 82 | |
|
65 | 83 | |
|
66 | 84 | def check_repo_dir(self, paths): |
|
67 | 85 | repos_path = paths[0][1].split('/') |
|
68 | 86 | if repos_path[-1] in ['*', '**']: |
|
69 | 87 | repos_path = repos_path[:-1] |
|
70 | 88 | if repos_path[0] != '/': |
|
71 | 89 | repos_path[0] = '/' |
|
72 | 90 | if not os.path.isdir(os.path.join(*repos_path)): |
|
73 | 91 | raise Exception('Not a valid repository in %s' % paths[0][1]) |
|
74 | 92 |
@@ -1,7 +1,8 b'' | |||
|
1 | 1 | |
|
2 | 2 | def get_repo_slug(request): |
|
3 | 3 | path_info = request.environ.get('PATH_INFO') |
|
4 |
|
|
|
5 | action = path_info.split('/')[-1] | |
|
6 | ||
|
4 | uri_lst = path_info.split('/') | |
|
5 | print uri_lst | |
|
6 | print 'len', len(uri_lst) | |
|
7 | repo_name = uri_lst[1] | |
|
7 | 8 | return repo_name |
@@ -1,59 +1,60 b'' | |||
|
1 | 1 | #!/usr/bin/env python |
|
2 | 2 | # encoding: utf-8 |
|
3 | 3 | # |
|
4 | 4 | # Copyright (c) 2010 marcink. All rights reserved. |
|
5 | 5 | # |
|
6 | 6 | ''' |
|
7 | 7 | Created on Apr 9, 2010 |
|
8 | 8 | |
|
9 | 9 | @author: marcink |
|
10 | 10 | ''' |
|
11 | 11 | import os |
|
12 | 12 | from pylons import tmpl_context as c, app_globals as g, session, request, config |
|
13 | 13 | from pylons.controllers.util import abort |
|
14 | 14 | try: |
|
15 | 15 | from vcs.backends.hg import get_repositories, MercurialRepository |
|
16 | 16 | except ImportError: |
|
17 | 17 | print 'You have to import vcs module' |
|
18 | raise | |
|
18 | 19 | |
|
19 | 20 | class HgModel(object): |
|
20 | 21 | """ |
|
21 | 22 | Mercurial Model |
|
22 | 23 | """ |
|
23 | 24 | |
|
24 | 25 | |
|
25 | 26 | def __init__(self): |
|
26 | 27 | """ |
|
27 | 28 | Constructor |
|
28 | 29 | """ |
|
29 | 30 | pass |
|
30 | 31 | |
|
31 | 32 | def get_repos(self): |
|
32 | 33 | for mercurial_repo in get_repositories(g.paths[0][0], g.paths[0][1], g.baseui): |
|
33 | 34 | |
|
34 | 35 | if mercurial_repo._get_hidden(): |
|
35 | 36 | #skip hidden web repository |
|
36 | 37 | continue |
|
37 | 38 | |
|
38 | 39 | last_change = mercurial_repo.last_change |
|
39 | 40 | tip = mercurial_repo.repo.changectx('tip') |
|
40 | 41 | tmp_d = {} |
|
41 | 42 | tmp_d['name'] = mercurial_repo.name |
|
42 | 43 | tmp_d['name_sort'] = tmp_d['name'] |
|
43 | 44 | tmp_d['description'] = mercurial_repo.description |
|
44 | 45 | tmp_d['description_sort'] = tmp_d['description'] |
|
45 | 46 | tmp_d['last_change'] = last_change |
|
46 | 47 | tmp_d['last_change_sort'] = last_change[1] - last_change[0] |
|
47 | 48 | tmp_d['tip'] = str(tip) |
|
48 | 49 | tmp_d['tip_sort'] = tip.rev() |
|
49 | 50 | tmp_d['rev'] = tip.rev() |
|
50 | 51 | tmp_d['contact'] = mercurial_repo.contact |
|
51 | 52 | tmp_d['contact_sort'] = tmp_d['contact'] |
|
52 | tmp_d['repo_archives'] = mercurial_repo._get_archives() | |
|
53 | tmp_d['repo_archives'] = list(mercurial_repo._get_archives()) | |
|
53 | 54 | |
|
54 | 55 | yield tmp_d |
|
55 | 56 | |
|
56 | 57 | def get_repo(self, repo_name): |
|
57 | 58 | path = g.paths[0][1].replace('*', '') |
|
58 | 59 | repo = MercurialRepository(os.path.join(path, repo_name), baseui=g.baseui) |
|
59 | 60 | return repo |
General Comments 0
You need to be logged in to leave comments.
Login now