# HG changeset patch # User Marcin Kuzminski # Date 1287969541 -7200 # Node ID fd63782c44269119a0cc3c1d41ce4c6dcb3795f5 # Parent 0d18cf02278adb86ef9b0be4bdfe55f449dfcfcc Fixed age, for new vcs implementation. Removed all obsolete date formatters Added simplegit middleware. fixed deps added scm type icon to main page diff -r 0d18cf02278a -r fd63782c4426 rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/config/middleware.py Mon Oct 25 03:19:01 2010 +0200 @@ -8,6 +8,7 @@ from pylons.wsgiapp import PylonsApp from routes.middleware import RoutesMiddleware from rhodecode.lib.middleware.simplehg import SimpleHg +from rhodecode.lib.middleware.simplegit import SimpleGit from rhodecode.lib.middleware.https_fixup import HttpsFixup from rhodecode.config.environment import load_environment @@ -35,15 +36,16 @@ # The Pylons WSGI app app = PylonsApp(config=config) - + # Routing/Session/Cache Middleware app = RoutesMiddleware(app, config['routes.map']) app = SessionMiddleware(app, config) - + # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares) - + app = SimpleHg(app, config) - + app = SimpleGit(app, config) + if asbool(full_stack): # Handle Python exceptions app = ErrorHandler(app, global_conf, **config['pylons.errorware']) @@ -54,10 +56,10 @@ app = StatusCodeRedirect(app) else: app = StatusCodeRedirect(app, [400, 401, 403, 404, 500]) - + #enable https redirets based on HTTP_X_URL_SCHEME set by proxy app = HttpsFixup(app) - + # Establish the Registry for this application app = RegistryManager(app) @@ -65,7 +67,7 @@ # Serve static files static_app = StaticURLParser(config['pylons.paths']['static_files']) app = Cascade([static_app, app]) - + app.config = config return app diff -r 0d18cf02278a -r fd63782c4426 rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/lib/celerylib/tasks.py Mon Oct 25 03:19:01 2010 +0200 @@ -101,7 +101,7 @@ commits_by_day_aggregate = {} repos_path = get_hg_ui_settings()['paths_root_path'] p = os.path.join(repos_path, repo_name) - repo = get_repo(get_scm(p)[0], p) + repo = get_repo(p) skip_date_limit = True parse_limit = 250 #limit for single task changeset parsing optimal for @@ -312,10 +312,8 @@ repos_path = get_hg_ui_settings()['paths_root_path'] p = os.path.join(repos_path, repo_name) - repo = get_repo(get_scm(p)[0], p) - + repo = get_repo(p) tip = repo.get_changeset() - code_stats = {} def aggregate(cs): diff -r 0d18cf02278a -r fd63782c4426 rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/lib/helpers.py Mon Oct 25 03:19:01 2010 +0200 @@ -23,6 +23,7 @@ from webhelpers.text import chop_at, collapse, convert_accented_entities, \ convert_misc_entities, lchop, plural, rchop, remove_formatting, \ replace_whitespace, urlify, truncate, wrap_paragraphs +from webhelpers.date import time_ago_in_words #Custom helpers here :) class _Link(object): @@ -317,37 +318,50 @@ flash = _Flash() -#=============================================================================== +#============================================================================== # MERCURIAL FILTERS available via h. -#=============================================================================== +#============================================================================== from mercurial import util -from mercurial.templatefilters import age as _age, person as _person +from mercurial.templatefilters import person as _person + + + +def _age(curdate): + """turns a datetime into an age string.""" -age = lambda x:x + from datetime import timedelta, datetime + agescales = [("year", 3600 * 24 * 365), + ("month", 3600 * 24 * 30), + #("week", 3600 * 24 * 7), + ("day", 3600 * 24), + ("hour", 3600), + ("minute", 60), + ("second", 1)] + + age = datetime.now() - curdate + age_seconds = (age.days * agescales[2][1]) + age.seconds + + pos = 1 + for scale in agescales: + if scale[1] <= age_seconds: + return time_ago_in_words(curdate, agescales[pos][0]) + pos += 1 + +age = lambda x:_age(x) capitalize = lambda x: x.capitalize() -date = lambda x: util.datestr(x) email = util.email email_or_none = lambda x: util.email(x) if util.email(x) != x else None person = lambda x: _person(x) -hgdate = lambda x: "%d %d" % x -isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2') -isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2') -localdate = lambda x: (x[0], util.makedate()[1]) -rfc822date = lambda x: x#util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2") -rfc822date_notz = lambda x: x#util.datestr(x, "%a, %d %b %Y %H:%M:%S") -rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2") -time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2") - -#=============================================================================== +#============================================================================== # PERMS -#=============================================================================== +#============================================================================== from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \ HasRepoPermissionAny, HasRepoPermissionAll -#=============================================================================== +#============================================================================== # GRAVATAR URL -#=============================================================================== +#============================================================================== import hashlib import urllib from pylons import request diff -r 0d18cf02278a -r fd63782c4426 rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/lib/middleware/simplegit.py Mon Oct 25 03:19:01 2010 +0200 @@ -17,6 +17,14 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. +""" +Created on 2010-04-28 + +@author: marcink +SimpleGit middleware for handling git protocol request (push/clone etc.) +It's implemented with basic auth function +""" + from dulwich import server as dulserver class SimpleGitUploadPackHandler(dulserver.UploadPackHandler): @@ -54,22 +62,14 @@ from dulwich.web import HTTPGitApplication from paste.auth.basic import AuthBasicAuthenticator from paste.httpheaders import REMOTE_USER, AUTH_TYPE -from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware, \ - get_user_cached +from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware from rhodecode.lib.utils import action_logger, is_git, invalidate_cache, \ check_repo_fast +from rhodecode.model.user import UserModel from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError import logging import os import traceback -""" -Created on 2010-04-28 - -@author: marcink -SimpleGit middleware for handling git protocol request (push/clone etc.) -It's implemented with basic auth function -""" - log = logging.getLogger(__name__) @@ -175,7 +175,7 @@ return environ.get('REMOTE_USER') def __get_user(self, username): - return get_user_cached(username) + return UserModel().get_by_username(username, cache=True) def __get_action(self, environ): """ diff -r 0d18cf02278a -r fd63782c4426 rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/public/css/style.css Mon Oct 25 03:19:01 2010 +0200 @@ -1010,7 +1010,7 @@ #content div.box table th { background:#eee; border-bottom:1px solid #ddd; -padding:10px; +padding:5px 0px 5px 5px; } #content div.box table th.left { diff -r 0d18cf02278a -r fd63782c4426 rhodecode/public/images/icons/giticon.png Binary file rhodecode/public/images/icons/giticon.png has changed diff -r 0d18cf02278a -r fd63782c4426 rhodecode/templates/index.html --- a/rhodecode/templates/index.html Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/templates/index.html Mon Oct 25 03:19:01 2010 +0200 @@ -55,6 +55,14 @@ %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(repo['name'],'main page check'): + %if repo['repo'].dbrepo.repo_type =='hg': + ${_('Mercurial repository')} + %elif repo['repo'].dbrepo.repo_type =='git': + ${_('Git repository')} + %else: + + %endif + %if repo['repo'].dbrepo.private: ${_('private')} %else: @@ -70,7 +78,8 @@ %endif ${h.truncate(repo['description'],60)} - ${h.age(repo['last_change'])} + + ${h.age(repo['last_change'])} %if repo['rev']>=0: ${h.link_to('r%s:%s' % (repo['rev'],repo['tip']), diff -r 0d18cf02278a -r fd63782c4426 rhodecode/templates/shortlog/shortlog_data.html --- a/rhodecode/templates/shortlog/shortlog_data.html Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/templates/shortlog/shortlog_data.html Mon Oct 25 03:19:01 2010 +0200 @@ -13,7 +13,7 @@ %for cnt,cs in enumerate(c.repo_changesets): - ${h.age(cs.date)} - ${h.rfc822date_notz(cs.date)} + ${h.age(cs.date)} - ${cs.date} ${h.person(cs.author)} r${cs.revision}:${cs.short_id} diff -r 0d18cf02278a -r fd63782c4426 rhodecode/templates/summary/summary.html --- a/rhodecode/templates/summary/summary.html Sun Oct 24 22:29:35 2010 +0200 +++ b/rhodecode/templates/summary/summary.html Mon Oct 25 03:19:01 2010 +0200 @@ -92,7 +92,7 @@
- ${h.age(c.repo_info.last_change)} - ${h.rfc822date_notz(c.repo_info.last_change)} + ${h.age(c.repo_info.last_change)} - ${c.repo_info.last_change} ${_('by')} ${h.get_changeset_safe(c.repo_info,'tip').author}
diff -r 0d18cf02278a -r fd63782c4426 setup.py --- a/setup.py Sun Oct 24 22:29:35 2010 +0200 +++ b/setup.py Mon Oct 25 03:19:01 2010 +0200 @@ -4,13 +4,13 @@ requirements = [ "Pylons>=1.0.0", - "SQLAlchemy>=0.6", - "Mako>=0.3.2", - "vcs==0.1.8", + "SQLAlchemy>=0.6.4", + "Mako>=0.3.5", + "vcs==0.1.10", "pygments>=1.3.0", - "mercurial>=1.6", - "whoosh==1.0.0", - "celery>=2.0.0", + "mercurial==1.6.4", + "whoosh==1.1.0", + "celery==2.1.1", "py-bcrypt", "babel", ]