Changeset - 7a4df261a375
[Not reviewed]
beta
0 6 0
Marcin Kuzminski - 13 years ago 2013-05-12 16:58:01
marcin@python-works.com
added alias configuration option for gists.
Used to generate nice looking urls for gists
6 files changed with 57 insertions and 29 deletions:
0 comments (0 inline, 0 general)
development.ini
Show inline comments
 
@@ -115,6 +115,12 @@ rss_include_diff = false
 
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
docs/setup.rst
Show inline comments
 
@@ -534,6 +534,28 @@ Sample config for nginx using proxy::
 
        #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 @@ Sample config for nginx using proxy::
 
       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 @@ pushes or large pushes::
 
    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
 
-----------------------------------------
production.ini
Show inline comments
 
@@ -115,6 +115,12 @@ rss_include_diff = false
 
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
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -115,6 +115,12 @@ rss_include_diff = false
 
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
rhodecode/model/db.py
Show inline comments
 
@@ -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 @@ class Repository(Base, BaseModel):
 
            .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 @@ class Gist(Base, BaseModel):
 
        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)
 

	
rhodecode/templates/admin/gists/show.html
Show inline comments
 
@@ -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>
0 comments (0 inline, 0 general)