# HG changeset patch # User Marcin Kuzminski # Date 1368370681 -7200 # Node ID 7a4df261a375c7a0920d5f1042d93691dc5082a6 # Parent b4fc29a051ae50d1925bef9670359270972ded30 added alias configuration option for gists. Used to generate nice looking urls for gists diff -r b4fc29a051ae -r 7a4df261a375 development.ini --- 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/. +## example: http://gist.rhodecode.org/{gistid}. Empty means use the internal +## RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/ +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 diff -r b4fc29a051ae -r 7a4df261a375 docs/setup.rst --- 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 ----------------------------------------- diff -r b4fc29a051ae -r 7a4df261a375 production.ini --- 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/. +## example: http://gist.rhodecode.org/{gistid}. Empty means use the internal +## RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/ +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 diff -r b4fc29a051ae -r 7a4df261a375 rhodecode/config/deployment.ini_tmpl --- 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/. +## example: http://gist.rhodecode.org/{gistid}. Empty means use the internal +## RhodeCode url, ie. http[s]://rhodecode.server/_admin/gists/ +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 diff -r b4fc29a051ae -r 7a4df261a375 rhodecode/model/db.py --- 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 . 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) diff -r b4fc29a051ae -r 7a4df261a375 rhodecode/templates/admin/gists/show.html --- 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 @@
${_('Private gist')}
%endif - +
%if c.gist.gist_expires == -1: ${_('Expires')}: ${_('never')} %else: ${_('Expires')}: ${h.age(h.time_to_datetime(c.gist.gist_expires))} %endif - -
${c.gist.gist_description}
+
+
+ ${c.gist.gist_description} +
## 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:
- ${file.path} + ΒΆ + ${file.path} ##
## ${h.link_to(_('Show as raw'),h.url(''),class_="ui-btn")} ##