Show More
@@ -132,7 +132,7 b' class ChangelogController(BaseRepoContro' | |||
|
132 | 132 | c.total_cs = len(collection) |
|
133 | 133 | |
|
134 | 134 | c.pagination = RepoPage(collection, page=p, item_count=c.total_cs, |
|
135 | items_per_page=c.size, branch=branch_name) | |
|
135 | items_per_page=c.size, branch=branch_name,) | |
|
136 | 136 | collection = list(c.pagination) |
|
137 | 137 | page_revisions = [x.raw_id for x in c.pagination] |
|
138 | 138 | c.comments = c.rhodecode_db_repo.get_comments(page_revisions) |
@@ -900,13 +900,15 b' class Page(_Page):' | |||
|
900 | 900 | if self.page != self.last_page and rightmost_page < self.last_page: |
|
901 | 901 | nav_items.append(self._pagerlink(self.last_page, self.last_page)) |
|
902 | 902 | |
|
903 | ## prerender links | |
|
904 | nav_items.append(literal('<link rel="prerender" href="/rhodecode/changelog/1?page=%s">' % str(int(self.page)+1))) | |
|
903 | 905 | return self.separator.join(nav_items) |
|
904 | 906 | |
|
905 | 907 | def pager(self, format='~2~', page_param='page', partial_param='partial', |
|
906 | 908 | show_if_single_page=False, separator=' ', onclick=None, |
|
907 | 909 | symbol_first='<<', symbol_last='>>', |
|
908 | 910 | symbol_previous='<', symbol_next='>', |
|
909 | link_attr={'class': 'pager_link'}, | |
|
911 | link_attr={'class': 'pager_link', 'rel': 'prerender'}, | |
|
910 | 912 | curpage_attr={'class': 'pager_curpage'}, |
|
911 | 913 | dotdot_attr={'class': 'pager_dotdot'}, **kwargs): |
|
912 | 914 |
@@ -24,32 +24,17 b'' | |||
|
24 | 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | 25 | import os |
|
26 | 26 | import sys |
|
27 | import traceback | |
|
28 | 27 | import logging |
|
29 | 28 | from os.path import dirname as dn, join as jn |
|
30 | 29 | |
|
31 | 30 | #to get the rhodecode import |
|
32 | 31 | sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) |
|
33 | 32 | |
|
34 | from string import strip | |
|
35 | from shutil import rmtree | |
|
36 | ||
|
37 | 33 | from whoosh.analysis import RegexTokenizer, LowercaseFilter, StopFilter |
|
38 | 34 | from whoosh.fields import TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME |
|
39 | from whoosh.index import create_in, open_dir | |
|
40 | 35 | from whoosh.formats import Characters |
|
41 | from whoosh.highlight import highlight, HtmlFormatter, ContextFragmenter | |
|
42 | ||
|
43 | from webhelpers.html.builder import escape, literal | |
|
44 | from sqlalchemy import engine_from_config | |
|
45 | ||
|
46 | from rhodecode.model import init_model | |
|
47 | from rhodecode.model.scm import ScmModel | |
|
48 | from rhodecode.model.repo import RepoModel | |
|
49 | from rhodecode.config.environment import load_environment | |
|
36 | from whoosh.highlight import highlight as whoosh_highlight, HtmlFormatter, ContextFragmenter | |
|
50 | 37 | from rhodecode.lib.utils2 import LazyProperty |
|
51 | from rhodecode.lib.utils import BasePasterCommand, Command, add_cache,\ | |
|
52 | load_rcextensions | |
|
53 | 38 | |
|
54 | 39 | log = logging.getLogger(__name__) |
|
55 | 40 | |
@@ -99,74 +84,6 b' JOURNAL_SCHEMA = Schema(' | |||
|
99 | 84 | ) |
|
100 | 85 | |
|
101 | 86 | |
|
102 | class MakeIndex(BasePasterCommand): | |
|
103 | ||
|
104 | max_args = 1 | |
|
105 | min_args = 1 | |
|
106 | ||
|
107 | usage = "CONFIG_FILE" | |
|
108 | summary = "Creates or update full text search index" | |
|
109 | group_name = "RhodeCode" | |
|
110 | takes_config_file = -1 | |
|
111 | parser = Command.standard_parser(verbose=True) | |
|
112 | ||
|
113 | def command(self): | |
|
114 | logging.config.fileConfig(self.path_to_ini_file) | |
|
115 | from pylons import config | |
|
116 | add_cache(config) | |
|
117 | engine = engine_from_config(config, 'sqlalchemy.db1.') | |
|
118 | init_model(engine) | |
|
119 | index_location = config['index_dir'] | |
|
120 | repo_location = self.options.repo_location \ | |
|
121 | if self.options.repo_location else RepoModel().repos_path | |
|
122 | repo_list = map(strip, self.options.repo_list.split(',')) \ | |
|
123 | if self.options.repo_list else None | |
|
124 | repo_update_list = map(strip, self.options.repo_update_list.split(',')) \ | |
|
125 | if self.options.repo_update_list else None | |
|
126 | load_rcextensions(config['here']) | |
|
127 | #====================================================================== | |
|
128 | # WHOOSH DAEMON | |
|
129 | #====================================================================== | |
|
130 | from rhodecode.lib.pidlock import LockHeld, DaemonLock | |
|
131 | from rhodecode.lib.indexers.daemon import WhooshIndexingDaemon | |
|
132 | try: | |
|
133 | l = DaemonLock(file_=jn(dn(dn(index_location)), 'make_index.lock')) | |
|
134 | WhooshIndexingDaemon(index_location=index_location, | |
|
135 | repo_location=repo_location, | |
|
136 | repo_list=repo_list, | |
|
137 | repo_update_list=repo_update_list)\ | |
|
138 | .run(full_index=self.options.full_index) | |
|
139 | l.release() | |
|
140 | except LockHeld: | |
|
141 | sys.exit(1) | |
|
142 | ||
|
143 | def update_parser(self): | |
|
144 | self.parser.add_option('--repo-location', | |
|
145 | action='store', | |
|
146 | dest='repo_location', | |
|
147 | help="Specifies repositories location to index OPTIONAL", | |
|
148 | ) | |
|
149 | self.parser.add_option('--index-only', | |
|
150 | action='store', | |
|
151 | dest='repo_list', | |
|
152 | help="Specifies a comma separated list of repositores " | |
|
153 | "to build index on. If not given all repositories " | |
|
154 | "are scanned for indexing. OPTIONAL", | |
|
155 | ) | |
|
156 | self.parser.add_option('--update-only', | |
|
157 | action='store', | |
|
158 | dest='repo_update_list', | |
|
159 | help="Specifies a comma separated list of repositores " | |
|
160 | "to re-build index on. OPTIONAL", | |
|
161 | ) | |
|
162 | self.parser.add_option('-f', | |
|
163 | action='store_true', | |
|
164 | dest='full_index', | |
|
165 | help="Specifies that index should be made full i.e" | |
|
166 | " destroy old and build from scratch", | |
|
167 | default=False) | |
|
168 | ||
|
169 | ||
|
170 | 87 | class WhooshResultWrapper(object): |
|
171 | 88 | def __init__(self, search_type, searcher, matcher, highlight_items, |
|
172 | 89 | repo_location): |
@@ -249,9 +166,6 b' class WhooshResultWrapper(object):' | |||
|
249 | 166 | Smart function that implements chunking the content |
|
250 | 167 | but not overlap chunks so it doesn't highlight the same |
|
251 | 168 | close occurrences twice. |
|
252 | ||
|
253 | :param matcher: | |
|
254 | :param size: | |
|
255 | 169 | """ |
|
256 | 170 | memory = [(0, 0)] |
|
257 | 171 | if self.matcher.supports('positions'): |
@@ -269,7 +183,7 b' class WhooshResultWrapper(object):' | |||
|
269 | 183 | def highlight(self, content, top=5): |
|
270 | 184 | if self.search_type not in ['content', 'message']: |
|
271 | 185 | return '' |
|
272 | hl = highlight( | |
|
186 | hl = whoosh_highlight( | |
|
273 | 187 | text=content, |
|
274 | 188 | terms=self.highlight_items, |
|
275 | 189 | analyzer=ANALYZER, |
@@ -29,15 +29,14 b' import os' | |||
|
29 | 29 | import sys |
|
30 | 30 | import logging |
|
31 | 31 | |
|
32 | from os.path import dirname as dn, join as jn | |
|
33 | 32 | from rhodecode.model.meta import Session |
|
34 | #to get the rhodecode import | |
|
33 | from rhodecode.lib.utils import BasePasterCommand | |
|
34 | from rhodecode.model.db import CacheInvalidation | |
|
35 | ||
|
36 | # fix rhodecode import | |
|
37 | from os.path import dirname as dn | |
|
35 | 38 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
36 | 39 | sys.path.append(rc_path) |
|
37 | from rhodecode.lib.utils import BasePasterCommand | |
|
38 | ||
|
39 | from rhodecode.model.db import CacheInvalidation | |
|
40 | ||
|
41 | 40 | |
|
42 | 41 | log = logging.getLogger(__name__) |
|
43 | 42 |
@@ -32,15 +32,14 b' import shutil' | |||
|
32 | 32 | import logging |
|
33 | 33 | import datetime |
|
34 | 34 | |
|
35 | from os.path import dirname as dn, join as jn | |
|
36 | #to get the rhodecode import | |
|
37 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
|
38 | sys.path.append(rc_path) | |
|
39 | 35 | from rhodecode.lib.utils import BasePasterCommand, ask_ok, REMOVED_REPO_PAT |
|
40 | ||
|
41 | 36 | from rhodecode.lib.utils2 import safe_str |
|
42 | 37 | from rhodecode.model.db import RhodeCodeUi |
|
43 | 38 | |
|
39 | # fix rhodecode import | |
|
40 | from os.path import dirname as dn | |
|
41 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
|
42 | sys.path.append(rc_path) | |
|
44 | 43 | |
|
45 | 44 | log = logging.getLogger(__name__) |
|
46 | 45 |
@@ -29,12 +29,12 b' import os' | |||
|
29 | 29 | import sys |
|
30 | 30 | import logging |
|
31 | 31 | |
|
32 | from os.path import dirname as dn, join as jn | |
|
33 | #to get the rhodecode import | |
|
32 | from rhodecode.lib.utils import BasePasterCommand | |
|
33 | ||
|
34 | # fix rhodecode import | |
|
35 | from os.path import dirname as dn | |
|
34 | 36 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
35 | 37 | sys.path.append(rc_path) |
|
36 | from rhodecode.lib.utils import BasePasterCommand | |
|
37 | ||
|
38 | 38 | |
|
39 | 39 | log = logging.getLogger(__name__) |
|
40 | 40 |
@@ -26,17 +26,16 b' from __future__ import with_statement' | |||
|
26 | 26 | |
|
27 | 27 | import os |
|
28 | 28 | import sys |
|
29 | import logging | |
|
29 | 30 | import pkg_resources |
|
30 | import traceback | |
|
31 | import logging | |
|
31 | ||
|
32 | from rhodecode.lib.utils import BasePasterCommand, ask_ok | |
|
32 | 33 | |
|
33 | from os.path import dirname as dn, join as jn | |
|
34 | #to get the rhodecode import | |
|
34 | # fix rhodecode import | |
|
35 | from os.path import dirname as dn | |
|
35 | 36 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
36 | 37 | sys.path.append(rc_path) |
|
37 | 38 | |
|
38 | from rhodecode.lib.utils import BasePasterCommand, ask_ok | |
|
39 | ||
|
40 | 39 | log = logging.getLogger(__name__) |
|
41 | 40 | |
|
42 | 41 | |
@@ -65,9 +64,9 b' class Command(BasePasterCommand):' | |||
|
65 | 64 | |
|
66 | 65 | here = config['here'] |
|
67 | 66 | tmpl = pkg_resources.resource_string( |
|
68 | 'rhodecode', jn('config', 'rcextensions', '__init__.py') | |
|
67 | 'rhodecode', os.path.join('config', 'rcextensions', '__init__.py') | |
|
69 | 68 | ) |
|
70 | ext_file = jn(here, 'rcextensions', '__init__.py') | |
|
69 | ext_file = os.path.join(here, 'rcextensions', '__init__.py') | |
|
71 | 70 | if os.path.exists(ext_file): |
|
72 | 71 | msg = ('Extension file already exists, do you want ' |
|
73 | 72 | 'to overwrite it ? [y/n]') |
@@ -29,17 +29,13 b' import os' | |||
|
29 | 29 | import sys |
|
30 | 30 | import logging |
|
31 | 31 | |
|
32 | from os.path import dirname as dn, join as jn | |
|
33 | 32 | from rhodecode.model.scm import ScmModel |
|
34 | #to get the rhodecode import | |
|
33 | from rhodecode.lib.utils import BasePasterCommand, repo2db_mapper | |
|
34 | ||
|
35 | # fix rhodecode import | |
|
36 | from os.path import dirname as dn | |
|
35 | 37 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
36 | 38 | sys.path.append(rc_path) |
|
37 | from rhodecode.lib.utils import BasePasterCommand, repo2db_mapper | |
|
38 | ||
|
39 | from rhodecode.model.db import Repository | |
|
40 | from rhodecode.model.repo import RepoModel | |
|
41 | from rhodecode.model.meta import Session | |
|
42 | ||
|
43 | 39 | |
|
44 | 40 | log = logging.getLogger(__name__) |
|
45 | 41 |
@@ -4,8 +4,8 b' from paste.script.appinstall import Abst' | |||
|
4 | 4 | from paste.script.command import BadCommand |
|
5 | 5 | from paste.deploy import appconfig |
|
6 | 6 | |
|
7 | from os.path import dirname as dn, join as jn | |
|
8 | #to get the rhodecode import | |
|
7 | # fix rhodecode import | |
|
8 | from os.path import dirname as dn | |
|
9 | 9 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
10 | 10 | sys.path.append(rc_path) |
|
11 | 11 |
@@ -29,16 +29,16 b' import sys' | |||
|
29 | 29 | import logging |
|
30 | 30 | import string |
|
31 | 31 | |
|
32 | from os.path import dirname as dn, join as jn | |
|
33 | #to get the rhodecode import | |
|
34 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
|
35 | sys.path.append(rc_path) | |
|
36 | 32 | from rhodecode.lib.utils import BasePasterCommand |
|
37 | ||
|
38 | 33 | from rhodecode.model.db import Repository |
|
39 | 34 | from rhodecode.model.repo import RepoModel |
|
40 | 35 | from rhodecode.model.meta import Session |
|
41 | 36 | |
|
37 | # fix rhodecode import | |
|
38 | from os.path import dirname as dn | |
|
39 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
|
40 | sys.path.append(rc_path) | |
|
41 | ||
|
42 | 42 | log = logging.getLogger(__name__) |
|
43 | 43 | |
|
44 | 44 |
@@ -167,7 +167,7 b' setup(' | |||
|
167 | 167 | repo-scan=rhodecode.lib.paster_commands.repo_scan:Command |
|
168 | 168 | cache-keys=rhodecode.lib.paster_commands.cache_keys:Command |
|
169 | 169 | ishell=rhodecode.lib.paster_commands.ishell:Command |
|
170 |
make-index=rhodecode.lib. |
|
|
170 | make-index=rhodecode.lib.paster_commands.make_index:Command | |
|
171 | 171 | upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb |
|
172 | 172 | celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand |
|
173 | 173 | """, |
General Comments 0
You need to be logged in to leave comments.
Login now