Changeset - fd63782c4426
[Not reviewed]
beta
0 10 0
Marcin Kuzminski - 15 years ago 2010-10-25 03:19:01
marcin@python-works.com
Fixed age, for new vcs implementation. Removed all obsolete date formatters
Added simplegit middleware.
fixed deps
added scm type icon to main page
10 files changed with 66 insertions and 43 deletions:
0 comments (0 inline, 0 general)
rhodecode/config/middleware.py
Show inline comments
 
@@ -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
 

	
 
@@ -43,6 +44,7 @@ def make_app(global_conf, full_stack=Tru
 
    # CUSTOM MIDDLEWARE HERE (filtered by error handling middlewares)
 
    
 
    app = SimpleHg(app, config)
 
    app = SimpleGit(app, config)
 
    
 
    if asbool(full_stack):
 
        # Handle Python exceptions
rhodecode/lib/celerylib/tasks.py
Show inline comments
 
@@ -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):
rhodecode/lib/helpers.py
Show inline comments
 
@@ -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
rhodecode/lib/middleware/simplegit.py
Show inline comments
 
@@ -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):
 
        """
rhodecode/public/css/style.css
Show inline comments
 
@@ -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 {
rhodecode/public/images/icons/giticon.png
Show inline comments
 
binary diff not shown
Show images
rhodecode/templates/index.html
Show inline comments
 
@@ -55,6 +55,14 @@
 
					        %if h.HasRepoPermissionAny('repository.write','repository.read','repository.admin')(repo['name'],'main page check'):
 
					        <tr class="parity${cnt%2}">
 
					            <td>
 
					             %if repo['repo'].dbrepo.repo_type =='hg':
 
					               <img class="icon" alt="${_('Mercurial repository')}" src="/images/icons/hgicon.png"/>
 
					             %elif repo['repo'].dbrepo.repo_type =='git':
 
					               <img class="icon" alt="${_('Git repository')}" src="/images/icons/giticon.png"/>
 
					             %else:
 
					               
 
					             %endif 
 
					            
 
					             %if repo['repo'].dbrepo.private:
 
					                <img class="icon" alt="${_('private')}" src="/images/icons/lock.png"/>
 
					             %else:
 
@@ -70,7 +78,8 @@
 
					            %endif
 
					            </td>
 
					            <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
 
					            <td>${h.age(repo['last_change'])}</td>
 
					            <td><span class="tooltip" tooltip_title="${repo['last_change']}">
 
					                ${h.age(repo['last_change'])} </span></td>
 
					            <td>
 
					            	%if repo['rev']>=0:
 
					            	${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
rhodecode/templates/shortlog/shortlog_data.html
Show inline comments
 
@@ -13,7 +13,7 @@
 
	</tr>
 
%for cnt,cs in enumerate(c.repo_changesets):
 
	<tr class="parity${cnt%2}">
 
		<td>${h.age(cs.date)} - ${h.rfc822date_notz(cs.date)} </td>
 
		<td>${h.age(cs.date)} - ${cs.date} </td>
 
		<td title="${cs.author}">${h.person(cs.author)}</td>
 
		<td>r${cs.revision}:${cs.short_id}</td>
 
		<td>
rhodecode/templates/summary/summary.html
Show inline comments
 
@@ -92,7 +92,7 @@ E.onDOMReady(function(e){
 
			      <label>${_('Last change')}:</label>
 
			  </div>
 
			  <div class="input-short">
 
			      ${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} 
 
			      
 
			  </div>
setup.py
Show inline comments
 
@@ -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",
 
    ]
0 comments (0 inline, 0 general)