Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ongaeshi committed May 5, 2013
2 parents 4c22f01 + 6df1a89 commit c35eaa8
Show file tree
Hide file tree
Showing 46 changed files with 926 additions and 299 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ notifications:
- ongaeshi0621@gmail.com

rvm:
- 1.8.7
# - 1.8.7
- 1.9.3
- 2.0.0

before_install:
- curl https://raw.github.com/groonga/groonga/master/data/travis/setup.sh | sh
23 changes: 12 additions & 11 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ source "http://rubygems.org"
# Example:
# gem "activesupport", ">= 2.3.5"
# gemspec
gem 'termcolor','>= 1.2.0', '< 1.2.2'
gem 'rroonga','>= 1.1.0'
gem 'rack','>=1.3.4', '~> 1.4.0'
gem 'sinatra', '>=1.2.6'
gem 'launchy', '>=0.3.7'
gem 'coderay', '>=1.0.5'
gem 'thin', '>=1.2.10'
gem 'archive-zip', '>=0.4.0'
gem 'haml', '>=3.1.2'
gem 'sass', '>=3.1.3'
gem 'thor', '~> 0.15.0'
gem 'termcolor' , '>= 1.2.0' , '< 1.2.2'
gem 'rroonga' , '>= 1.1.0'
gem 'rack' , '>= 1.5.2'
gem 'sinatra' , '>= 1.2.6'
gem 'launchy' , '>= 0.3.7'
gem 'coderay' , '>= 1.0.5'
gem 'thin' , '>= 1.2.10'
gem 'archive-zip' , '>= 0.4.0'
gem 'haml' , '>= 3.1.2'
gem 'sass' , '>= 3.1.3'
gem 'thor' , '>= 0.18.1'

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
Expand All @@ -23,4 +23,5 @@ group :development do
gem 'jeweler'
gem 'rack-test'
gem 'sinatra-reloader'
gem 'test-unit' , '>= 2.5.4'
end
42 changes: 41 additions & 1 deletion HISTORY.ja.rdoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,44 @@
=== 1.0.0.rc.1 2013/05/05

* milk web
* お気に入りリスト
* お気に入りを付けたパッケージにすぐアクセス出来る
* ☆マークをクリックでwebアプリからも設定が可能に

* 統計情報ボタンの設置
* ファイル数、行数、言語別割合の表示をWebインターフェースで

* 「新規タブ」ボタンを設置
* タブを開きながら検索

* help.haml
* 全体的にリニューアル
* 'w:' オプションについて追記

* gmilk
* 依存関係を整理して、起動時間の高速化
* ダイレクトパス検索('gmilk /path/to/file:5')に関してはさらに高速化
* gmilk -d が正しく動いていない問題を修正

* milk
* milk fav --sync-yaml を追加
* webアプリ経由のお気に入り設定をyamlに取り込む

* etc
* Ruby2.0.0 に対応
* test/test_milkode_yaml.rb が動かない問題を修正: Yaml#dumpの取得形式が変わった
* Gemfile更新: test-unit >= 2.5.4
* .travis.yml に Ruby2.0 を追加

* Gemfile
* 'thor 0.18.1' に対応
* 'rack 1.5.2' に対応

* ファイル構造の整理 : findgrep/findgrep.rb -> grep/findgrep.rb

* バグ修正
* Issues#47 add meta tag for favicon (thanks y-ken)

=== 0.9.9 2013/02/26

* ワイド範囲検索のサポート
Expand All @@ -13,7 +54,6 @@
* export MILKODE_SINATRA_RELOADER=1

* Delete 'milkode/cdweb/app_error.rb'
* Recommend 'RACK_ENV=production'

=== 0.9.8 2013/02/27

Expand Down
29 changes: 28 additions & 1 deletion HISTORY.rdoc
Original file line number Diff line number Diff line change
@@ -1,11 +1,38 @@
=== 1.0.0.rc.1 2013/05/05

* milk web
* Add favorite-list
* Add info
* Add 「newtab」button
* Renewal help.haml

* gmilk
* Fast startup time
* Fast directpath search('gmilk /path/to/file:5') more
* Fix 'gmilk -d'

* milk
* Add 'milk fav --sync-yaml'

* etc
* Support Ruby2.0.0

* Gemfile
* Support 'thor 0.18.1'
* Support 'rack 1.5.2'

* findgrep/findgrep.rb -> grep/findgrep.rb

* Bug fix
* Issues#47 add meta tag for favicon (thanks y-ken)

=== 0.9.9 2013/02/26

* Suppor wide range search
* Add 'w:' search option
* Support sinatra-reloader
* export MILKODE_SINATRA_RELOADER=1
* Delete 'milkode/cdweb/app_error.rb'
* Recommend 'RACK_ENV=production'

=== 0.9.8 2013/02/27

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.9.9
1.0.0.rc.1
2 changes: 1 addition & 1 deletion bin/gmilk
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/grep/cli_grep'

Version = "0.9.9"
Version = "1.0.0.rc.1"
Milkode::CLI_Grep.execute(STDOUT, ARGV)
2 changes: 1 addition & 1 deletion bin/milk
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
require 'rubygems'
require 'milkode/cli'

Version = "0.9.9"
Version = "1.0.0.rc.1"
Milkode::CLI.start(ARGV)
16 changes: 15 additions & 1 deletion lib/milkode/cdstk/cdstk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,21 @@ def list(args, options)
def fav(args, options)
db_open

if (args.empty?)
if (options[:sync_yaml])
is_dirty = false

