##// END OF EJS Templates
Fixed age, for new vcs implementation. Removed all obsolete date formatters...
marcink -
r635:fd63782c beta
parent child Browse files
Show More
@@ -8,6 +8,7 b' from pylons.middleware import ErrorHandl'
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 rhodecode.lib.middleware.simplehg import SimpleHg
10 from rhodecode.lib.middleware.simplehg import SimpleHg
11 from rhodecode.lib.middleware.simplegit import SimpleGit
11 from rhodecode.lib.middleware.https_fixup import HttpsFixup
12 from rhodecode.lib.middleware.https_fixup import HttpsFixup
12 from rhodecode.config.environment import load_environment
13 from rhodecode.config.environment import load_environment
13
14
@@ -43,6 +44,7 b' def make_app(global_conf, full_stack=Tru'
43 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
44 # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
44
45
45 app = SimpleHg(app, config)
46 app = SimpleHg(app, config)
47 app = SimpleGit(app, config)
46
48
47 if asbool(full_stack):
49 if asbool(full_stack):
48 # Handle Python exceptions
50 # Handle Python exceptions
@@ -101,7 +101,7 b' def get_commits_stats(repo_name, ts_min_'
101 commits_by_day_aggregate = {}
101 commits_by_day_aggregate = {}
102 repos_path = get_hg_ui_settings()['paths_root_path']
102 repos_path = get_hg_ui_settings()['paths_root_path']
103 p = os.path.join(repos_path, repo_name)
103 p = os.path.join(repos_path, repo_name)
104 repo = get_repo(get_scm(p)[0], p)
104 repo = get_repo(p)
105
105
106 skip_date_limit = True
106 skip_date_limit = True
107 parse_limit = 250 #limit for single task changeset parsing optimal for
107 parse_limit = 250 #limit for single task changeset parsing optimal for
@@ -312,10 +312,8 b' def __get_codes_stats(repo_name):'
312
312
313 repos_path = get_hg_ui_settings()['paths_root_path']
313 repos_path = get_hg_ui_settings()['paths_root_path']
314 p = os.path.join(repos_path, repo_name)
314 p = os.path.join(repos_path, repo_name)
315 repo = get_repo(get_scm(p)[0], p)
315 repo = get_repo(p)
316
317 tip = repo.get_changeset()
316 tip = repo.get_changeset()
318
319 code_stats = {}
317 code_stats = {}
320
318
321 def aggregate(cs):
319 def aggregate(cs):
@@ -23,6 +23,7 b' from webhelpers.pylonslib.secure_form im'
23 from webhelpers.text import chop_at, collapse, convert_accented_entities, \
23 from webhelpers.text import chop_at, collapse, convert_accented_entities, \
24 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
24 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
25 replace_whitespace, urlify, truncate, wrap_paragraphs
25 replace_whitespace, urlify, truncate, wrap_paragraphs
26 from webhelpers.date import time_ago_in_words
26
27
27 #Custom helpers here :)
28 #Custom helpers here :)
28 class _Link(object):
29 class _Link(object):
@@ -317,37 +318,50 b' def get_changeset_safe(repo, rev):'
317 flash = _Flash()
318 flash = _Flash()
318
319
319
320
320 #===============================================================================
321 #==============================================================================
321 # MERCURIAL FILTERS available via h.
322 # MERCURIAL FILTERS available via h.
322 #===============================================================================
323 #==============================================================================
323 from mercurial import util
324 from mercurial import util
324 from mercurial.templatefilters import age as _age, person as _person
325 from mercurial.templatefilters import person as _person
326
327
328
329 def _age(curdate):
330 """turns a datetime into an age string."""
325
331
326 age = lambda x:x
332 from datetime import timedelta, datetime
333 agescales = [("year", 3600 * 24 * 365),
334 ("month", 3600 * 24 * 30),
335 #("week", 3600 * 24 * 7),
336 ("day", 3600 * 24),
337 ("hour", 3600),
338 ("minute", 60),
339 ("second", 1)]
340
341 age = datetime.now() - curdate
342 age_seconds = (age.days * agescales[2][1]) + age.seconds
343
344 pos = 1
345 for scale in agescales:
346 if scale[1] <= age_seconds:
347 return time_ago_in_words(curdate, agescales[pos][0])
348 pos += 1
349
350 age = lambda x:_age(x)
327 capitalize = lambda x: x.capitalize()
351 capitalize = lambda x: x.capitalize()
328 date = lambda x: util.datestr(x)
329 email = util.email
352 email = util.email
330 email_or_none = lambda x: util.email(x) if util.email(x) != x else None
353 email_or_none = lambda x: util.email(x) if util.email(x) != x else None
331 person = lambda x: _person(x)
354 person = lambda x: _person(x)
332 hgdate = lambda x: "%d %d" % x
333 isodate = lambda x: util.datestr(x, '%Y-%m-%d %H:%M %1%2')
334 isodatesec = lambda x: util.datestr(x, '%Y-%m-%d %H:%M:%S %1%2')
335 localdate = lambda x: (x[0], util.makedate()[1])
336 rfc822date = lambda x: x#util.datestr(x, "%a, %d %b %Y %H:%M:%S %1%2")
337 rfc822date_notz = lambda x: x#util.datestr(x, "%a, %d %b %Y %H:%M:%S")
338 rfc3339date = lambda x: util.datestr(x, "%Y-%m-%dT%H:%M:%S%1:%2")
339 time_ago = lambda x: util.datestr(_age(x), "%a, %d %b %Y %H:%M:%S %1%2")
340
355
341
356 #==============================================================================
342 #===============================================================================
343 # PERMS
357 # PERMS
344 #===============================================================================
358 #==============================================================================
345 from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
359 from rhodecode.lib.auth import HasPermissionAny, HasPermissionAll, \
346 HasRepoPermissionAny, HasRepoPermissionAll
360 HasRepoPermissionAny, HasRepoPermissionAll
347
361
348 #===============================================================================
362 #==============================================================================
349 # GRAVATAR URL
363 # GRAVATAR URL
350 #===============================================================================
364 #==============================================================================
351 import hashlib
365 import hashlib
352 import urllib
366 import urllib
353 from pylons import request
367 from pylons import request
@@ -17,6 +17,14 b''
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 # MA 02110-1301, USA.
19 # MA 02110-1301, USA.
20 """
21 Created on 2010-04-28
22
23 @author: marcink
24 SimpleGit middleware for handling git protocol request (push/clone etc.)
25 It's implemented with basic auth function
26 """
27
20 from dulwich import server as dulserver
28 from dulwich import server as dulserver
21
29
22 class SimpleGitUploadPackHandler(dulserver.UploadPackHandler):
30 class SimpleGitUploadPackHandler(dulserver.UploadPackHandler):
@@ -54,22 +62,14 b' from dulwich.repo import Repo'
54 from dulwich.web import HTTPGitApplication
62 from dulwich.web import HTTPGitApplication
55 from paste.auth.basic import AuthBasicAuthenticator
63 from paste.auth.basic import AuthBasicAuthenticator
56 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
64 from paste.httpheaders import REMOTE_USER, AUTH_TYPE
57 from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware, \
65 from rhodecode.lib.auth import authfunc, HasPermissionAnyMiddleware
58 get_user_cached
59 from rhodecode.lib.utils import action_logger, is_git, invalidate_cache, \
66 from rhodecode.lib.utils import action_logger, is_git, invalidate_cache, \
60 check_repo_fast
67 check_repo_fast
68 from rhodecode.model.user import UserModel
61 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
69 from webob.exc import HTTPNotFound, HTTPForbidden, HTTPInternalServerError
62 import logging
70 import logging
63 import os
71 import os
64 import traceback
72 import traceback
65 """
66 Created on 2010-04-28
67
68 @author: marcink
69 SimpleGit middleware for handling git protocol request (push/clone etc.)
70 It's implemented with basic auth function
71 """
72
73
73
74
74
75 log = logging.getLogger(__name__)
75 log = logging.getLogger(__name__)
@@ -175,7 +175,7 b' class SimpleGit(object):'
175 return environ.get('REMOTE_USER')
175 return environ.get('REMOTE_USER')
176
176
177 def __get_user(self, username):
177 def __get_user(self, username):
178 return get_user_cached(username)
178 return UserModel().get_by_username(username, cache=True)
179
179
180 def __get_action(self, environ):
180 def __get_action(self, environ):
181 """
181 """
@@ -1010,7 +1010,7 b' padding:0;'
1010 #content div.box table th {
1010 #content div.box table th {
1011 background:#eee;
1011 background:#eee;
1012 border-bottom:1px solid #ddd;
1012 border-bottom:1px solid #ddd;
1013 padding:10px;
1013 padding:5px 0px 5px 5px;
1014 }
1014 }
1015
1015
1016 #content div.box table th.left {
1016 #content div.box table th.left {
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -55,6 +55,14 b''
55 %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(repo['name'],'main page check'):
55 %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(repo['name'],'main page check'):
56 <tr class="parity${cnt%2}">
56 <tr class="parity${cnt%2}">
57 <td>
57 <td>
58 %if repo['repo'].dbrepo.repo_type =='hg':
59 <img class="icon" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
60 %elif repo['repo'].dbrepo.repo_type =='git':
61 <img class="icon" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
62 %else:
63
64 %endif
65
58 %if repo['repo'].dbrepo.private:
66 %if repo['repo'].dbrepo.private:
59 <img class="icon" alt="${_('private')}" src="/images/icons/lock.png"/>
67 <img class="icon" alt="${_('private')}" src="/images/icons/lock.png"/>
60 %else:
68 %else:
@@ -70,7 +78,8 b''
70 %endif
78 %endif
71 </td>
79 </td>
72 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
80 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
73 <td>${h.age(repo['last_change'])}</td>
81 <td><span class="tooltip" tooltip_title="${repo['last_change']}">
82 ${h.age(repo['last_change'])} </span></td>
74 <td>
83 <td>
75 %if repo['rev']>=0:
84 %if repo['rev']>=0:
76 ${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
85 ${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
@@ -13,7 +13,7 b''
13 </tr>
13 </tr>
14 %for cnt,cs in enumerate(c.repo_changesets):
14 %for cnt,cs in enumerate(c.repo_changesets):
15 <tr class="parity${cnt%2}">
15 <tr class="parity${cnt%2}">
16 <td>${h.age(cs.date)} - ${h.rfc822date_notz(cs.date)} </td>
16 <td>${h.age(cs.date)} - ${cs.date} </td>
17 <td title="${cs.author}">${h.person(cs.author)}</td>
17 <td title="${cs.author}">${h.person(cs.author)}</td>
18 <td>r${cs.revision}:${cs.short_id}</td>
18 <td>r${cs.revision}:${cs.short_id}</td>
19 <td>
19 <td>
@@ -92,7 +92,7 b' E.onDOMReady(function(e){'
92 <label>${_('Last change')}:</label>
92 <label>${_('Last change')}:</label>
93 </div>
93 </div>
94 <div class="input-short">
94 <div class="input-short">
95 ${h.age(c.repo_info.last_change)} - ${h.rfc822date_notz(c.repo_info.last_change)}
95 ${h.age(c.repo_info.last_change)} - ${c.repo_info.last_change}
96 ${_('by')} ${h.get_changeset_safe(c.repo_info,'tip').author}
96 ${_('by')} ${h.get_changeset_safe(c.repo_info,'tip').author}
97
97
98 </div>
98 </div>
@@ -4,13 +4,13 b' py_version = sys.version_info'
4
4
5 requirements = [
5 requirements = [
6 "Pylons>=1.0.0",
6 "Pylons>=1.0.0",
7 "SQLAlchemy>=0.6",
7 "SQLAlchemy>=0.6.4",
8 "Mako>=0.3.2",
8 "Mako>=0.3.5",
9 "vcs==0.1.8",
9 "vcs==0.1.10",
10 "pygments>=1.3.0",
10 "pygments>=1.3.0",
11 "mercurial>=1.6",
11 "mercurial==1.6.4",
12 "whoosh==1.0.0",
12 "whoosh==1.1.0",
13 "celery>=2.0.0",
13 "celery==2.1.1",
14 "py-bcrypt",
14 "py-bcrypt",
15 "babel",
15 "babel",
16 ]
16 ]
General Comments 0
You need to be logged in to leave comments. Login now