Mercurial > kallithea
changeset 967:fd3557b09f01 beta
merge
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Fri, 28 Jan 2011 12:19:20 +0100 |
parents | 1707aae3f985 (current diff) 63c91390853c (diff) |
children | aa550e290f26 |
files | |
diffstat | 6 files changed, 88 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/development.ini Wed Jan 26 18:47:12 2011 +0100 +++ b/development.ini Fri Jan 28 12:19:20 2011 +0100 @@ -137,7 +137,8 @@ ######################################################### ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### ######################################################### -sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db +#sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db +sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode #sqlalchemy.db1.echo = False #sqlalchemy.db1.pool_recycle = 3600 sqlalchemy.convert_unicode = true
--- a/rhodecode/lib/db_manage.py Wed Jan 26 18:47:12 2011 +0100 +++ b/rhodecode/lib/db_manage.py Fri Jan 28 12:19:20 2011 +0100 @@ -69,12 +69,17 @@ self.db_exists = True if not override: raise Exception('database already exists') + return 'sqlite' + if self.dburi.startswith('postgresql'): + self.db_exists = True + return 'postgresql' + def create_tables(self, override=False): """Create a auth database """ - self.check_for_db(override) + db_type = self.check_for_db(override) if self.db_exists: log.info("database exist and it's going to be destroyed") if self.tests: @@ -84,7 +89,11 @@ if not destroy: sys.exit() if self.db_exists and destroy: - os.remove(jn(self.root, self.dbname)) + if db_type == 'sqlite': + os.remove(jn(self.root, self.dbname)) + if db_type == 'postgresql': + meta.Base.metadata.drop_all() + checkfirst = not override meta.Base.metadata.create_all(checkfirst=checkfirst) log.info('Created tables for %s', self.dbname)
--- a/rhodecode/lib/helpers.py Wed Jan 26 18:47:12 2011 +0100 +++ b/rhodecode/lib/helpers.py Fri Jan 28 12:19:20 2011 +0100 @@ -5,6 +5,7 @@ """ import random import hashlib +import StringIO from pygments.formatters import HtmlFormatter from pygments import highlight as code_highlight from pylons import url, app_globals as g @@ -217,6 +218,8 @@ files_breadcrumbs = _FilesBreadCrumbs() class CodeHtmlFormatter(HtmlFormatter): + """My code Html Formatter for source codes + """ def wrap(self, source, outfile): return self._wrap_div(self._wrap_pre(self._wrap_code(source))) @@ -224,8 +227,72 @@ def _wrap_code(self, source): for cnt, it in enumerate(source): i, t = it - t = '<div id="#S-%s">%s</div>' % (cnt + 1, t) + t = '<div id="L%s">%s</div>' % (cnt + 1, t) yield i, t + + def _wrap_tablelinenos(self, inner): + dummyoutfile = StringIO.StringIO() + lncount = 0 + for t, line in inner: + if t: + lncount += 1 + dummyoutfile.write(line) + + fl = self.linenostart + mw = len(str(lncount + fl - 1)) + sp = self.linenospecial + st = self.linenostep + la = self.lineanchors + aln = self.anchorlinenos + nocls = self.noclasses + if sp: + lines = [] + + for i in range(fl, fl + lncount): + if i % st == 0: + if i % sp == 0: + if aln: + lines.append('<a href="#%s%d" class="special">%*d</a>' % + (la, i, mw, i)) + else: + lines.append('<span class="special">%*d</span>' % (mw, i)) + else: + if aln: + lines.append('<a href="#%s%d">%*d</a>' % (la, i, mw, i)) + else: + lines.append('%*d' % (mw, i)) + else: + lines.append('') + ls = '\n'.join(lines) + else: + lines = [] + for i in range(fl, fl + lncount): + if i % st == 0: + if aln: + lines.append('<a href="#%s%d">%*d</a>' % (la, i, mw, i)) + else: + lines.append('%*d' % (mw, i)) + else: + lines.append('') + ls = '\n'.join(lines) + + # in case you wonder about the seemingly redundant <div> here: since the + # content in the other cell also is wrapped in a div, some browsers in + # some configurations seem to mess up the formatting... + if nocls: + yield 0, ('<table class="%stable">' % self.cssclass + + '<tr><td><div class="linenodiv" ' + 'style="background-color: #f0f0f0; padding-right: 10px">' + '<pre style="line-height: 125%">' + + ls + '</pre></div></td><td class="code">') + else: + yield 0, ('<table class="%stable">' % self.cssclass + + '<tr><td class="linenos"><div class="linenodiv"><pre>' + + ls + '</pre></div></td><td class="code">') + yield 0, dummyoutfile.getvalue() + yield 0, '</td></tr></table>' + + def pygmentize(filenode, **kwargs): """pygmentize function using pygments
--- a/rhodecode/public/css/pygments.css Wed Jan 26 18:47:12 2011 +0100 +++ b/rhodecode/public/css/pygments.css Fri Jan 28 12:19:20 2011 +0100 @@ -53,6 +53,10 @@ padding: 5px; margin: 0; } +.code-highlight pre div:target { + background-color: #FFFFBE !important; +} + .linenos a { text-decoration: none; } .code { display: block; }
--- a/rhodecode/templates/files/files_source.html Wed Jan 26 18:47:12 2011 +0100 +++ b/rhodecode/templates/files/files_source.html Fri Jan 28 12:19:20 2011 +0100 @@ -37,7 +37,7 @@ </div> <div class="code-body"> % if c.files_list.size < c.cut_off_limit: - ${h.pygmentize(c.files_list,linenos=True,anchorlinenos=True,lineanchors='S',cssclass="code-highlight")} + ${h.pygmentize(c.files_list,linenos=True,anchorlinenos=True,lineanchors='L',cssclass="code-highlight")} %else: ${_('File is to big to display')} ${h.link_to(_('show as raw'), h.url('files_raw_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path))}
--- a/test.ini Wed Jan 26 18:47:12 2011 +0100 +++ b/test.ini Fri Jan 28 12:19:20 2011 +0100 @@ -137,7 +137,8 @@ ######################################################### ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ### ######################################################### -sqlalchemy.db1.url = sqlite:///%(here)s/test.db +#sqlalchemy.db1.url = sqlite:///%(here)s/test.db +sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode_tests #sqlalchemy.db1.echo = False #sqlalchemy.db1.pool_recycle = 3600 sqlalchemy.convert_unicode = true