@yaml.contents.each do |package|
db_fav = @grndb.packages.fav?(package.name)
if package.fav? != db_fav
@out.puts "#{package.name} : #{package.fav?} -> #{db_fav}"
package.set_fav(db_fav)
is_dirty = true
end
end

@yaml.save if is_dirty

elsif (args.empty?)
@out.puts @grndb.packages.favs.map{|r| r.name}
else
is_dirty = false
Expand Down
16 changes: 16 additions & 0 deletions lib/milkode/cdstk/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,22 @@ def ==(rhs)
name == rhs.name && directory == rhs.directory && ignore == rhs.ignore
end

def fav?
options[:fav] == true
end

def set_fav(value)
if value
if @hash['options']
@hash['options'][:fav] = true
else
@hash['options'] = {:fav => true}
end
else
@hash['options'].delete(:fav) if @hash['options']
end
end

private

def normalize
Expand Down
81 changes: 72 additions & 9 deletions lib/milkode/cdweb/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@
require 'haml'

$LOAD_PATH.unshift '../..'
require 'milkode/common/util'
require 'milkode/cdweb/lib/database'
require 'milkode/cdweb/lib/command'
require 'milkode/cdweb/lib/mkurl'
require 'milkode/cdweb/lib/web_setting'
require 'milkode/cdweb/lib/package_list'
require 'milkode/common/util'
require 'milkode/cdweb/lib/info_home'
require 'milkode/cdweb/lib/info_package'

set :haml, :format => :html5

get '/' do
if Database.validate?
@setting = WebSetting.new
@version = "0.9.9"
@version = "1.0.0.rc.1"

@package_num = Database.instance.yaml_package_num
@file_num = Database.instance.totalRecords
Expand Down Expand Up @@ -85,13 +87,18 @@ def package_path(path)
result = Database.instance.update(params[:name])
update_result_str(result, before)
end
when 'favorite'
Database.instance.set_fav(params[:name], params[:favorited] == 'true')
@package_list = PackageList.new(Database.instance.grndb)
"お気に入り: " + @package_list.favorite_list({})
end
end

get '/home*' do |path|
before = Time.now
path = path.sub(/^\//, "")
record = Database.instance.record(path)
@package_list = PackageList.new(Database.instance.grndb)

if path.empty?
if (params[:query] and !params[:query].empty?)
Expand All @@ -112,9 +119,37 @@ def package_path(path)

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

get '/info' do
obj = InfoHome.new

@setting = WebSetting.new
@path = ""
@summary_content = obj.summary_content
@record_content = obj.record_content

haml :info_home
end

get '/info/:package' do
before = Time.now

name = params[:package]
obj = InfoPackage.new(name)

@setting = WebSetting.new
@path = name
@summary_content = obj.summary_content
@plang_content = obj.plang_content

@elapsed = Time.now - before

haml :info_package
end

# -- helper function --

helpers do
Expand All @@ -127,8 +162,12 @@ def escape_path(src)
end

# -- utility --
def link(query)
"<a href='#{'/home?query=' + escape_url(query)}'>#{query}</a>"
def link(query, text = nil)
if text.nil?
"<a href='#{'/home?query=' + escape_url(query)}'>#{query}</a>"
else
"<a href='#{'/home?query=' + escape_url(query)}'>#{text}</a>"
end
end

def create_select_shead(value)
Expand Down Expand Up @@ -187,12 +226,15 @@ def create_headmenu(path, query, flistpath = '')
modal_body = "#{package_name} を更新しますか?"
end

info_path = "/info"
info_path = File.join(info_path, package_name) if package_name != ""

<<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(document.URL); return false;">タブを複製</a>
#{headicon('directory.png')} <a href="#{flist}" class="headmenu">ディレクトリ</a>
#{headicon('view-refresh-4.png')} <a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>
#{headicon('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
#{headicon('go-home-5.png')}<a href="/home" class="headmenu">ホーム</a>&nbsp;
#{headicon('directory.png')}<a href="#{flist}" class="headmenu">ディレクトリ</a>
#{headicon('view-refresh-4.png')}<a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>&nbsp;
#{headicon('info.png')}<a href="#{info_path}" class="headmenu">統計情報</a>&nbsp;
#{headicon('help.png')}<a href="/help" class="headmenu">ヘルプ</a>
<div id="updateModal" class="modal hide fade">
<div class="modal-header">
Expand Down Expand Up @@ -227,6 +269,16 @@ def create_headmenu(path, query, flistpath = '')
EOF
end

def create_favorite_list(package_list)
<<EOF
<div class="favorite_list">
お気に入り:
#{package_list.favorite_list(params)}
</div>
</div>
EOF
end

def headicon(name)
"<img alt='' style='vertical-align:center; border: 0px; margin: 0px;' src='/images/#{name}'>"
end
Expand Down Expand Up @@ -295,6 +347,17 @@ def update_result_str(result, before)
"#{r.join(', ')} (#{Time.now - before} sec)"
end

def favstar(path)
pname = package_name(path)

if pname != "root"
classes = Database.instance.fav?(pname) ? "star favorited" : "star"
"<a href=\"javascript:\" class=\"#{classes}\" milkode-package-name=\"#{pname}\">Favorite Me</a>"
else
""
end
end

# .search-summary に追加情報を表示したい時はこの関数をオーバーライド
def search_summary_hook(path)
""
Expand Down
Loading

0 comments on commit c35eaa8

Please sign in to comment.