Show More
@@ -1,13 +1,13 | |||||
1 | """ |
|
1 | """ | |
2 | Hg app, a web based mercurial repository managment based on pylons |
|
2 | Hg app, a web based mercurial repository managment based on pylons | |
3 | """ |
|
3 | """ | |
4 |
|
4 | |||
5 |
VERSION = (0, 7, |
|
5 | VERSION = (0, 7, 1, 'beta') | |
6 |
|
6 | |||
7 | __version__ = '.'.join((str(each) for each in VERSION[:4])) |
|
7 | __version__ = '.'.join((str(each) for each in VERSION[:4])) | |
8 |
|
8 | |||
9 | def get_version(): |
|
9 | def get_version(): | |
10 | """ |
|
10 | """ | |
11 | Returns shorter version (digit parts only) as string. |
|
11 | Returns shorter version (digit parts only) as string. | |
12 | """ |
|
12 | """ | |
13 | return '.'.join((str(each) for each in VERSION[:3])) |
|
13 | return '.'.join((str(each) for each in VERSION[:3])) |
@@ -1,72 +1,73 | |||||
1 | """Pylons middleware initialization""" |
|
1 | """Pylons middleware initialization""" | |
2 | from beaker.middleware import SessionMiddleware |
|
2 | from beaker.middleware import SessionMiddleware | |
3 | from paste.cascade import Cascade |
|
3 | from paste.cascade import Cascade | |
4 | from paste.registry import RegistryManager |
|
4 | from paste.registry import RegistryManager | |
5 | from paste.urlparser import StaticURLParser |
|
5 | from paste.urlparser import StaticURLParser | |
6 | from paste.deploy.converters import asbool |
|
6 | from paste.deploy.converters import asbool | |
7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect |
|
7 | from pylons.middleware import ErrorHandler, StatusCodeRedirect | |
8 | from pylons.wsgiapp import PylonsApp |
|
8 | from pylons.wsgiapp import PylonsApp | |
9 | from routes.middleware import RoutesMiddleware |
|
9 | from routes.middleware import RoutesMiddleware | |
10 | from pylons_app.lib.middleware.simplehg import SimpleHg |
|
10 | from pylons_app.lib.middleware.simplehg import SimpleHg | |
11 | from pylons_app.lib.middleware.https_fixup import HttpsFixup |
|
11 | from pylons_app.lib.middleware.https_fixup import HttpsFixup | |
12 | from pylons_app.config.environment import load_environment |
|
12 | from pylons_app.config.environment import load_environment | |
13 |
|
13 | |||
14 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): |
|
14 | def make_app(global_conf, full_stack=True, static_files=True, **app_conf): | |
15 | """Create a Pylons WSGI application and return it |
|
15 | """Create a Pylons WSGI application and return it | |
16 |
|
16 | |||
17 | ``global_conf`` |
|
17 | ``global_conf`` | |
18 | The inherited configuration for this application. Normally from |
|
18 | The inherited configuration for this application. Normally from | |
19 | the [DEFAULT] section of the Paste ini file. |
|
19 | the [DEFAULT] section of the Paste ini file. | |
20 |
|
20 | |||
21 | ``full_stack`` |
|
21 | ``full_stack`` | |
22 | Whether or not this application provides a full WSGI stack (by |
|
22 | Whether or not this application provides a full WSGI stack (by | |
23 | default, meaning it handles its own exceptions and errors). |
|
23 | default, meaning it handles its own exceptions and errors). | |
24 | Disable full_stack when this application is "managed" by |
|
24 | Disable full_stack when this application is "managed" by | |
25 | another WSGI middleware. |
|
25 | another WSGI middleware. | |
26 |
|
26 | |||
27 | ``app_conf`` |
|
27 | ``app_conf`` | |
28 | The application's local configuration. Normally specified in |
|
28 | The application's local configuration. Normally specified in | |
29 | the [app:<name>] section of the Paste ini file (where <name> |
|
29 | the [app:<name>] section of the Paste ini file (where <name> | |
30 | defaults to main). |
|
30 | defaults to main). | |
31 |
|
31 | |||
32 | """ |
|
32 | """ | |
33 | # Configure the Pylons environment |
|
33 | # Configure the Pylons environment | |
34 | config = load_environment(global_conf, app_conf) |
|
34 | config = load_environment(global_conf, app_conf) | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | # The Pylons WSGI app |
|
37 | # The Pylons WSGI app | |
38 | app = PylonsApp(config=config) |
|
38 | app = PylonsApp(config=config) | |
39 |
|
39 | |||
40 |
|
40 | |||
41 | # Routing/Session/Cache Middleware |
|
41 | # Routing/Session/Cache Middleware | |
42 | app = RoutesMiddleware(app, config['routes.map']) |
|
42 | app = RoutesMiddleware(app, config['routes.map']) | |
43 | app = SessionMiddleware(app, config) |
|
43 | app = SessionMiddleware(app, config) | |
44 |
|
44 | |||
45 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) |
|
45 | # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) | |
46 | #set the https based on HTTP_X_URL_SCHEME |
|
46 | #set the https based on HTTP_X_URL_SCHEME | |
47 | app = HttpsFixup(app) |
|
47 | ||
48 | app = SimpleHg(app, config) |
|
48 | app = SimpleHg(app, config) | |
49 |
|
49 | |||
50 | if asbool(full_stack): |
|
50 | if asbool(full_stack): | |
51 | # Handle Python exceptions |
|
51 | # Handle Python exceptions | |
52 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) |
|
52 | app = ErrorHandler(app, global_conf, **config['pylons.errorware']) | |
53 |
|
53 | |||
54 | # Display error documents for 401, 403, 404 status codes (and |
|
54 | # Display error documents for 401, 403, 404 status codes (and | |
55 | # 500 when debug is disabled) |
|
55 | # 500 when debug is disabled) | |
56 | if asbool(config['debug']): |
|
56 | if asbool(config['debug']): | |
57 | app = StatusCodeRedirect(app) |
|
57 | app = StatusCodeRedirect(app) | |
58 | else: |
|
58 | else: | |
59 | app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) |
|
59 | app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) | |
60 |
|
60 | |||
|
61 | app = HttpsFixup(app) | |||
61 | # Establish the Registry for this application |
|
62 | # Establish the Registry for this application | |
62 | app = RegistryManager(app) |
|
63 | app = RegistryManager(app) | |
63 |
|
64 | |||
64 | if asbool(static_files): |
|
65 | if asbool(static_files): | |
65 | # Serve static files |
|
66 | # Serve static files | |
66 | static_app = StaticURLParser(config['pylons.paths']['static_files']) |
|
67 | static_app = StaticURLParser(config['pylons.paths']['static_files']) | |
67 | app = Cascade([static_app, app]) |
|
68 | app = Cascade([static_app, app]) | |
68 |
|
69 | |||
69 | app.config = config |
|
70 | app.config = config | |
70 |
|
71 | |||
71 | return app |
|
72 | return app | |
72 |
|
73 |
@@ -1,22 +1,61 | |||||
1 | #!/usr/bin/python |
|
1 | #!/usr/bin/python | |
2 | # -*- coding: utf-8 -*- |
|
2 | # -*- coding: utf-8 -*- | |
3 | import logging |
|
3 | import logging | |
4 | from operator import itemgetter |
|
4 | from operator import itemgetter | |
5 | from pylons import tmpl_context as c, request, config |
|
5 | from pylons import tmpl_context as c, request, config, url, response | |
6 | from pylons_app.lib.base import BaseController, render |
|
6 | from pylons_app.lib.base import BaseController, render, _full_changelog_cached | |
7 | from pylons_app.lib.utils import get_repo_slug |
|
7 | from pylons_app.lib.utils import get_repo_slug | |
8 | from pylons_app.model.hg_model import HgModel |
|
8 | from pylons_app.model.hg_model import HgModel | |
9 | from pylons_app.lib.auth import LoginRequired |
|
9 | from pylons_app.lib.auth import LoginRequired | |
|
10 | from webhelpers.feedgenerator import Atom1Feed, Rss201rev2Feed | |||
10 | log = logging.getLogger(__name__) |
|
11 | log = logging.getLogger(__name__) | |
11 |
|
12 | |||
12 | class FeedController(BaseController): |
|
13 | class FeedController(BaseController): | |
13 |
|
14 | |||
14 | #secure it or not ? |
|
15 | #secure it or not ? | |
15 | def __before__(self): |
|
16 | def __before__(self): | |
16 | super(FeedController, self).__before__() |
|
17 | super(FeedController, self).__before__() | |
|
18 | #common values for feeds | |||
|
19 | self.description = 'Changes on %s repository' | |||
|
20 | self.title = "%s feed" | |||
|
21 | self.language = 'en-us' | |||
|
22 | self.ttl = "5" | |||
|
23 | self.feed_nr = 10 | |||
|
24 | ||||
|
25 | def atom(self, repo_name): | |||
|
26 | """Produce an atom-1.0 feed via feedgenerator module""" | |||
|
27 | feed = Atom1Feed(title=self.title % repo_name, | |||
|
28 | link=url('summary_home', repo_name=repo_name, qualified=True), | |||
|
29 | description=self.description % repo_name, | |||
|
30 | language=self.language, | |||
|
31 | ttl=self.ttl) | |||
17 |
|
32 | |||
18 | def atom(self): |
|
33 | ||
19 | return 'Hello Atom' |
|
34 | for cnt, cs in enumerate(_full_changelog_cached(repo_name)): | |
|
35 | if cnt > self.feed_nr: | |||
|
36 | break | |||
|
37 | feed.add_item(title=cs.message, | |||
|
38 | link=url('changeset_home', repo_name=repo_name, revision=cs.raw_id, qualified=True), | |||
|
39 | description=str(cs.date)) | |||
|
40 | ||||
|
41 | response.content_type = feed.mime_type | |||
|
42 | return feed.writeString('utf-8') | |||
|
43 | ||||
20 |
|
44 | |||
21 | def rss(self): |
|
45 | def rss(self, repo_name): | |
22 | return 'Hello rss' |
|
46 | """Produce an rss2 feed via feedgenerator module""" | |
|
47 | feed = Rss201rev2Feed(title=self.title % repo_name, | |||
|
48 | link=url('summary_home', repo_name=repo_name, qualified=True), | |||
|
49 | description=self.description % repo_name, | |||
|
50 | language=self.language, | |||
|
51 | ttl=self.ttl) | |||
|
52 | ||||
|
53 | for cnt, cs in enumerate(_full_changelog_cached(repo_name)): | |||
|
54 | if cnt > self.feed_nr: | |||
|
55 | break | |||
|
56 | feed.add_item(title=cs.message, | |||
|
57 | link=url('changeset_home', repo_name=repo_name, revision=cs.raw_id, qualified=True), | |||
|
58 | description=str(cs.date)) | |||
|
59 | ||||
|
60 | response.content_type = feed.mime_type | |||
|
61 | return feed.writeString('utf-8') |
General Comments 0
You need to be logged in to leave comments.
Login now