Module: Milkode
- Defined in:
- lib/milkode/cdweb/lib/info_home.rb,
lib/milkode.rb,
lib/milkode/cli.rb,
lib/milkode/version.rb,
lib/milkode/cdstk/cdstk.rb,
lib/milkode/common/util.rb,
lib/milkode/common/dbdir.rb,
lib/milkode/cdstk/package.rb,
lib/milkode/grep/cli_grep.rb,
lib/milkode/grep/findgrep.rb,
lib/milkode/cdweb/lib/grep.rb,
lib/milkode/cdweb/cli_cdweb.rb,
lib/milkode/cdweb/lib/mkurl.rb,
lib/milkode/cdweb/lib/query.rb,
lib/milkode/database/updater.rb,
lib/milkode/cdweb/lib/command.rb,
lib/milkode/cdstk/milkode_yaml.rb,
lib/milkode/cdweb/lib/database.rb,
lib/milkode/grep/fast_gotoline.rb,
lib/milkode/cdstk/cdstk_command.rb,
lib/milkode/common/wide_matcher.rb,
lib/milkode/grep/findgrep_option.rb,
lib/milkode/cdweb/lib/web_setting.rb,
lib/milkode/common/ignore_checker.rb,
lib/milkode/common/ignore_setting.rb,
lib/milkode/common/plang_detector.rb,
lib/milkode/cdweb/lib/info_package.rb,
lib/milkode/cdweb/lib/package_list.rb,
lib/milkode/cdweb/lib/search_files.rb,
lib/milkode/database/package_table.rb,
lib/milkode/cdstk/yaml_file_wrapper.rb,
lib/milkode/database/document_table.rb,
lib/milkode/database/document_record.rb,
lib/milkode/cdweb/lib/coderay_wrapper.rb,
lib/milkode/cdweb/lib/search_contents.rb,
lib/milkode/cdweb/lib/search_gotoline.rb,
lib/milkode/database/groonga_database.rb,
lib/milkode/cdweb/lib/search_fuzzy_gotoline.rb
Overview
Defined Under Namespace
Modules: CdstkCommand, Dbdir, Util
Classes: AddError, CLI, CLI_Cdweb, CLI_Grep, Cdstk, CodeRayWrapper, ConvertError, Database, DocumentRecord, DocumentTable, FastGotoline, FindGrep, FindGrepOption, Grep, GroongaDatabase, IgnoreChecker, IgnoreError, IgnoreSetting, InfoHome, InfoPackage, MatchLineResult, MilkodeYaml, Mkurl, Package, PackageList, PackageTable, PlangDetector, Query, SearchContents, SearchFiles, SearchFuzzyGotoLine, SearchGotoLine, Updater, WebSetting, WideMatcher, WideMatcherZero, YamlFileWrapper
Constant Summary
collapse
- VERSION =
"1.8.2"
Instance Method Summary
collapse
-
#filelist(path, params, before, suburl) ⇒ Object
-
#packages(params, before, suburl, locale) ⇒ Object
-
#search(path, params, before, suburl, locale) ⇒ Object
-
#search_for_gomilk(params) ⇒ Object
-
#view(record, params, before) ⇒ Object
Instance Method Details
#filelist(path, params, before, suburl) ⇒ Object
95
96
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/milkode/cdweb/lib/command.rb', line 95
def filelist(path, params, before, suburl)
@setting = WebSetting.new
@title = filelist_title(path)
@path = path
fileList = Database.instance.fileList(path)
@total_records = fileList.size
@record_content = fileList.map do |v|
"<dt class='result-file'>#{file_or_dirimg(v[1], suburl)}<a href='#{Mkurl.new(suburl + '/home/' + v[0], params).inherit_query_shead}'>#{File.basename v[0]}</a></dt>"
end.join
Database.instance.touch_viewtime(path)
@elapsed = Time.now - before
haml :filelist
end
|
#packages(params, before, suburl, locale) ⇒ Object
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
|
# File 'lib/milkode/cdweb/lib/command.rb', line 109
def packages(params, before, suburl, locale)
@setting = WebSetting.new
@title = "Package List"
@path = ""
packages = Database.instance.packages(params["sort"])
@total_records = packages.size
@locale = locale
@sort_change_content =
[
sort_change_content(params["sort"], I18n.t(:name, locale: @locale)),
'|',
sort_change_content(params["sort"], I18n.t(:recently_viewed, locale: @locale), 'viewtime'),
'|',
sort_change_content(params["sort"], I18n.t(:added, locale: @locale), 'addtime'),
'|',
sort_change_content(params["sort"], I18n.t(:updated, locale: @locale), 'updatetime'),
'|',
sort_change_content(params["sort"], I18n.t(:favorite, locale: @locale), 'favtime'),
].join("\n")
@record_content = packages.map do |v|
"<dt class='result-file'>#{file_or_dirimg(false, suburl)}<a href='#{Mkurl.new(suburl + '/home/' + v, params).inherit_query_shead}'>#{File.basename v}</a></dt>"
end.join
@elapsed = Time.now - before
haml :packages
end
|
#search(path, params, before, suburl, locale) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/milkode/cdweb/lib/command.rb', line 60
def search(path, params, before, suburl, locale)
@setting = WebSetting.new
@path = path
query = Query.new(params[:query])
@title = "'#{query.query_string}' in #{path_title(path)}"
if (query.gotolines.size > 0)
searcher = SearchFuzzyGotoLine.new(path, params, query, suburl)
if searcher.directjump?
redirect searcher.directjump_url
end
elsif (query.keywords.size > 0)
if Util.gotoline_keyword?(query.keywords[0])
searcher = SearchGotoLine.new(path, params, query, suburl)
else
searcher = SearchContents.new(path, params, query, suburl, locale)
if searcher.directjump?
redirect searcher.directjump_url
end
end
else
searcher = SearchFiles.new(path, params, query, suburl)
end
@total_records = searcher.total_records
@range = searcher.data_range
@record_content = "<dl class='autopagerize_page_element'>#{searcher.html_contents}</dl>#{searcher.}";
@match_num = searcher.match_num
@elapsed = Time.now - before
haml :search
end
|
#search_for_gomilk(params) ⇒ Object
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/milkode/cdweb/lib/command.rb', line 137
def search_for_gomilk(params)
documents = Database.instance.documents
grn = documents.table
query = %Q|"#{params[:query]}"|
unless params[:all]
begin
package = CLI_Grep.package_root(params[:dir].gsub("\\", "/"))
rescue CLI_Grep::NotFoundPackage
return "Error: Not package dir '#{params[:dir]}'"
end
query += " package: #{package.name}"
end
records = grn.select(query, default_column: "content")
records.map { |r| r.path }.join("\n")
end
|
#view(record, params, before) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/milkode/cdweb/lib/command.rb', line 19
def view(record, params, before)
@setting = WebSetting.new
@title = record.shortpath
@path = record.shortpath
is_sensitive = params[:sensitive] == 'on'
q = params[:query] && Query.new(params[:query])
if (Util.larger_than_oneline(record.content) && q && !q.keywords.empty?)
if Util.gotoline_keyword?(q.keywords[0])
gotolines = Util.parse_gotoline(q.keywords)
match_lines = []
gotolines.each do |v|
if v[0][0][1..-1] == record.shortpath
match_lines << Grep::MatchLineResult.new(v[1] - 1, nil)
end
end
@record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines, q.keywords).to_html
else
grep = Grep.new(record.content)
match_lines = grep.match_lines_and(q.keywords, is_sensitive, q.wide_match_range)
if match_lines.empty? && q.wide_match_range_empty?
match_lines = grep.match_lines_and(q.keywords, is_sensitive, 7)
end
@record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines, q.keywords).to_html
end
else
@record_content = CodeRayWrapper.new(record.content, record.shortpath).to_html
end
Database.instance.touch_viewtime(@path)
@elapsed = Time.now - before
haml :view
end
|