Skip to content

Commit

Permalink
Merge 0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ongaeshi committed Mar 28, 2012
2 parents 48625b3 + 05e7e0f commit fd2bc4d
Show file tree
Hide file tree
Showing 32 changed files with 631 additions and 351 deletions.
25 changes: 25 additions & 0 deletions HISTORY.ja.rdoc
@@ -1,3 +1,28 @@
=== 0.6.0 2012/03/28

* milk web
* 高速化
* パッケージ数をmilkode.yamlから取得
* Database#fileList('/')をmilkode.yamlから取得
* CodeRay::Encoders::HTMLを直接カスタマイズすることで高速化
* ウェブアプリのタイトルやアイコンを簡単にカスタマイズ出来るように
* milk web --customize で、milkweb.yaml のテンプレートを作成
* milkweb.yaml を書き換えることでカスタマイズ出来ます
* 使い勝手の改善
* 近接行マッチはまとめて表示するように。
* 検索結果の行番号をクリックで指定行へジャンプ出来るように
* 検索結果はファイル名順にソートするように
* クリアボタンを追加
* ヘッダーメニューに'ヘルプ'の項目を追加
* ラジオボタンが未指定の時は'shead=package'に
* パッケージ検索を正確に
* CodeRay 1.0.5 に対応
* nokogiri, hpricot への依存を外す

* common
* '\n' -> '$/'
* 'rroonga','>= 1.1.0','<2.0'

=== 0.5.0 2012/03/09

* milk
Expand Down
13 changes: 13 additions & 0 deletions HISTORY.rdoc
@@ -1,3 +1,16 @@
=== 0.6.0 2012/03/28

* milk web
* Optimize
* Customize title and icon
* Usability improvements
* CodeRay 1.0.5
* Remove the dependency on hpricot, nokogiri

* common
* '\n' -> '$/'
* 'rroonga','>= 1.1.0','<2.0'

=== 0.5.0 2012/03/09

* milk
Expand Down
10 changes: 4 additions & 6 deletions Rakefile
Expand Up @@ -23,17 +23,15 @@ Jeweler::Tasks.new do |gem|

# Include your dependencies below. Runtime dependencies are required when using your gem,
gem.add_runtime_dependency 'termcolor','>= 1.2.0'
gem.add_runtime_dependency 'rroonga','>= 1.1.0'
gem.add_runtime_dependency 'rroonga','>= 1.1.0','<2.0'
gem.add_runtime_dependency 'rack','>=1.3.4'
gem.add_runtime_dependency 'sinatra', '>=1.2.6'
gem.add_runtime_dependency 'launchy', '>=0.3.7'
gem.add_runtime_dependency 'coderay', '=0.9.8'
gem.add_runtime_dependency 'coderay', '>=1.0.5'
gem.add_runtime_dependency 'thin', '>=1.2.10'
gem.add_runtime_dependency 'archive-zip', '>=0.4.0'
gem.add_runtime_dependency 'haml', '>=3.1.2'
gem.add_runtime_dependency 'sass', '>=3.1.3'
gem.add_runtime_dependency 'nokogiri', '>=1.5.0'
gem.add_runtime_dependency 'hpricot', '>=0.8.2'

# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
# gem.add_development_dependency 'rspec', '> 1.2.3'
Expand All @@ -55,7 +53,7 @@ end

Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/test_*.rb'
test.test_files = FileList['test/**/test_*.rb']
test.verbose = true
end

Expand All @@ -78,7 +76,7 @@ end

task :default => :test

require 'rake/rdoctask'
require 'rdoc/task'
Rake::RDocTask.new do |rdoc|
version = File.exist?('VERSION') ? File.read('VERSION') : ""

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.5.0
0.6.0
2 changes: 1 addition & 1 deletion bin/gmilk
Expand Up @@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/grep/cli_grep'

Version = "0.5.0"
Version = "0.6.0"
Milkode::CLI_Grep.execute(STDOUT, ARGV)
2 changes: 1 addition & 1 deletion bin/milk
Expand Up @@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/cdstk/cli_cdstk'

Version = "0.5.0"
Version = "0.6.0"
Milkode::CLI_Cdstk.execute(STDOUT, ARGV)
4 changes: 2 additions & 2 deletions lib/milkode/cdstk/cdstk.rb
Expand Up @@ -636,12 +636,12 @@ def remove_dir(dir, no_yaml = false)
end

# データベースからも削除
dir = File.expand_path(dir)
# dir = File.expand_path(dir)

alert("rm_package", dir)
@package_count += 1

Database.instance.remove([File.basename(dir)]) do |record|
Database.instance.remove_fpath(dir) do |record|
alert_info("rm_record", record.path)
@file_count += 1
end
Expand Down
1 change: 1 addition & 0 deletions lib/milkode/cdstk/cli_cdstksub.rb
Expand Up @@ -120,6 +120,7 @@ def self.setup_web
opts.on('-p', '--port PORT', 'use PORT (default: 9292)') {|v| options[:Port] = v }
opts.on("-s", "--server SERVER", "serve using SERVER (default : thin)") {|s| options[:server] = s }
opts.on('-n', '--no-browser', 'No launch browser.') {|v| options[:LaunchBrowser] = false }
opts.on('--customize', 'Create customize file.') {|v| options[:customize] = true }

