@@ -23,23 +23,25 @@
# 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 traceback
import calendar
import logging
from time import mktime
from datetime import datetime, timedelta, date
from datetime import timedelta, date
from itertools import product
from vcs.exceptions import ChangesetError
from vcs.exceptions import ChangesetError, EmptyRepositoryError, \
NodeDoesNotExistError
from pylons import tmpl_context as c, request, url
from pylons.i18n.translation import _
from rhodecode.model.db import Statistics, Repository
from rhodecode.model.repo import RepoModel
from rhodecode.model.db import Statistics
from rhodecode.lib import ALL_READMES, ALL_EXTS
from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator
from rhodecode.lib.base import BaseRepoController, render
from rhodecode.lib.utils import EmptyChangeset
from rhodecode.lib.markup_renderer import MarkupRenderer
from rhodecode.lib.celerylib import run_task
from rhodecode.lib.celerylib.tasks import get_commits_stats, \
LANGUAGES_EXTENSIONS_MAP
@@ -48,6 +50,9 @@ from rhodecode.lib.compat import json, O
log = logging.getLogger(__name__)
README_FILES = [''.join([x[0][0], x[1][0]]) for x in
sorted(list(product(ALL_READMES, ALL_EXTS)),
key=lambda y:y[0][1] + y[1][1])]
class SummaryController(BaseRepoController):
@@ -161,8 +166,33 @@ class SummaryController(BaseRepoControll
if c.enable_downloads:
c.download_options = self._get_download_links(c.rhodecode_repo)
c.readme_data,c.readme_file = self.__get_readme_data()
return render('summary/summary.html')
def __get_readme_data(self):
readme_data = None
readme_file = None
try:
cs = c.rhodecode_repo.get_changeset('tip')
renderer = MarkupRenderer()
for f in README_FILES:
readme = cs.get_node(f)
readme_file = f
readme_data = renderer.render(readme.content, f)
break
except NodeDoesNotExistError:
continue
except ChangesetError:
pass
except EmptyRepositoryError:
except Exception:
log.error(traceback.format_exc())
return readme_data, readme_file
def _get_download_links(self, repo):
download_l = []
@@ -181,3 +211,4 @@ class SummaryController(BaseRepoControll
download_l.append(tags_group)
return download_l
@@ -66,6 +66,34 @@ ADDITIONAL_MAPPINGS = {'xaml': 'XAML'}
LANGUAGES_EXTENSIONS_MAP.update(ADDITIONAL_MAPPINGS)
# list of readme files to search in file tree and display in summary
# attached weights defines the search order lower is first
ALL_READMES = [
('readme', 0), ('README', 0), ('Readme', 0),
('doc/readme', 1), ('doc/README', 1), ('doc/Readme', 1),
('Docs/readme', 2), ('Docs/README', 2), ('Docs/Readme', 2),
('DOCS/readme', 2), ('DOCS/README', 2), ('DOCS/Readme', 2),
('docs/readme', 2), ('docs/README', 2), ('docs/Readme', 2),
]
# extension together with weights to search lower is first
RST_EXTS = [
('', 0), ('.rst', 1),('.rest', 1),
('.RST', 2) ,('.REST', 2),
('.txt', 3), ('.TXT', 3)
MARKDOWN_EXTS = [
('.md', 1), ('.MD', 1),
('.mkdn', 2), ('.MKDN', 2),
('.mdown', 3), ('.MDOWN', 3),
('.markdown', 4), ('.MARKDOWN', 4)
PLAIN_EXTS = [('.text', 2),('.TEXT', 2)]
ALL_EXTS = MARKDOWN_EXTS + RST_EXTS + PLAIN_EXTS
def str2bool(_str):
"""
@@ -3011,4 +3011,96 @@ div#legend_container table td,div#legend
border: 0px solid #545454;
color: #AAAAAA;
padding-left: 3px;
}
\ No newline at end of file
/*README STYLE*/
div.readme {
padding:0px;
div.readme h2 {
font-weight: normal;
div.readme .readme_box {
background-color: #fafafa;
clear:both;
overflow:hidden;
margin:0;
padding:0 20px 10px;
div.readme .readme_box h1, div.readme .readme_box h2, div.readme .readme_box h3, div.readme .readme_box h4, div.readme .readme_box h5, div.readme .readme_box h6 {
border-bottom: 0 !important;
margin: 0 !important;
padding: 0 !important;
line-height: 1.5em !important;
div.readme .readme_box h1:first-child {
padding-top: .25em !important;
div.readme .readme_box h2, div.readme .readme_box h3 {
margin: 1em 0 !important;
div.readme .readme_box h2 {
margin-top: 1.5em !important;
border-top: 4px solid #e0e0e0 !important;
padding-top: .5em !important;
div.readme .readme_box p {
color: black !important;
div.readme .readme_box ul {
list-style: disc !important;
margin: 1em 0 1em 2em !important;
div.readme .readme_box ol {
list-style: decimal;
div.readme .readme_box pre, code {
font: 12px "Bitstream Vera Sans Mono","Courier",monospace;
div.readme .readme_box code {
font-size: 12px !important;
background-color: ghostWhite !important;
color: #444 !important;
padding: 0 .2em !important;
border: 1px solid #dedede !important;
div.readme .readme_box pre code {
background-color: #eee !important;
border: none !important;
div.readme .readme_box pre {
margin: 1em 0;
font-size: 12px;
background-color: #eee;
border: 1px solid #ddd;
padding: 5px;
color: #444;
overflow: auto;
-webkit-box-shadow: rgba(0,0,0,0.07) 0 1px 2px inset;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
@@ -64,10 +64,7 @@
##FORK
%if c.dbrepo.fork:
<div style="margin-top:5px;clear:both"">
<a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}">
<img class="icon" alt="${_('public')}"
title="${_('Fork of')} ${c.dbrepo.fork.repo_name}"
src="${h.url('/images/icons/arrow_divide.png')}"/>
<a href="${h.url('summary_home',repo_name=c.dbrepo.fork.repo_name)}"><img class="icon" alt="${_('public')}" title="${_('Fork of')} ${c.dbrepo.fork.repo_name}" src="${h.url('/images/icons/arrow_divide.png')}"/>
${_('Fork of')} ${c.dbrepo.fork.repo_name}
</a>
</div>
@@ -75,10 +72,7 @@
##REMOTE
%if c.dbrepo.clone_uri:
<div style="margin-top:5px;clear:both">
<a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}">
<img class="icon" alt="${_('remote clone')}"
title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}"
src="${h.url('/images/icons/connect.png')}"/>
<a href="${h.url(str(h.hide_credentials(c.dbrepo.clone_uri)))}"><img class="icon" alt="${_('remote clone')}" title="${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}" src="${h.url('/images/icons/connect.png')}"/>
${_('Clone from')} ${h.hide_credentials(c.dbrepo.clone_uri)}
@@ -86,7 +80,6 @@
<div class="field">
<div class="label">
<label>${_('Description')}:</label>
@@ -94,7 +87,6 @@
<div class="input-short desc">${h.urlify_text(c.dbrepo.description)}</div>
<label>${_('Contact')}:</label>
@@ -119,7 +111,6 @@
<span class="tooltip" title="${c.rhodecode_repo.last_change}">
${h.age(c.rhodecode_repo.last_change)}</span><br/>
${_('by')} ${h.get_changeset_safe(c.rhodecode_repo,'tip').author}
@@ -187,6 +178,62 @@
<div class="box box-right" style="min-height:455px">
<!-- box / title -->
<div class="title">
<h5>${_('Commit activity by day / author')}</h5>
<div class="graph">
<div style="padding:0 10px 10px 15px;font-size: 1.2em;">
%if c.no_data:
${c.no_data_msg}
%if h.HasPermissionAll('hg.admin')('enable stats on from summary'):
${h.link_to(_('enable'),h.url('edit_repo',repo_name=c.repo_name),class_="ui-button-small")}
%endif
%else:
${_('Loaded in')} ${c.stats_percentage} %
<div id="commit_history" style="width:450px;height:300px;float:left"></div>
<div style="clear: both;height: 10px"></div>
<div id="overview" style="width:450px;height:100px;float:left"></div>
<div id="legend_data" style="clear:both;margin-top:10px;">
<div id="legend_container"></div>
<div id="legend_choices">
<table id="legend_choices_tables" class="noborder" style="font-size:smaller;color:#545454"></table>
<div class="box">
<div class="breadcrumbs">${h.link_to(_('Shortlog'),h.url('shortlog_home',repo_name=c.repo_name))}</div>
<div class="table">
<div id="shortlog_data">
<%include file='../shortlog/shortlog_data.html'/>
%if c.readme_data:
<div class="box" style="background-color: #FAFAFA">
<div class="breadcrumbs"><a href="${h.url('files_home',repo_name=c.repo_name,revision='tip',f_path=c.readme_file)}">${c.readme_file}</a></div>
<div class="readme">
<div class="readme_box">
${c.readme_data|n}
<script type="text/javascript">
YUE.onDOMReady(function(e){
id = 'clone_url';
@@ -304,36 +351,6 @@
});
</script>
<table id="legend_choices_tables" style="font-size:smaller;color:#545454"></table>
/**
* Plots summary graph
@@ -658,43 +675,4 @@
SummaryPlot(${c.ts_min},${c.ts_max},${c.commit_data|n},${c.overview_data|n});
##%if c.repo_changesets:
## ${h.link_to(_('show more'),h.url('changelog_home',repo_name=c.repo_name))}
##%endif
<div class="breadcrumbs">${h.link_to(_('Tags'),h.url('tags_home',repo_name=c.repo_name))}</div>
<%include file='../tags/tags_data.html'/>
%if c.repo_changesets:
${h.link_to(_('show more'),h.url('tags_home',repo_name=c.repo_name))}
<div class="breadcrumbs">${h.link_to(_('Branches'),h.url('branches_home',repo_name=c.repo_name))}</div>
<%include file='../branches/branches_data.html'/>
${h.link_to(_('show more'),h.url('branches_home',repo_name=c.repo_name))}
</%def>
@@ -24,7 +24,9 @@ requirements = [
"python-dateutil>=1.5.0,<2.0.0",
"dulwich>=0.8.0,<0.9.0",
"vcs>=0.2.3.dev",
"webob==1.0.8"
"webob==1.0.8",
"markdown==2.0.3",
"docutils==0.8.1",
dependency_links = [
Status change: