diff --git a/rhodecode/config/middleware.py b/rhodecode/config/middleware.py --- a/rhodecode/config/middleware.py +++ b/rhodecode/config/middleware.py @@ -8,6 +8,7 @@ from pylons.middleware import ErrorHandl 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 @@ def make_app(global_conf, full_stack=Tru # 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 @@ def make_app(global_conf, full_stack=Tru 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 @@ def make_app(global_conf, full_stack=Tru # Serve static files static_app = StaticURLParser(config['pylons.paths']['static_files']) app = Cascade([static_app, app]) - + app.config = config return app diff --git a/rhodecode/lib/celerylib/tasks.py b/rhodecode/lib/celerylib/tasks.py --- a/rhodecode/lib/celerylib/tasks.py +++ b/rhodecode/lib/celerylib/tasks.py @@ -101,7 +101,7 @@ def get_commits_stats(repo_name, ts_min_ 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 @@ def __get_codes_stats(repo_name): 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 --git a/rhodecode/lib/helpers.py b/rhodecode/lib/helpers.py --- a/rhodecode/lib/helpers.py +++ b/rhodecode/lib/helpers.py @@ -23,6 +23,7 @@ from webhelpers.pylonslib.secure_form im 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 @@ def get_changeset_safe(repo, rev): 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 --git a/rhodecode/lib/middleware/simplegit.py b/rhodecode/lib/middleware/simplegit.py --- a/rhodecode/lib/middleware/simplegit.py +++ b/rhodecode/lib/middleware/simplegit.py @@ -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.repo import Repo 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 @@ class SimpleGit(object): 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 --git a/rhodecode/public/css/style.css b/rhodecode/public/css/style.css --- a/rhodecode/public/css/style.css +++ b/rhodecode/public/css/style.css @@ -1010,7 +1010,7 @@ padding:0; #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 --git a/rhodecode/public/images/icons/giticon.png b/rhodecode/public/images/icons/giticon.png index aae35a70e70351fe6dcb3e905e2e388cf0cb0ac3..3f909ea413d66fb362b1991c22c869b36909891c GIT binary patch literal 318 zc$@(~0m1%>P)AbwBC0AnPZvAJXqAp_1LIk^K$S0Kp|^ul{2 zTVT%JLv$b>aF0|1QlU81uXfnE{2n0}C?Po=oA+=Vke;5-z@Wefa;`E|p)pcSfDLd! zGm#04Eone}7by^TL-9+lAmAXL*VB(Y9tV3wmhADatcPOd=nb0?HeBPJS=K?R|_ zfbN1lP@8rm`BxC?d}D0s0hp#T5? diff --git a/rhodecode/templates/index.html b/rhodecode/templates/index.html --- a/rhodecode/templates/index.html +++ b/rhodecode/templates/index.html @@ -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 --git a/rhodecode/templates/shortlog/shortlog_data.html b/rhodecode/templates/shortlog/shortlog_data.html --- a/rhodecode/templates/shortlog/shortlog_data.html +++ b/rhodecode/templates/shortlog/shortlog_data.html @@ -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 --git a/rhodecode/templates/summary/summary.html b/rhodecode/templates/summary/summary.html --- a/rhodecode/templates/summary/summary.html +++ b/rhodecode/templates/summary/summary.html @@ -92,7 +92,7 @@ E.onDOMReady(function(e){
- ${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 --git a/setup.py b/setup.py --- a/setup.py +++ b/setup.py @@ -4,13 +4,13 @@ py_version = sys.version_info 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", ]