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
 
@@ -112,12 +112,18 @@ rss_items_per_page = 10
 
rss_include_diff = false
 

	
 
## options for showing and identifying changesets
 
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
 
## add `ChangesetController:changeset_patch`. This list should be "," separated
 
## Syntax is <ControllerClass>:<function>. Check debug logs for generated names
 
api_access_controllers_whitelist =
docs/setup.rst
Show inline comments
 
@@ -531,12 +531,34 @@ Sample config for nginx using proxy::
 
        server 127.0.0.1:5000;
 
        # add more instances for load balancing
 
        #server 127.0.0.1:5001;
 
        #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;
 
       access_log      /var/log/nginx/rhodecode.access.log;
 
       error_log       /var/log/nginx/rhodecode.error.log;
 

	
 
@@ -547,22 +569,14 @@ Sample config for nginx using proxy::
 
       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;
 

	
 
       # 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 / {
 
            try_files $uri @rhode;
 
       }
 

	
 
@@ -588,24 +602,12 @@ pushes or large pushes::
 
    proxy_buffering             off;
 
    proxy_connect_timeout       7200;
 
    proxy_send_timeout          7200;
 
    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
 
-----------------------------------------
 

	
 
Here is a sample configuration file for apache using proxy::
 

	
production.ini
Show inline comments
 
@@ -112,12 +112,18 @@ rss_items_per_page = 10
 
rss_include_diff = false
 

	
 
## options for showing and identifying changesets
 
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
 
## add `ChangesetController:changeset_patch`. This list should be "," separated
 
## Syntax is <ControllerClass>:<function>. Check debug logs for generated names
 
api_access_controllers_whitelist =
rhodecode/config/deployment.ini_tmpl
Show inline comments
 
@@ -112,12 +112,18 @@ rss_items_per_page = 10
 
rss_include_diff = false
 

	
 
## options for showing and identifying changesets
 
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
 
## add `ChangesetController:changeset_patch`. This list should be "," separated
 
## Syntax is <ControllerClass>:<function>. Check debug logs for generated names
 
api_access_controllers_whitelist =
rhodecode/model/db.py
Show inline comments
 
@@ -21,18 +21,18 @@
 
# GNU General Public License for more details.
 
#
 
# You should have received a copy of the GNU General Public License
 
# 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
 
from sqlalchemy.orm import relationship, joinedload, class_mapper, validates
 
from sqlalchemy.exc import DatabaseError
 
from beaker.cache import cache_region, region_invalidate
 
@@ -1117,13 +1117,13 @@ class Repository(Base, BaseModel):
 
        :param revisions: filter query by revisions only
 
        """
 
        cmts = ChangesetComment.query()\
 
            .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
 

	
 
    def statuses(self, revisions=None):
 
        """
 
@@ -2152,12 +2152,17 @@ class Gist(Base, BaseModel):
 

	
 
    @classmethod
 
    def get_by_access_id(cls, gist_access_id):
 
        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)
 

	
 
    @classmethod
 
    def base_path(cls):
 
        """
rhodecode/templates/admin/gists/show.html
Show inline comments
 
@@ -35,20 +35,22 @@
 
                          %if c.gist.gist_type == 'public':
 
                            <div class="ui-btn green badge">${_('Public gist')}</div>
 
                          %else:
 
                            <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:
 
                            ##${h.link_to(_('Edit'),h.url(''),class_="ui-btn")}
 
                            ${h.form(url('gist', id=c.gist.gist_id),method='delete')}
 
                                ${h.submit('remove_gist', _('Delete'),class_="ui-btn red",onclick="return confirm('"+_('Confirm to delete this gist')+"');")}
 
@@ -68,13 +70,14 @@
 
            </div>
 

	
 
               ## iterate over the files
 
               % 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>
 
                </div>
 
                <div class="code-body">
 
                    ${h.pygmentize(file,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")}
0 comments (0 inline, 0 general)