# --hostが'-h'を上書きするので、'-h'を再定義してあげる
opts.on_tail("-h", "-?", "--help", "Show this message") do
Expand Down
5 changes: 5 additions & 0 deletions lib/milkode/cdstk/milkode_yaml.rb
Expand Up @@ -59,6 +59,11 @@ def find_name(name)
@contents.find {|v| v.same_name?(name)}
end

# 指定キーワードにマッチする全てのパッケージを返す
def match_all(keyword)
@contents.find_all {|p| p.name.include? keyword }
end

# ディレクトリ名が同じパッケージを検索
def find_dir(directory)
@contents.find {|v| v.directory == directory}
Expand Down
4 changes: 4 additions & 0 deletions lib/milkode/cdstk/yaml_file_wrapper.rb
Expand Up @@ -56,6 +56,10 @@ def find_name(name)
@data.find_name(name)
end

def match_all(keyword)
@data.match_all(keyword)
end

def find_dir(dir)
@data.find_dir(dir)
end
Expand Down
38 changes: 27 additions & 11 deletions lib/milkode/cdweb/app.rb
Expand Up @@ -14,27 +14,41 @@
require 'milkode/cdweb/lib/database'
require 'milkode/cdweb/lib/command'
require 'milkode/cdweb/lib/mkurl'
require 'milkode/cdweb/lib/web_setting'

set :haml, :format => :html5

get '/' do
@version = "0.5.0"
@package_num = Database.instance.fileList('').size
@file_num = Database.instance.fileNum
@setting = WebSetting.new
@version = "0.6.0"
@package_num = Database.instance.yaml_package_num
@file_num = Database.instance.totalRecords
haml :index
end

def package_path(path)
path.split('/')[0,3].join('/')
end

post '/search*' do
path = unescape(params[:pathname])

case params[:shead]
when 'all'
path = "/home"
when 'package'
path = path.split('/')[0,3].join('/')
end

redirect Mkurl.new("#{path}", params).inherit_query_shead
if params[:clear]
redirect Mkurl.new("#{path}", params).inherit_shead
else
case params[:shead]
when 'all'
path = "/home"
when 'package'
path = package_path(path)
when 'directory'
# do nothing
else
path = package_path(path)
end

redirect Mkurl.new("#{path}", params).inherit_query_shead
end
end

get '/home*' do |path|
Expand All @@ -54,6 +68,7 @@
end

get %r{/help} do
@setting = WebSetting.new
haml :help
end

Expand Down Expand Up @@ -90,6 +105,7 @@ def create_headmenu(path, query, flistpath = '')
#{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('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
EOF
end

Expand Down
46 changes: 39 additions & 7 deletions lib/milkode/cdweb/cli_cdweb.rb
Expand Up @@ -75,6 +75,7 @@ def self.execute(stdout, argv)
opts.on('-p', '--port PORT', 'use PORT (default: 9292)') {|v| options[:Port] = v }
opts.on("-s", "--server SERVER", "serve using SERVER (default : thin)") {|s| options[:server] = s }
opts.on('-n', '--no-browser', 'No launch browser.') {|v| options[:LaunchBrowser] = false }
opts.on('--customize', 'Create customize file.') {|v| options[:customize] = true }

# --hostが'-h'を上書きするので、'-h'を再定義してあげる
opts.on_tail("-h", "-?", "--help", "Show this message") do
Expand All @@ -89,16 +90,21 @@ def self.execute(stdout, argv)
end

def self.execute_with_options(stdout, options)
# 使用するデータベースの位置設定
Database.setup(File.expand_path(options[:DbDir]))
dbdir = File.expand_path(options[:DbDir])

unless options[:customize]
# 使用するデータベースの位置設定
Database.setup(dbdir)

# サーバースクリプトのある場所へ移動
FileUtils.cd(File.dirname(__FILE__))
# サーバースクリプトのある場所へ移動
FileUtils.cd(File.dirname(__FILE__))

# Rackサーバー起動
Rack::Server.start(options)
# Rackサーバー起動
Rack::Server.start(options)
else
create_customize_file(dbdir)
end
end


def self.select_dbdir
if (Dbdir.dbdir?('.') || !Dbdir.dbdir?(Dbdir.default_dir))
Expand All @@ -107,5 +113,31 @@ def self.select_dbdir
Dbdir.default_dir
end
end

def self.create_customize_file(dbdir)
fname = File.join(dbdir, "milkweb.yaml")

if File.exist? fname
puts "Already exist '#{fname}'"
else
puts <<EOF
Create '#{fname}'.
Please customize yaml parameter.
EOF

File.open(fname, "w") do |f|
f.write <<EOF
---
:home_title : "Milkode"
:home_icon : "/images/MilkodeIcon135.png"
:header_title: "Milkode"
:header_icon : "/images/MilkodeIcon135.png"
:display_about_milkode: true
EOF
end
end
end
end
end

0 comments on commit fd2bc4d

Please sign in to comment.