Mercurial > kallithea
changeset 3850:7a4df261a375 beta
added alias configuration option for gists.
Used to generate nice looking urls for gists
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 12 May 2013 16:58:01 +0200 |
parents | b4fc29a051ae |
children | 24e479e21334 |
files | development.ini docs/setup.rst production.ini rhodecode/config/deployment.ini_tmpl rhodecode/model/db.py rhodecode/templates/admin/gists/show.html |
diffstat | 6 files changed, 57 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Sun May 12 14:32:38 2013 +0200 +++ b/development.ini Sun May 12 16:58:01 2013 +0200 @@ -115,6 +115,12 @@ show_sha_length = 12 show_revision_number = true +## gist URL alias, used to create nicer urls for gist. This should be an +## url that does rewrites to _admin/gists/<gistid>. +## example: http://gist.rhodecode.org/{gistid}. Empty means use the internal +## RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/<gistid> +gist_alias_url = + ## white list of API enabled controllers. This allows to add list of ## controllers to which access will be enabled by api_key. eg: to enable ## api access to raw_files put `FilesController:raw`, to enable access to patches
--- a/docs/setup.rst Sun May 12 14:32:38 2013 +0200 +++ b/docs/setup.rst Sun May 12 16:58:01 2013 +0200 @@ -534,6 +534,28 @@ #server 127.0.0.1:5002; } + ## gist alias + server { + listen 443; + server_name gist.myserver.com; + access_log /var/log/nginx/gist.access.log; + error_log /var/log/nginx/gist.error.log; + + ssl on; + ssl_certificate gist.rhodecode.myserver.com.crt; + ssl_certificate_key gist.rhodecode.myserver.com.key; + + ssl_session_timeout 5m; + + ssl_protocols SSLv3 TLSv1; + ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; + ssl_prefer_server_ciphers on; + + location / { + rewrite ^/(.*) https://rhodecode.myserver.com/_admin/gists/$1; + } + } + server { listen 443; server_name rhodecode.myserver.com; @@ -550,16 +572,8 @@ ssl_ciphers DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:EDH-RSA-DES-CBC3-SHA:AES256-SHA:DES-CBC3-SHA:AES128-SHA:RC4-SHA:RC4-MD5; ssl_prefer_server_ciphers on; - # uncomment if you have nginx with chunking module compiled - # fixes the issues of having to put postBuffer data for large git - # pushes - #chunkin on; - #error_page 411 = @my_411_error; - #location @my_411_error { - # chunkin_resume; - #} - - # uncomment if you want to serve static files by nginx + ## uncomment root directive if you want to serve static files by nginx + ## requires static_files = false in .ini file #root /path/to/installation/rhodecode/public; location / { @@ -591,18 +605,6 @@ proxy_read_timeout 7200; proxy_buffers 8 32k; -Also, when using root path with nginx you might set the static files to false -in the production.ini file:: - - [app:main] - use = egg:rhodecode - full_stack = true - static_files = false - lang=en - cache_dir = %(here)s/data - -In order to not have the statics served by the application. This improves speed. - Apache virtual host reverse proxy example -----------------------------------------
--- a/production.ini Sun May 12 14:32:38 2013 +0200 +++ b/production.ini Sun May 12 16:58:01 2013 +0200 @@ -115,6 +115,12 @@ show_sha_length = 12 show_revision_number = true +## gist URL alias, used to create nicer urls for gist. This should be an +## url that does rewrites to _admin/gists/<gistid>. +## example: http://gist.rhodecode.org/{gistid}. Empty means use the internal +## RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/<gistid> +gist_alias_url = + ## white list of API enabled controllers. This allows to add list of ## controllers to which access will be enabled by api_key. eg: to enable ## api access to raw_files put `FilesController:raw`, to enable access to patches
--- a/rhodecode/config/deployment.ini_tmpl Sun May 12 14:32:38 2013 +0200 +++ b/rhodecode/config/deployment.ini_tmpl Sun May 12 16:58:01 2013 +0200 @@ -115,6 +115,12 @@ show_sha_length = 12 show_revision_number = true +## gist URL alias, used to create nicer urls for gist. This should be an +## url that does rewrites to _admin/gists/<gistid>. +## example: http://gist.rhodecode.org/{gistid}. Empty means use the internal +## RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/<gistid> +gist_alias_url = + ## white list of API enabled controllers. This allows to add list of ## controllers to which access will be enabled by api_key. eg: to enable ## api access to raw_files put `FilesController:raw`, to enable access to patches
--- a/rhodecode/model/db.py Sun May 12 14:32:38 2013 +0200 +++ b/rhodecode/model/db.py Sun May 12 16:58:01 2013 +0200 @@ -24,12 +24,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os +import time import logging import datetime import traceback import hashlib -import time -from collections import defaultdict +import collections from sqlalchemy import * from sqlalchemy.ext.hybrid import hybrid_property @@ -1120,7 +1120,7 @@ .filter(ChangesetComment.repo == self) if revisions: cmts = cmts.filter(ChangesetComment.revision.in_(revisions)) - grouped = defaultdict(list) + grouped = collections.defaultdict(list) for cmt in cmts.all(): grouped[cmt.revision].append(cmt) return grouped @@ -2155,6 +2155,11 @@ return cls.query().filter(cls.gist_access_id == gist_access_id).scalar() def gist_url(self): + import rhodecode + alias_url = rhodecode.CONFIG.get('gist_alias_url') + if alias_url: + return alias_url.replace('{gistid}', self.gist_access_id) + from pylons import url return url('gist', id=self.gist_access_id, qualified=True)
--- a/rhodecode/templates/admin/gists/show.html Sun May 12 14:32:38 2013 +0200 +++ b/rhodecode/templates/admin/gists/show.html Sun May 12 16:58:01 2013 +0200 @@ -38,14 +38,16 @@ <div class="ui-btn yellow badge">${_('Private gist')}</div> %endif </div> - <span style="color: #AAA"> + <div class="left item ${'' if c.gist.gist_description else 'last'}" style="color: #AAA"> %if c.gist.gist_expires == -1: ${_('Expires')}: ${_('never')} %else: ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))} %endif - </span> - <div class="left item last">${c.gist.gist_description}</div> + </div> + <div class="left item last"> + ${c.gist.gist_description} + </div> <div class="buttons"> ## only owner should see that %if h.HasPermissionAny('hg.admin')() or c.gist.gist_owner == c.rhodecode_user.user_id: @@ -71,7 +73,8 @@ % for file in c.files: <div style="border: 1px solid #EEE;margin-top:20px"> <div id="${h.FID('G', file.path)}" class="stats" style="border-bottom: 1px solid #DDD;padding: 8px 14px;"> - <b>${file.path}</b> + <a href="${c.gist.gist_url()}">ΒΆ</a> + <b style="margin:0px 0px 0px 4px">${file.path}</b> ##<div class="buttons"> ## ${h.link_to(_('Show as raw'),h.url(''),class_="ui-btn")} ##</div>