Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents f7d4f0d + af1d170 commit f37e959d73d7ee6f44d0286516cb23f651baeb4c @ongaeshi committed Jul 9, 2012
View
@@ -21,4 +21,5 @@ gem 'thor', '~> 0.15.0'
group :development do
gem "bundler"
gem "jeweler"
+ gem "rack-test"
end
View
@@ -1,3 +1,39 @@
+=== 0.9.0 2012/07/09
+
+* milk web
+ * ページデザインを刷新
+ * メインページ以外もTwitter bootstrapに対応
+ * デザインの調整
+ * ファイル一覧 -> ディレクトリ に文章変更
+ * 検索時にキーワードにマッチするファイルも合わせて表示するように
+ * パッケージセレクタの追加
+ * 現在パッケージ名を選択
+ * パッケージの切り替え
+ * ダイレクトジャンプ
+ * viewモードで行番号をクリックするとダイレクトパス(現在行を表すテキスト)を表示
+ * ダイレクトパス入力時に指定行に直接ジャンプ出来るように
+ * 検索オプション追加
+ * fp(fpath_or_packages)
+ * k(keyword)
+ * 大文字/小文字を区別する(:sensitive)
+ * バグ修正
+ * 空ファイルを表示出来ない問題を修正
+ * 半角スペースを含むファイルが正しく表示出来ない
+ * ファイル検索時に次の100件が表示されない
+ * ヘルプに文言追加
+ * Webアプリのテストを追加(test_cdweb_app)
+
+* gmilk
+ * 引数解析して'-g'オプション無くても-gモードに移行出来るように
+ * ダイレクトパス入力時に指定行に直接ジャンプ出来るように
+
+* database
+ * fpath_or_packages(fp)オプションに対応
+
+=== 0.8.1 2012/06/20
+
+* gmilk -a -u 時にエラーになる問題を修正 (thanks hazy_moon)
+
=== 0.8.0 2012/06/20
* milk web
View
@@ -1,3 +1,23 @@
+=== 0.9.0 2012/07/09
+
+* milk web
+ * Renew page design
+ * Display match files when searching
+ * Add package selector
+ * Direct jump
+ * Add search options
+ * Bug fix
+
+* gmilk
+ * Direct jump
+
+* database
+ * fpath_or_packages
+
+=== 0.8.1 2012/06/20
+
+* Fix, gmilk -a -u error (thanks hazy_moon)
+
=== 0.8.0 2012/06/20
* milk web
View
@@ -1 +1 @@
-0.8.0
+0.9.0
View
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/grep/cli_grep'
-Version = "0.8.0"
+Version = "0.9.0"
Milkode::CLI_Grep.execute(STDOUT, ARGV)
View
@@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/cli'
-Version = "0.8.0"
+Version = "0.9.0"
Milkode::CLI.start(ARGV)
@@ -16,12 +16,13 @@
require 'milkode/cdweb/lib/mkurl'
require 'milkode/cdweb/lib/web_setting'
require 'milkode/cdweb/lib/package_list'
+require 'milkode/common/util'
set :haml, :format => :html5
get '/' do
@setting = WebSetting.new
- @version = "0.8.0"
+ @version = "0.9.0"
@package_num = Database.instance.yaml_package_num
@file_num = Database.instance.totalRecords
@package_list = PackageList.new(Database.instance.grndb)
@@ -49,7 +50,15 @@ def package_path(path)
path = package_path(path)
end
- redirect Mkurl.new("#{path}", params).inherit_query_shead
+ query = Query.new(params[:query])
+ # gotolineモードで1つだけ渡された時は直接ジャンプ
+ if query.keywords.size == 1 && Milkode::Util::gotoline_keyword?(query.keywords[0])
+ gotoline = Milkode::Util::parse_gotoline(query.keywords)[0]
+ path2 = File.join('/home', gotoline[0][0])
+ redirect Mkurl.new(path2, params).inherit_query_shead + "#n#{gotoline[1]}"
+ else
+ redirect Mkurl.new("#{path}", params).inherit_query_shead
+ end
end
end
@@ -96,14 +105,37 @@ def link(query)
"<a href='#{'/home?query=' + escape_url(query)}'>#{query}</a>"
end
- def create_radio(value, shead)
- str = (value == shead) ? 'checked' : ''
- "<input name='shead' type='radio' value='#{value}' #{str}/>"
+ def create_select_shead(value)
+ value ||= "package"
+
+ data = [
+ ['all' , '全て' ],
+ ['package' , 'パッケージ' ],
+ ['directory', 'ディレクトリ'],
+ ]
+
+ <<EOF
+<select name="shead" id="shead">
+#{data.map{|v| "<option value='#{v[0]}' #{v[0] == value ? 'selected' : ''}>#{v[1]}</option>"}}
+</select>
+EOF
end
- def create_checkbox(name, value)
+ def create_select_package(path)
+ value = package_name(path)
+ value = '---' if value == "root"
+ data = ['---'] + Database.instance.packages(nil)
+
+ <<EOF
+<select name="package" id="package" onchange="select_package()">
+#{data.map{|v| "<option value='#{v}' #{v == value ? 'selected' : ''}>#{v}</option>"}}
+</select>
+EOF
+ end
+
+ def create_checkbox(name, value, label)
str = (value) ? 'checked' : ''
- "<input type='checkbox' name='#{name}' value='on' #{str}/>"
+ "<label class='checkbox inline'><input type='checkbox' name='#{name}' value='on' #{str}/>#{label}</label>"
end
def create_headmenu(path, query, flistpath = '')
@@ -112,7 +144,7 @@ def create_headmenu(path, query, flistpath = '')
<<EOF
#{headicon('go-home-5.png')} <a href="/home" class="headmenu">全てのパッケージ</a>
#{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open('#{href}'); return false;">新しい検索</a>
- #{headicon('directory.png')} <a href="#{flist}" class="headmenu">ファイル一覧</a>
+ #{headicon('directory.png')} <a href="#{flist}" class="headmenu">ディレクトリ</a>
#{headicon('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
EOF
end
@@ -131,6 +163,35 @@ def topic_path(path, params)
}.join('/')
end
+ HASH = {
+ '.h' => ['.c', '.cpp', '.m', '.mm'],
+ '.c' => ['.h'],
+ '.hpp' => ['.cpp'],
+ '.cpp' => ['.hpp', '.h'],
+ '.m' => ['.h'],
+ '.mm' => ['.h'],
+ }
+
+ def additional_info(path, parms)
+ suffix = File.extname path
+ cadet = HASH[suffix]
+
+ if (cadet)
+ result = cadet.find do |v|
+ Database.instance.record(path.gsub(/#{suffix}\Z/, v))
+ end
+
+ if (result)
+ path2 = path.gsub(/#{suffix}\Z/, result)
+ " (<a href='#{Mkurl.new(File.join('/home', path2), params).inherit_query_shead}'>#{result}</a>) "
+ else
+ ''
+ end
+ else
+ ''
+ end
+ end
+
def package_name(path)
(path == "") ? 'root' : path.split('/')[0]
end
@@ -72,22 +72,7 @@ def self.number! output, mode = :table, options = {}
raise ArgumentError, "Invalid value %p for :line_number_start; Integer expected." % start
end
- anchor_prefix = options[:line_number_anchors]
- anchor_prefix = 'line' if anchor_prefix == true
- anchor_prefix = anchor_prefix.to_s[/\w+/] if anchor_prefix
-
- anchor_url = options[:line_number_anchor_url] || ""
-
- anchoring =
- if anchor_prefix
- proc do |line|
- line = line.to_s
- anchor = anchor_prefix + line
- "<a href=\"#{anchor_url}##{anchor}\" name=\"#{anchor}\">#{line}</a>"
- end
- else
- proc { |line| line.to_s } # :to_s.to_proc in Ruby 1.8.7+
- end
+ anchoring = create_anchor(options)
bold_every = options[:bold_every]
highlight_lines = options[:highlight_lines]
@@ -166,6 +151,29 @@ def self.number! output, mode = :table, options = {}
output
end
+
+ def self.create_anchor(options)
+ anchor_prefix = options[:line_number_anchors]
+ anchor_prefix = 'line' if anchor_prefix == true
+ anchor_prefix = anchor_prefix.to_s[/\w+/] if anchor_prefix
+
+ if anchor_prefix
+ anchor_url = options[:line_number_anchor_url] || ""
+
+ proc do |line|
+ line = line.to_s
+ anchor = anchor_prefix + line
+ "<a href=\"#{anchor_url}##{anchor}\" name=\"#{anchor}\">#{line}</a>"
+ end
+ elsif options[:onclick_copy_line_number]
+ prefix = options[:onclick_copy_prefix] || ""
+ proc do |line|
+ "<a href=\"#!\" onclick=\"alert('#{prefix + line.to_s}');\" title=\"Display line number\">#{line.to_s}</a>"
+ end
+ else
+ proc { |line| line.to_s } # :to_s.to_proc in Ruby 1.8.7+
+ end
+ end
end
end
end
@@ -55,7 +55,9 @@ def to_html
:css => :class,
:highlight_lines => @highlight_lines,
:line_number_start => @line_number_start,
- :line_number_anchors => false
+ :line_number_anchors => false,
+ :onclick_copy_line_number => true,
+ :onclick_copy_prefix => "/#{@filename}:"
)
end
@@ -9,6 +9,7 @@
require 'milkode/cdweb/lib/coderay_wrapper'
require 'milkode/cdweb/lib/search_contents'
require 'milkode/cdweb/lib/search_files'
+require 'milkode/cdweb/lib/search_gotoline'
require 'milkode/cdweb/lib/mkurl'
require 'milkode/common/util'
@@ -17,13 +18,25 @@ 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) and q and !q.keywords.empty?)
- grep = Grep.new(record.content)
- match_lines = grep.match_lines_and(q.keywords)
- @record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines).to_html
+ 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).to_html
+ else
+ grep = Grep.new(record.content)
+ match_lines = grep.match_lines_and(q.keywords, is_sensitive)
+ @record_content = CodeRayWrapper.new(record.content, record.shortpath, match_lines).to_html
+ end
else
@record_content = CodeRayWrapper.new(record.content, record.shortpath).to_html
end
@@ -40,7 +53,11 @@ def search(path, params, before)
@title = "'#{query.query_string}' in #{path_title(path)}"
if (query.keywords.size > 0)
- searcher = SearchContents.new(path, params, query)
+ if Util::gotoline_keyword? query.keywords[0]
+ searcher = SearchGotoLine.new(path, params, query)
+ else
+ searcher = SearchContents.new(path, params, query)
+ end
else
searcher = SearchFiles.new(path, params, query)
end
@@ -12,6 +12,7 @@
require 'milkode/common/dbdir'
require 'milkode/cdstk/yaml_file_wrapper'
require 'milkode/database/groonga_database'
+require 'milkode/common/util'
include Milkode
module Milkode
@@ -42,18 +43,22 @@ def yaml_reload
def open
if !@grndb || @grndb.closed?
- @grndb = GroongaDatabase.new
- @grndb.open(Database.dbdir)
- @grndb.yaml_sync(yaml_load.contents)
- @documents = @grndb.documents
+ open_force
end
end
+ def open_force
+ @grndb = GroongaDatabase.new
+ @grndb.open(Database.dbdir)
+ @grndb.yaml_sync(yaml_load.contents)
+ @documents = @grndb.documents
+ end
+
def record(shortpath)
DocumentRecord.create @documents.find_shortpath(shortpath)
end
- def search(patterns, packages, current_path, fpaths, suffixs, offset = 0, limit = -1)
+ def search(patterns, keywords, packages, current_path, fpaths, suffixs, fpath_or_packages, offset = 0, limit = -1)
paths = []
# パッケージ名未指定の時は現在位置を検索条件に追加
@@ -73,11 +78,12 @@ def search(patterns, packages, current_path, fpaths, suffixs, offset = 0, limit
# 検索
result = @documents.search(
:patterns => patterns,
- # :keywords => ,
+ :keywords => keywords,
:paths => paths,
:packages => packages,
:restpaths => fpaths,
:suffixs => suffixs,
+ :fpath_or_packages => fpath_or_packages,
:offset => offset,
:limit => limit
)
Oops, something went wrong.

0 comments on commit f37e959

Please sign in to comment.