Show More
@@ -132,7 +132,7 b' class ChangelogController(BaseRepoContro' | |||||
132 | c.total_cs = len(collection) |
|
132 | c.total_cs = len(collection) | |
133 |
|
133 | |||
134 | c.pagination = RepoPage(collection, page=p, item_count=c.total_cs, |
|
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 | collection = list(c.pagination) |
|
136 | collection = list(c.pagination) | |
137 | page_revisions = [x.raw_id for x in c.pagination] |
|
137 | page_revisions = [x.raw_id for x in c.pagination] | |
138 | c.comments = c.rhodecode_db_repo.get_comments(page_revisions) |
|
138 | c.comments = c.rhodecode_db_repo.get_comments(page_revisions) |
@@ -900,13 +900,15 b' class Page(_Page):' | |||||
900 | if self.page != self.last_page and rightmost_page < self.last_page: |
|
900 | if self.page != self.last_page and rightmost_page < self.last_page: | |
901 | nav_items.append(self._pagerlink(self.last_page, self.last_page)) |
|
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 | return self.separator.join(nav_items) |
|
905 | return self.separator.join(nav_items) | |
904 |
|
906 | |||
905 | def pager(self, format='~2~', page_param='page', partial_param='partial', |
|
907 | def pager(self, format='~2~', page_param='page', partial_param='partial', | |
906 | show_if_single_page=False, separator=' ', onclick=None, |
|
908 | show_if_single_page=False, separator=' ', onclick=None, | |
907 | symbol_first='<<', symbol_last='>>', |
|
909 | symbol_first='<<', symbol_last='>>', | |
908 | symbol_previous='<', symbol_next='>', |
|
910 | symbol_previous='<', symbol_next='>', | |
909 | link_attr={'class': 'pager_link'}, |
|
911 | link_attr={'class': 'pager_link', 'rel': 'prerender'}, | |
910 | curpage_attr={'class': 'pager_curpage'}, |
|
912 | curpage_attr={'class': 'pager_curpage'}, | |
911 | dotdot_attr={'class': 'pager_dotdot'}, **kwargs): |
|
913 | dotdot_attr={'class': 'pager_dotdot'}, **kwargs): | |
912 |
|
914 |
@@ -24,32 +24,17 b'' | |||||
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
25 | import os |
|
25 | import os | |
26 | import sys |
|
26 | import sys | |
27 | import traceback |
|
|||
28 | import logging |
|
27 | import logging | |
29 | from os.path import dirname as dn, join as jn |
|
28 | from os.path import dirname as dn, join as jn | |
30 |
|
29 | |||
31 | #to get the rhodecode import |
|
30 | #to get the rhodecode import | |
32 | sys.path.append(dn(dn(dn(os.path.realpath(__file__))))) |
|
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 | from whoosh.analysis import RegexTokenizer, LowercaseFilter, StopFilter |
|
33 | from whoosh.analysis import RegexTokenizer, LowercaseFilter, StopFilter | |
38 | from whoosh.fields import TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME |
|
34 | from whoosh.fields import TEXT, ID, STORED, NUMERIC, BOOLEAN, Schema, FieldType, DATETIME | |
39 | from whoosh.index import create_in, open_dir |
|
|||
40 | from whoosh.formats import Characters |
|
35 | from whoosh.formats import Characters | |
41 | from whoosh.highlight import highlight, HtmlFormatter, ContextFragmenter |
|
36 | from whoosh.highlight import highlight as whoosh_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 |
|
|||
50 | from rhodecode.lib.utils2 import LazyProperty |
|
37 | from rhodecode.lib.utils2 import LazyProperty | |
51 | from rhodecode.lib.utils import BasePasterCommand, Command, add_cache,\ |
|
|||
52 | load_rcextensions |
|
|||
53 |
|
38 | |||
54 | log = logging.getLogger(__name__) |
|
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 | class WhooshResultWrapper(object): |
|
87 | class WhooshResultWrapper(object): | |
171 | def __init__(self, search_type, searcher, matcher, highlight_items, |
|
88 | def __init__(self, search_type, searcher, matcher, highlight_items, | |
172 | repo_location): |
|
89 | repo_location): | |
@@ -249,9 +166,6 b' class WhooshResultWrapper(object):' | |||||
249 | Smart function that implements chunking the content |
|
166 | Smart function that implements chunking the content | |
250 | but not overlap chunks so it doesn't highlight the same |
|
167 | but not overlap chunks so it doesn't highlight the same | |
251 | close occurrences twice. |
|
168 | close occurrences twice. | |
252 |
|
||||
253 | :param matcher: |
|
|||
254 | :param size: |
|
|||
255 | """ |
|
169 | """ | |
256 | memory = [(0, 0)] |
|
170 | memory = [(0, 0)] | |
257 | if self.matcher.supports('positions'): |
|
171 | if self.matcher.supports('positions'): | |
@@ -269,7 +183,7 b' class WhooshResultWrapper(object):' | |||||
269 | def highlight(self, content, top=5): |
|
183 | def highlight(self, content, top=5): | |
270 | if self.search_type not in ['content', 'message']: |
|
184 | if self.search_type not in ['content', 'message']: | |
271 | return '' |
|
185 | return '' | |
272 | hl = highlight( |
|
186 | hl = whoosh_highlight( | |
273 | text=content, |
|
187 | text=content, | |
274 | terms=self.highlight_items, |
|
188 | terms=self.highlight_items, | |
275 | analyzer=ANALYZER, |
|
189 | analyzer=ANALYZER, |
@@ -29,15 +29,14 b' import os' | |||||
29 | import sys |
|
29 | import sys | |
30 | import logging |
|
30 | import logging | |
31 |
|
31 | |||
32 | from os.path import dirname as dn, join as jn |
|
|||
33 | from rhodecode.model.meta import Session |
|
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 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
38 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
36 | sys.path.append(rc_path) |
|
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 | log = logging.getLogger(__name__) |
|
41 | log = logging.getLogger(__name__) | |
43 |
|
42 |
@@ -32,15 +32,14 b' import shutil' | |||||
32 | import logging |
|
32 | import logging | |
33 | import datetime |
|
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 | from rhodecode.lib.utils import BasePasterCommand, ask_ok, REMOVED_REPO_PAT |
|
35 | from rhodecode.lib.utils import BasePasterCommand, ask_ok, REMOVED_REPO_PAT | |
40 |
|
||||
41 | from rhodecode.lib.utils2 import safe_str |
|
36 | from rhodecode.lib.utils2 import safe_str | |
42 | from rhodecode.model.db import RhodeCodeUi |
|
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 | log = logging.getLogger(__name__) |
|
44 | log = logging.getLogger(__name__) | |
46 |
|
45 |
@@ -29,12 +29,12 b' import os' | |||||
29 | import sys |
|
29 | import sys | |
30 | import logging |
|
30 | import logging | |
31 |
|
31 | |||
32 | from os.path import dirname as dn, join as jn |
|
32 | from rhodecode.lib.utils import BasePasterCommand | |
33 | #to get the rhodecode import |
|
33 | ||
|
34 | # fix rhodecode import | |||
|
35 | from os.path import dirname as dn | |||
34 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
36 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
35 | sys.path.append(rc_path) |
|
37 | sys.path.append(rc_path) | |
36 | from rhodecode.lib.utils import BasePasterCommand |
|
|||
37 |
|
||||
38 |
|
38 | |||
39 | log = logging.getLogger(__name__) |
|
39 | log = logging.getLogger(__name__) | |
40 |
|
40 |
@@ -26,17 +26,16 b' from __future__ import with_statement' | |||||
26 |
|
26 | |||
27 | import os |
|
27 | import os | |
28 | import sys |
|
28 | import sys | |
|
29 | import logging | |||
29 | import pkg_resources |
|
30 | import pkg_resources | |
30 | import traceback |
|
31 | ||
31 | import logging |
|
32 | from rhodecode.lib.utils import BasePasterCommand, ask_ok | |
32 |
|
33 | |||
33 | from os.path import dirname as dn, join as jn |
|
34 | # fix rhodecode import | |
34 | #to get the rhodecode import |
|
35 | from os.path import dirname as dn | |
35 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
36 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
36 | sys.path.append(rc_path) |
|
37 | sys.path.append(rc_path) | |
37 |
|
38 | |||
38 | from rhodecode.lib.utils import BasePasterCommand, ask_ok |
|
|||
39 |
|
||||
40 | log = logging.getLogger(__name__) |
|
39 | log = logging.getLogger(__name__) | |
41 |
|
40 | |||
42 |
|
41 | |||
@@ -65,9 +64,9 b' class Command(BasePasterCommand):' | |||||
65 |
|
64 | |||
66 | here = config['here'] |
|
65 | here = config['here'] | |
67 | tmpl = pkg_resources.resource_string( |
|
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 | if os.path.exists(ext_file): |
|
70 | if os.path.exists(ext_file): | |
72 | msg = ('Extension file already exists, do you want ' |
|
71 | msg = ('Extension file already exists, do you want ' | |
73 | 'to overwrite it ? [y/n]') |
|
72 | 'to overwrite it ? [y/n]') |
@@ -29,17 +29,13 b' import os' | |||||
29 | import sys |
|
29 | import sys | |
30 | import logging |
|
30 | import logging | |
31 |
|
31 | |||
32 | from os.path import dirname as dn, join as jn |
|
|||
33 | from rhodecode.model.scm import ScmModel |
|
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 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
37 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
36 | sys.path.append(rc_path) |
|
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 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
45 |
|
41 |
@@ -4,8 +4,8 b' from paste.script.appinstall import Abst' | |||||
4 | from paste.script.command import BadCommand |
|
4 | from paste.script.command import BadCommand | |
5 | from paste.deploy import appconfig |
|
5 | from paste.deploy import appconfig | |
6 |
|
6 | |||
7 | from os.path import dirname as dn, join as jn |
|
7 | # fix rhodecode import | |
8 | #to get the rhodecode import |
|
8 | from os.path import dirname as dn | |
9 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) |
|
9 | rc_path = dn(dn(dn(os.path.realpath(__file__)))) | |
10 | sys.path.append(rc_path) |
|
10 | sys.path.append(rc_path) | |
11 |
|
11 |
@@ -29,16 +29,16 b' import sys' | |||||
29 | import logging |
|
29 | import logging | |
30 | import string |
|
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 | from rhodecode.lib.utils import BasePasterCommand |
|
32 | from rhodecode.lib.utils import BasePasterCommand | |
37 |
|
||||
38 | from rhodecode.model.db import Repository |
|
33 | from rhodecode.model.db import Repository | |
39 | from rhodecode.model.repo import RepoModel |
|
34 | from rhodecode.model.repo import RepoModel | |
40 | from rhodecode.model.meta import Session |
|
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 | log = logging.getLogger(__name__) |
|
42 | log = logging.getLogger(__name__) | |
43 |
|
43 | |||
44 |
|
44 |
@@ -167,7 +167,7 b' setup(' | |||||
167 | repo-scan=rhodecode.lib.paster_commands.repo_scan:Command |
|
167 | repo-scan=rhodecode.lib.paster_commands.repo_scan:Command | |
168 | cache-keys=rhodecode.lib.paster_commands.cache_keys:Command |
|
168 | cache-keys=rhodecode.lib.paster_commands.cache_keys:Command | |
169 | ishell=rhodecode.lib.paster_commands.ishell:Command |
|
169 | ishell=rhodecode.lib.paster_commands.ishell:Command | |
170 |
make-index=rhodecode.lib. |
|
170 | make-index=rhodecode.lib.paster_commands.make_index:Command | |
171 | upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb |
|
171 | upgrade-db=rhodecode.lib.dbmigrate:UpgradeDb | |
172 | celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand |
|
172 | celeryd=rhodecode.lib.celerypylons.commands:CeleryDaemonCommand | |
173 | """, |
|
173 | """, |
General Comments 0
You need to be logged in to leave comments.
Login now