milkode 0.9.3.1 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/HISTORY.ja.rdoc +25 -0
- data/HISTORY.rdoc +17 -0
- data/VERSION +1 -1
- data/bin/gmilk +1 -1
- data/bin/milk +1 -1
- data/lib/milkode/cdstk/cdstk.rb +16 -23
- data/lib/milkode/cdstk/milkode_yaml.rb +1 -1
- data/lib/milkode/cdweb/app.rb +18 -2
- data/lib/milkode/cdweb/lib/coderay_html2.rb +5 -1
- data/lib/milkode/cdweb/lib/coderay_php_utf8.rb +523 -0
- data/lib/milkode/cdweb/lib/coderay_wrapper.rb +4 -0
- data/lib/milkode/cdweb/lib/database.rb +10 -6
- data/lib/milkode/cdweb/lib/search_contents.rb +2 -2
- data/lib/milkode/cdweb/public/css/coderay-patch.css +1 -0
- data/lib/milkode/cdweb/public/js/milkode.js +26 -0
- data/lib/milkode/cli.rb +9 -5
- data/lib/milkode/common/plang_detector.rb +1 -0
- data/lib/milkode/common/util.rb +4 -0
- data/lib/milkode/database/document_table.rb +7 -1
- data/milkode.gemspec +6 -5
- data/test/test_plang_detector.rb +1 -0
- metadata +13 -5
data/Gemfile
CHANGED
data/HISTORY.ja.rdoc
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
=== 0.9.4 2012/11/14
|
2
|
+
|
3
|
+
* milk web
|
4
|
+
* 行番号クリック時の処理を改善
|
5
|
+
* ウィンドウをモーダルに変更
|
6
|
+
* ハイライト、URLを選択行に差し替え (thanks asane)
|
7
|
+
* 検索ボックスの操作性を改善 (thanks kenhys)
|
8
|
+
* Select query text on click event
|
9
|
+
* keep query text selected after searching
|
10
|
+
* suppress select() call for query text by tag jump
|
11
|
+
* パッケージ一覧のソートのルールを整理
|
12
|
+
* ソースコードの文字コードがEUC-JPの場合、検索結果に表示される日本語が文字化けする問題を修正 (thanks azurite)
|
13
|
+
* 文言修正 : '新しい検索' -> 'タブを複製'
|
14
|
+
|
15
|
+
* milk
|
16
|
+
* milk remove 改善
|
17
|
+
* milk init /path/to/dir -s が正しく動作しない問題を修正
|
18
|
+
* milkode_yaml.rb: package_root の正規表現調整
|
19
|
+
* 他のオプションとのバッティングを防ぐために milk -v は使えないように、 milk --version を推奨
|
20
|
+
* 拡張子 csproj, vbproj, sln に対応 (VisualStudio)
|
21
|
+
* document_table.rb: addするとnegative string size (or size too big) (ArgumentError)となる問題を修正 (thanks azurite)
|
22
|
+
|
23
|
+
* Bug fix
|
24
|
+
* termcolorの要求バージョンを '< 1.2.2' に (thanks mallowlabs)
|
25
|
+
|
1
26
|
=== 0.9.3.1 2012/10/14
|
2
27
|
|
3
28
|
* 'milk plugins' add gem-milkode, bundle-milkode
|
data/HISTORY.rdoc
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== 0.9.4
|
2
|
+
|
3
|
+
* milk web
|
4
|
+
* Improve handling when you click the line number
|
5
|
+
* Improve the usability of the search box (thanks kenhys)
|
6
|
+
|
7
|
+
* milk
|
8
|
+
* Improve milk remove
|
9
|
+
* Fix milk init /path/to/dir -s
|
10
|
+
* milkode_yaml.rb: Fix package_root regexp
|
11
|
+
* milk -v -> milk --version
|
12
|
+
* plang_detector.rb: Add csproj, vbproj, sln (VisualStudio)
|
13
|
+
* document_table.rb: Fix error negative string size (or size too big)
|
14
|
+
|
15
|
+
* Bug fix
|
16
|
+
* termcolor require version '< 1.2.2' (thanks mallowlabs)
|
17
|
+
|
1
18
|
=== 0.9.3.1 2012/10/14
|
2
19
|
|
3
20
|
* 'milk plugins' add gem-milkode, bundle-milkode
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.9.
|
1
|
+
0.9.4
|
data/bin/gmilk
CHANGED
data/bin/milk
CHANGED
data/lib/milkode/cdstk/cdstk.rb
CHANGED
@@ -316,29 +316,21 @@ module Milkode
|
|
316
316
|
if (options[:all])
|
317
317
|
remove_all
|
318
318
|
else
|
319
|
-
|
320
|
-
|
321
|
-
|
319
|
+
print_result do
|
320
|
+
db_open
|
321
|
+
args.each do |arg|
|
322
|
+
package = @yaml.find_name(arg) || @yaml.find_dir(arg)
|
322
323
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
remove_dir(package.directory)
|
324
|
+
unless package
|
325
|
+
path = File.expand_path(arg)
|
326
|
+
package = @yaml.package_root(path)
|
327
327
|
end
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
args.each do |name|
|
335
|
-
package = @yaml.find_name(name) || @yaml.find_dir(name)
|
336
|
-
if (package)
|
337
|
-
remove_dir(package.directory)
|
338
|
-
else
|
339
|
-
@out.puts "Not found package '#{name}'."
|
340
|
-
return
|
341
|
-
end
|
328
|
+
|
329
|
+
if (package)
|
330
|
+
remove_dir(package.directory)
|
331
|
+
else
|
332
|
+
@out.puts "Not found package '#{arg}'."
|
333
|
+
return
|
342
334
|
end
|
343
335
|
end
|
344
336
|
end
|
@@ -584,13 +576,14 @@ module Milkode
|
|
584
576
|
end
|
585
577
|
end
|
586
578
|
|
587
|
-
def setdb(
|
579
|
+
def setdb(args, options)
|
588
580
|
if (options[:reset])
|
589
581
|
CdstkCommand.setdb_reset
|
590
582
|
@out.puts "Reset default db\n remove: #{Dbdir.milkode_db_dir}\n default_db: #{Dbdir.default_dir}"
|
591
|
-
elsif (
|
583
|
+
elsif (args.empty?)
|
592
584
|
@out.puts Dbdir.default_dir
|
593
585
|
else
|
586
|
+
dbpath = args.first
|
594
587
|
path = File.expand_path(dbpath)
|
595
588
|
begin
|
596
589
|
CdstkCommand.setdb_set path
|
data/lib/milkode/cdweb/app.rb
CHANGED
@@ -22,7 +22,7 @@ set :haml, :format => :html5
|
|
22
22
|
|
23
23
|
get '/' do
|
24
24
|
@setting = WebSetting.new
|
25
|
-
@version = "0.9.
|
25
|
+
@version = "0.9.4"
|
26
26
|
@package_num = Database.instance.yaml_package_num
|
27
27
|
@file_num = Database.instance.totalRecords
|
28
28
|
@package_list = PackageList.new(Database.instance.grndb)
|
@@ -183,7 +183,7 @@ EOF
|
|
183
183
|
|
184
184
|
<<EOF
|
185
185
|
#{headicon('go-home-5.png')} <a href="/home" class="headmenu">ホーム</a>
|
186
|
-
#{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open('#{href}'); return false;"
|
186
|
+
#{headicon('document-new-4.png')} <a href="#{href}" class="headmenu" onclick="window.open('#{href}'); return false;">タブを複製</a>
|
187
187
|
#{headicon('directory.png')} <a href="#{flist}" class="headmenu">ディレクトリ</a>
|
188
188
|
#{headicon('view-refresh-4.png')} <a href="#updateModal" class="headmenu" data-toggle="modal">パッケージを更新</a>
|
189
189
|
#{headicon('help.png')} <a href="/help" class="headmenu">ヘルプ</a>
|
@@ -201,6 +201,22 @@ EOF
|
|
201
201
|
<a href="#" id="updateOk" class="btn btn-primary" data-loading-text="Updating..." milkode-package-name="#{package_name}"">OK</a>
|
202
202
|
</div>
|
203
203
|
</div>
|
204
|
+
|
205
|
+
<div id="lineno-modal" class="modal hide">
|
206
|
+
<div class="modal-header">
|
207
|
+
<a href="#" class="close" data-dismiss="modal">×</a>
|
208
|
+
<h3 id="lineno-path"></h3>
|
209
|
+
</div>
|
210
|
+
<div class="modal-body">
|
211
|
+
<table class="CodeRay"><tr>
|
212
|
+
<td class="code"><pre id="lineno-body">
|
213
|
+
</pre></td>
|
214
|
+
</tr></table>
|
215
|
+
</div>
|
216
|
+
<div class="modal-footer">
|
217
|
+
<a href="#" id="lineno-ok" class="btn" data-dismiss="modal">OK</a>
|
218
|
+
</div>
|
219
|
+
</div>
|
204
220
|
EOF
|
205
221
|
end
|
206
222
|
|
@@ -5,6 +5,9 @@
|
|
5
5
|
# @author ongaeshi
|
6
6
|
# @date 2012/03/18
|
7
7
|
|
8
|
+
require 'rubygems'
|
9
|
+
require 'rack'
|
10
|
+
|
8
11
|
module CodeRay
|
9
12
|
module Encoders
|
10
13
|
class HTML2 < HTML
|
@@ -168,7 +171,8 @@ module Encoders
|
|
168
171
|
elsif options[:onclick_copy_line_number]
|
169
172
|
prefix = options[:onclick_copy_prefix] || ""
|
170
173
|
proc do |line|
|
171
|
-
"<a href=\"
|
174
|
+
"<a href=\"#lineno-modal\" data-toggle=\"modal\" onclick=\"lineno_setup('#{prefix}', '#{line.to_s}');\" title=\"Display line number\">#{line.to_s}</a>"
|
175
|
+
# "<a onclick=\"lineno_setup('#{prefix}', '#{line.to_s}');\" title=\"Display line number\">#{line.to_s}</a>"
|
172
176
|
end
|
173
177
|
else
|
174
178
|
proc { |line| line.to_s } # :to_s.to_proc in Ruby 1.8.7+
|
@@ -0,0 +1,523 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
#
|
3
|
+
# @file
|
4
|
+
# @brief
|
5
|
+
# @author ongaeshi
|
6
|
+
# @date 2012/03/18
|
7
|
+
|
8
|
+
require 'rubygems'
|
9
|
+
require 'coderay/scanner'
|
10
|
+
|
11
|
+
# coderay-1.0.5/lib/coderay/scanners/php.rb
|
12
|
+
module CodeRay
|
13
|
+
module Scanners
|
14
|
+
|
15
|
+
load :html
|
16
|
+
|
17
|
+
# Scanner for PHP.
|
18
|
+
#
|
19
|
+
# Original by Stefan Walk.
|
20
|
+
class PHP_UTF8 < Scanner
|
21
|
+
|
22
|
+
# register_for :php
|
23
|
+
register_for :php_utf8 # customize
|
24
|
+
file_extension 'php'
|
25
|
+
# encoding 'BINARY'
|
26
|
+
encoding 'UTF-8' # customize
|
27
|
+
|
28
|
+
KINDS_NOT_LOC = HTML::KINDS_NOT_LOC
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def setup
|
33
|
+
@html_scanner = CodeRay.scanner :html, :tokens => @tokens, :keep_tokens => true, :keep_state => true
|
34
|
+
end
|
35
|
+
|
36
|
+
def reset_instance
|
37
|
+
super
|
38
|
+
@html_scanner.reset
|
39
|
+
end
|
40
|
+
|
41
|
+
module Words # :nodoc:
|
42
|
+
|
43
|
+
# according to http://www.php.net/manual/en/reserved.keywords.php
|
44
|
+
KEYWORDS = %w[
|
45
|
+
abstract and array as break case catch class clone const continue declare default do else elseif
|
46
|
+
enddeclare endfor endforeach endif endswitch endwhile extends final for foreach function global
|
47
|
+
goto if implements interface instanceof namespace new or private protected public static switch
|
48
|
+
throw try use var while xor
|
49
|
+
cfunction old_function
|
50
|
+
]
|
51
|
+
|
52
|
+
TYPES = %w[ int integer float double bool boolean string array object resource ]
|
53
|
+
|
54
|
+
LANGUAGE_CONSTRUCTS = %w[
|
55
|
+
die echo empty exit eval include include_once isset list
|
56
|
+
require require_once return print unset
|
57
|
+
]
|
58
|
+
|
59
|
+
CLASSES = %w[ Directory stdClass __PHP_Incomplete_Class exception php_user_filter Closure ]
|
60
|
+
|
61
|
+
# according to http://php.net/quickref.php on 2009-04-21;
|
62
|
+
# all functions with _ excluded (module functions) and selected additional functions
|
63
|
+
BUILTIN_FUNCTIONS = %w[
|
64
|
+
abs acos acosh addcslashes addslashes aggregate array arsort ascii2ebcdic asin asinh asort assert atan atan2
|
65
|
+
atanh basename bcadd bccomp bcdiv bcmod bcmul bcpow bcpowmod bcscale bcsqrt bcsub bin2hex bindec
|
66
|
+
bindtextdomain bzclose bzcompress bzdecompress bzerrno bzerror bzerrstr bzflush bzopen bzread bzwrite
|
67
|
+
calculhmac ceil chdir checkdate checkdnsrr chgrp chmod chop chown chr chroot clearstatcache closedir closelog
|
68
|
+
compact constant copy cos cosh count crc32 crypt current date dcgettext dcngettext deaggregate decbin dechex
|
69
|
+
decoct define defined deg2rad delete dgettext die dirname diskfreespace dl dngettext doubleval each
|
70
|
+
ebcdic2ascii echo empty end ereg eregi escapeshellarg escapeshellcmd eval exec exit exp explode expm1 extract
|
71
|
+
fclose feof fflush fgetc fgetcsv fgets fgetss file fileatime filectime filegroup fileinode filemtime fileowner
|
72
|
+
fileperms filepro filesize filetype floatval flock floor flush fmod fnmatch fopen fpassthru fprintf fputcsv
|
73
|
+
fputs fread frenchtojd fscanf fseek fsockopen fstat ftell ftok ftruncate fwrite getallheaders getcwd getdate
|
74
|
+
getenv gethostbyaddr gethostbyname gethostbynamel getimagesize getlastmod getmxrr getmygid getmyinode getmypid
|
75
|
+
getmyuid getopt getprotobyname getprotobynumber getrandmax getrusage getservbyname getservbyport gettext
|
76
|
+
gettimeofday gettype glob gmdate gmmktime gmstrftime gregoriantojd gzclose gzcompress gzdecode gzdeflate
|
77
|
+
gzencode gzeof gzfile gzgetc gzgets gzgetss gzinflate gzopen gzpassthru gzputs gzread gzrewind gzseek gztell
|
78
|
+
gzuncompress gzwrite hash header hebrev hebrevc hexdec htmlentities htmlspecialchars hypot iconv idate
|
79
|
+
implode include intval ip2long iptcembed iptcparse isset
|
80
|
+
jddayofweek jdmonthname jdtofrench jdtogregorian jdtojewish jdtojulian jdtounix jewishtojd join jpeg2wbmp
|
81
|
+
juliantojd key krsort ksort lcfirst lchgrp lchown levenshtein link linkinfo list localeconv localtime log
|
82
|
+
log10 log1p long2ip lstat ltrim mail main max md5 metaphone mhash microtime min mkdir mktime msql natcasesort
|
83
|
+
natsort next ngettext nl2br nthmac octdec opendir openlog
|
84
|
+
ord overload pack passthru pathinfo pclose pfsockopen phpcredits phpinfo phpversion pi png2wbmp popen pos pow
|
85
|
+
prev print printf putenv quotemeta rad2deg rand range rawurldecode rawurlencode readdir readfile readgzfile
|
86
|
+
readline readlink realpath recode rename require reset rewind rewinddir rmdir round rsort rtrim scandir
|
87
|
+
serialize setcookie setlocale setrawcookie settype sha1 shuffle signeurlpaiement sin sinh sizeof sleep snmpget
|
88
|
+
snmpgetnext snmprealwalk snmpset snmpwalk snmpwalkoid sort soundex split spliti sprintf sqrt srand sscanf stat
|
89
|
+
strcasecmp strchr strcmp strcoll strcspn strftime stripcslashes stripos stripslashes stristr strlen
|
90
|
+
strnatcasecmp strnatcmp strncasecmp strncmp strpbrk strpos strptime strrchr strrev strripos strrpos strspn
|
91
|
+
strstr strtok strtolower strtotime strtoupper strtr strval substr symlink syslog system tan tanh tempnam
|
92
|
+
textdomain time tmpfile touch trim uasort ucfirst ucwords uksort umask uniqid unixtojd unlink unpack
|
93
|
+
unserialize unset urldecode urlencode usleep usort vfprintf virtual vprintf vsprintf wordwrap
|
94
|
+
array_change_key_case array_chunk array_combine array_count_values array_diff array_diff_assoc
|
95
|
+
array_diff_key array_diff_uassoc array_diff_ukey array_fill array_fill_keys array_filter array_flip
|
96
|
+
array_intersect array_intersect_assoc array_intersect_key array_intersect_uassoc array_intersect_ukey
|
97
|
+
array_key_exists array_keys array_map array_merge array_merge_recursive array_multisort array_pad
|
98
|
+
array_pop array_product array_push array_rand array_reduce array_reverse array_search array_shift
|
99
|
+
array_slice array_splice array_sum array_udiff array_udiff_assoc array_udiff_uassoc array_uintersect
|
100
|
+
array_uintersect_assoc array_uintersect_uassoc array_unique array_unshift array_values array_walk
|
101
|
+
array_walk_recursive
|
102
|
+
assert_options base_convert base64_decode base64_encode
|
103
|
+
chunk_split class_exists class_implements class_parents
|
104
|
+
count_chars debug_backtrace debug_print_backtrace debug_zval_dump
|
105
|
+
error_get_last error_log error_reporting extension_loaded
|
106
|
+
file_exists file_get_contents file_put_contents load_file
|
107
|
+
func_get_arg func_get_args func_num_args function_exists
|
108
|
+
get_browser get_called_class get_cfg_var get_class get_class_methods get_class_vars
|
109
|
+
get_current_user get_declared_classes get_declared_interfaces get_defined_constants
|
110
|
+
get_defined_functions get_defined_vars get_extension_funcs get_headers get_html_translation_table
|
111
|
+
get_include_path get_included_files get_loaded_extensions get_magic_quotes_gpc get_magic_quotes_runtime
|
112
|
+
get_meta_tags get_object_vars get_parent_class get_required_filesget_resource_type
|
113
|
+
gc_collect_cycles gc_disable gc_enable gc_enabled
|
114
|
+
halt_compiler headers_list headers_sent highlight_file highlight_string
|
115
|
+
html_entity_decode htmlspecialchars_decode
|
116
|
+
in_array include_once inclued_get_data
|
117
|
+
is_a is_array is_binary is_bool is_buffer is_callable is_dir is_double is_executable is_file is_finite
|
118
|
+
is_float is_infinite is_int is_integer is_link is_long is_nan is_null is_numeric is_object is_readable
|
119
|
+
is_real is_resource is_scalar is_soap_fault is_string is_subclass_of is_unicode is_uploaded_file
|
120
|
+
is_writable is_writeable
|
121
|
+
locale_get_default locale_set_default
|
122
|
+
number_format override_function parse_str parse_url
|
123
|
+
php_check_syntax php_ini_loaded_file php_ini_scanned_files php_logo_guid php_sapi_name
|
124
|
+
php_strip_whitespace php_uname
|
125
|
+
preg_filter preg_grep preg_last_error preg_match preg_match_all preg_quote preg_replace
|
126
|
+
preg_replace_callback preg_split print_r
|
127
|
+
require_once register_shutdown_function register_tick_function
|
128
|
+
set_error_handler set_exception_handler set_file_buffer set_include_path
|
129
|
+
set_magic_quotes_runtime set_time_limit shell_exec
|
130
|
+
str_getcsv str_ireplace str_pad str_repeat str_replace str_rot13 str_shuffle str_split str_word_count
|
131
|
+
strip_tags substr_compare substr_count substr_replace
|
132
|
+
time_nanosleep time_sleep_until
|
133
|
+
token_get_all token_name trigger_error
|
134
|
+
unregister_tick_function use_soap_error_handler user_error
|
135
|
+
utf8_decode utf8_encode var_dump var_export
|
136
|
+
version_compare
|
137
|
+
zend_logo_guid zend_thread_id zend_version
|
138
|
+
create_function call_user_func_array
|
139
|
+
posix_access posix_ctermid posix_get_last_error posix_getcwd posix_getegid
|
140
|
+
posix_geteuid posix_getgid posix_getgrgid posix_getgrnam posix_getgroups
|
141
|
+
posix_getlogin posix_getpgid posix_getpgrp posix_getpid posix_getppid
|
142
|
+
posix_getpwnam posix_getpwuid posix_getrlimit posix_getsid posix_getuid
|
143
|
+
posix_initgroups posix_isatty posix_kill posix_mkfifo posix_mknod
|
144
|
+
posix_setegid posix_seteuid posix_setgid posix_setpgid posix_setsid
|
145
|
+
posix_setuid posix_strerror posix_times posix_ttyname posix_uname
|
146
|
+
pcntl_alarm pcntl_exec pcntl_fork pcntl_getpriority pcntl_setpriority
|
147
|
+
pcntl_signal pcntl_signal_dispatch pcntl_sigprocmask pcntl_sigtimedwait
|
148
|
+
pcntl_sigwaitinfo pcntl_wait pcntl_waitpid pcntl_wexitstatus pcntl_wifexited
|
149
|
+
pcntl_wifsignaled pcntl_wifstopped pcntl_wstopsig pcntl_wtermsig
|
150
|
+
]
|
151
|
+
# TODO: more built-in PHP functions?
|
152
|
+
|
153
|
+
EXCEPTIONS = %w[
|
154
|
+
E_ERROR E_WARNING E_PARSE E_NOTICE E_CORE_ERROR E_CORE_WARNING E_COMPILE_ERROR E_COMPILE_WARNING
|
155
|
+
E_USER_ERROR E_USER_WARNING E_USER_NOTICE E_DEPRECATED E_USER_DEPRECATED E_ALL E_STRICT
|
156
|
+
]
|
157
|
+
|
158
|
+
CONSTANTS = %w[
|
159
|
+
null true false self parent
|
160
|
+
__LINE__ __DIR__ __FILE__ __LINE__
|
161
|
+
__CLASS__ __NAMESPACE__ __METHOD__ __FUNCTION__
|
162
|
+
PHP_VERSION PHP_MAJOR_VERSION PHP_MINOR_VERSION PHP_RELEASE_VERSION PHP_VERSION_ID PHP_EXTRA_VERSION PHP_ZTS
|
163
|
+
PHP_DEBUG PHP_MAXPATHLEN PHP_OS PHP_SAPI PHP_EOL PHP_INT_MAX PHP_INT_SIZE DEFAULT_INCLUDE_PATH
|
164
|
+
PEAR_INSTALL_DIR PEAR_EXTENSION_DIR PHP_EXTENSION_DIR PHP_PREFIX PHP_BINDIR PHP_LIBDIR PHP_DATADIR
|
165
|
+
PHP_SYSCONFDIR PHP_LOCALSTATEDIR PHP_CONFIG_FILE_PATH PHP_CONFIG_FILE_SCAN_DIR PHP_SHLIB_SUFFIX
|
166
|
+
PHP_OUTPUT_HANDLER_START PHP_OUTPUT_HANDLER_CONT PHP_OUTPUT_HANDLER_END
|
167
|
+
__COMPILER_HALT_OFFSET__
|
168
|
+
EXTR_OVERWRITE EXTR_SKIP EXTR_PREFIX_SAME EXTR_PREFIX_ALL EXTR_PREFIX_INVALID EXTR_PREFIX_IF_EXISTS
|
169
|
+
EXTR_IF_EXISTS SORT_ASC SORT_DESC SORT_REGULAR SORT_NUMERIC SORT_STRING CASE_LOWER CASE_UPPER COUNT_NORMAL
|
170
|
+
COUNT_RECURSIVE ASSERT_ACTIVE ASSERT_CALLBACK ASSERT_BAIL ASSERT_WARNING ASSERT_QUIET_EVAL CONNECTION_ABORTED
|
171
|
+
CONNECTION_NORMAL CONNECTION_TIMEOUT INI_USER INI_PERDIR INI_SYSTEM INI_ALL M_E M_LOG2E M_LOG10E M_LN2 M_LN10
|
172
|
+
M_PI M_PI_2 M_PI_4 M_1_PI M_2_PI M_2_SQRTPI M_SQRT2 M_SQRT1_2 CRYPT_SALT_LENGTH CRYPT_STD_DES CRYPT_EXT_DES
|
173
|
+
CRYPT_MD5 CRYPT_BLOWFISH DIRECTORY_SEPARATOR SEEK_SET SEEK_CUR SEEK_END LOCK_SH LOCK_EX LOCK_UN LOCK_NB
|
174
|
+
HTML_SPECIALCHARS HTML_ENTITIES ENT_COMPAT ENT_QUOTES ENT_NOQUOTES INFO_GENERAL INFO_CREDITS
|
175
|
+
INFO_CONFIGURATION INFO_MODULES INFO_ENVIRONMENT INFO_VARIABLES INFO_LICENSE INFO_ALL CREDITS_GROUP
|
176
|
+
CREDITS_GENERAL CREDITS_SAPI CREDITS_MODULES CREDITS_DOCS CREDITS_FULLPAGE CREDITS_QA CREDITS_ALL STR_PAD_LEFT
|
177
|
+
STR_PAD_RIGHT STR_PAD_BOTH PATHINFO_DIRNAME PATHINFO_BASENAME PATHINFO_EXTENSION PATH_SEPARATOR CHAR_MAX
|
178
|
+
LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_ALL LC_MESSAGES ABDAY_1 ABDAY_2 ABDAY_3 ABDAY_4 ABDAY_5
|
179
|
+
ABDAY_6 ABDAY_7 DAY_1 DAY_2 DAY_3 DAY_4 DAY_5 DAY_6 DAY_7 ABMON_1 ABMON_2 ABMON_3 ABMON_4 ABMON_5 ABMON_6
|
180
|
+
ABMON_7 ABMON_8 ABMON_9 ABMON_10 ABMON_11 ABMON_12 MON_1 MON_2 MON_3 MON_4 MON_5 MON_6 MON_7 MON_8 MON_9
|
181
|
+
MON_10 MON_11 MON_12 AM_STR PM_STR D_T_FMT D_FMT T_FMT T_FMT_AMPM ERA ERA_YEAR ERA_D_T_FMT ERA_D_FMT ERA_T_FMT
|
182
|
+
ALT_DIGITS INT_CURR_SYMBOL CURRENCY_SYMBOL CRNCYSTR MON_DECIMAL_POINT MON_THOUSANDS_SEP MON_GROUPING
|
183
|
+
POSITIVE_SIGN NEGATIVE_SIGN INT_FRAC_DIGITS FRAC_DIGITS P_CS_PRECEDES P_SEP_BY_SPACE N_CS_PRECEDES
|
184
|
+
N_SEP_BY_SPACE P_SIGN_POSN N_SIGN_POSN DECIMAL_POINT RADIXCHAR THOUSANDS_SEP THOUSEP GROUPING YESEXPR NOEXPR
|
185
|
+
YESSTR NOSTR CODESET LOG_EMERG LOG_ALERT LOG_CRIT LOG_ERR LOG_WARNING LOG_NOTICE LOG_INFO LOG_DEBUG LOG_KERN
|
186
|
+
LOG_USER LOG_MAIL LOG_DAEMON LOG_AUTH LOG_SYSLOG LOG_LPR LOG_NEWS LOG_UUCP LOG_CRON LOG_AUTHPRIV LOG_LOCAL0
|
187
|
+
LOG_LOCAL1 LOG_LOCAL2 LOG_LOCAL3 LOG_LOCAL4 LOG_LOCAL5 LOG_LOCAL6 LOG_LOCAL7 LOG_PID LOG_CONS LOG_ODELAY
|
188
|
+
LOG_NDELAY LOG_NOWAIT LOG_PERROR
|
189
|
+
]
|
190
|
+
|
191
|
+
PREDEFINED = %w[
|
192
|
+
$GLOBALS $_SERVER $_GET $_POST $_FILES $_REQUEST $_SESSION $_ENV
|
193
|
+
$_COOKIE $php_errormsg $HTTP_RAW_POST_DATA $http_response_header
|
194
|
+
$argc $argv
|
195
|
+
]
|
196
|
+
|
197
|
+
IDENT_KIND = WordList::CaseIgnoring.new(:ident).
|
198
|
+
add(KEYWORDS, :keyword).
|
199
|
+
add(TYPES, :predefined_type).
|
200
|
+
add(LANGUAGE_CONSTRUCTS, :keyword).
|
201
|
+
add(BUILTIN_FUNCTIONS, :predefined).
|
202
|
+
add(CLASSES, :predefined_constant).
|
203
|
+
add(EXCEPTIONS, :exception).
|
204
|
+
add(CONSTANTS, :predefined_constant)
|
205
|
+
|
206
|
+
VARIABLE_KIND = WordList.new(:local_variable).
|
207
|
+
add(PREDEFINED, :predefined)
|
208
|
+
end
|
209
|
+
|
210
|
+
module RE # :nodoc:
|
211
|
+
|
212
|
+
PHP_START = /
|
213
|
+
<script\s+[^>]*?language\s*=\s*"php"[^>]*?> |
|
214
|
+
<script\s+[^>]*?language\s*=\s*'php'[^>]*?> |
|
215
|
+
<\?php\d? |
|
216
|
+
<\?(?!xml)
|
217
|
+
/xi
|
218
|
+
|
219
|
+
PHP_END = %r!
|
220
|
+
</script> |
|
221
|
+
\?>
|
222
|
+
!xi
|
223
|
+
|
224
|
+
HTML_INDICATOR = /<!DOCTYPE html|<(?:html|body|div|p)[> ]/i
|
225
|
+
|
226
|
+
# IDENTIFIER = /[a-z_\x7f-\xFF][a-z0-9_\x7f-\xFF]*/i
|
227
|
+
IDENTIFIER = /[a-z_][a-z0-9_]*/i # customize
|
228
|
+
VARIABLE = /\$#{IDENTIFIER}/
|
229
|
+
|
230
|
+
OPERATOR = /
|
231
|
+
\.(?!\d)=? | # dot that is not decimal point, string concatenation
|
232
|
+
&& | \|\| | # logic
|
233
|
+
:: | -> | => | # scope, member, dictionary
|
234
|
+
\\(?!\n) | # namespace
|
235
|
+
\+\+ | -- | # increment, decrement
|
236
|
+
[,;?:()\[\]{}] | # simple delimiters
|
237
|
+
[-+*\/%&|^]=? | # ordinary math, binary logic, assignment shortcuts
|
238
|
+
[~$] | # whatever
|
239
|
+
=& | # reference assignment
|
240
|
+
[=!]=?=? | <> | # comparison and assignment
|
241
|
+
<<=? | >>=? | [<>]=? # comparison and shift
|
242
|
+
/x
|
243
|
+
|
244
|
+
end
|
245
|
+
|
246
|
+
protected
|
247
|
+
|
248
|
+
def scan_tokens encoder, options
|
249
|
+
|
250
|
+
if check(RE::PHP_START) || # starts with <?
|
251
|
+
(match?(/\s*<\S/) && check(/.{1,1000}#{RE::PHP_START}/om)) || # starts with tag and contains <?
|
252
|
+
check(/.{0,1000}#{RE::HTML_INDICATOR}/om) ||
|
253
|
+
check(/.{1,100}#{RE::PHP_START}/om) # PHP start after max 100 chars
|
254
|
+
# is HTML with embedded PHP, so start with HTML
|
255
|
+
states = [:initial]
|
256
|
+
else
|
257
|
+
# is just PHP, so start with PHP surrounded by HTML
|
258
|
+
states = [:initial, :php]
|
259
|
+
end
|
260
|
+
|
261
|
+
label_expected = true
|
262
|
+
case_expected = false
|
263
|
+
|
264
|
+
heredoc_delimiter = nil
|
265
|
+
delimiter = nil
|
266
|
+
modifier = nil
|
267
|
+
|
268
|
+
until eos?
|
269
|
+
|
270
|
+
case states.last
|
271
|
+
|
272
|
+
when :initial # HTML
|
273
|
+
if match = scan(RE::PHP_START)
|
274
|
+
encoder.text_token match, :inline_delimiter
|
275
|
+
label_expected = true
|
276
|
+
states << :php
|
277
|
+
else
|
278
|
+
match = scan_until(/(?=#{RE::PHP_START})/o) || scan_rest
|
279
|
+
@html_scanner.tokenize match unless match.empty?
|
280
|
+
end
|
281
|
+
|
282
|
+
when :php
|
283
|
+
if match = scan(/\s+/)
|
284
|
+
encoder.text_token match, :space
|
285
|
+
|
286
|
+
elsif match = scan(%r! (?m: \/\* (?: .*? \*\/ | .* ) ) | (?://|\#) .*? (?=#{RE::PHP_END}|$) !xo)
|
287
|
+
encoder.text_token match, :comment
|
288
|
+
|
289
|
+
elsif match = scan(RE::IDENTIFIER)
|
290
|
+
kind = Words::IDENT_KIND[match]
|
291
|
+
if kind == :ident && label_expected && check(/:(?!:)/)
|
292
|
+
kind = :label
|
293
|
+
label_expected = true
|
294
|
+
else
|
295
|
+
label_expected = false
|
296
|
+
if kind == :ident && match =~ /^[A-Z]/
|
297
|
+
kind = :constant
|
298
|
+
elsif kind == :keyword
|
299
|
+
case match
|
300
|
+
when 'class'
|
301
|
+
states << :class_expected
|
302
|
+
when 'function'
|
303
|
+
states << :function_expected
|
304
|
+
when 'case', 'default'
|
305
|
+
case_expected = true
|
306
|
+
end
|
307
|
+
elsif match == 'b' && check(/['"]/) # binary string literal
|
308
|
+
modifier = match
|
309
|
+
next
|
310
|
+
end
|
311
|
+
end
|
312
|
+
encoder.text_token match, kind
|
313
|
+
|
314
|
+
elsif match = scan(/(?:\d+\.\d*|\d*\.\d+)(?:e[-+]?\d+)?|\d+e[-+]?\d+/i)
|
315
|
+
label_expected = false
|
316
|
+
encoder.text_token match, :float
|
317
|
+
|
318
|
+
elsif match = scan(/0x[0-9a-fA-F]+/)
|
319
|
+
label_expected = false
|
320
|
+
encoder.text_token match, :hex
|
321
|
+
|
322
|
+
elsif match = scan(/\d+/)
|
323
|
+
label_expected = false
|
324
|
+
encoder.text_token match, :integer
|
325
|
+
|
326
|
+
elsif match = scan(/['"`]/)
|
327
|
+
encoder.begin_group :string
|
328
|
+
if modifier
|
329
|
+
encoder.text_token modifier, :modifier
|
330
|
+
modifier = nil
|
331
|
+
end
|
332
|
+
delimiter = match
|
333
|
+
encoder.text_token match, :delimiter
|
334
|
+
states.push match == "'" ? :sqstring : :dqstring
|
335
|
+
|
336
|
+
elsif match = scan(RE::VARIABLE)
|
337
|
+
label_expected = false
|
338
|
+
encoder.text_token match, Words::VARIABLE_KIND[match]
|
339
|
+
|
340
|
+
elsif match = scan(/\{/)
|
341
|
+
encoder.text_token match, :operator
|
342
|
+
label_expected = true
|
343
|
+
states.push :php
|
344
|
+
|
345
|
+
elsif match = scan(/\}/)
|
346
|
+
if states.size == 1
|
347
|
+
encoder.text_token match, :error
|
348
|
+
else
|
349
|
+
states.pop
|
350
|
+
if states.last.is_a?(::Array)
|
351
|
+
delimiter = states.last[1]
|
352
|
+
states[-1] = states.last[0]
|
353
|
+
encoder.text_token match, :delimiter
|
354
|
+
encoder.end_group :inline
|
355
|
+
else
|
356
|
+
encoder.text_token match, :operator
|
357
|
+
label_expected = true
|
358
|
+
end
|
359
|
+
end
|
360
|
+
|
361
|
+
elsif match = scan(/@/)
|
362
|
+
label_expected = false
|
363
|
+
encoder.text_token match, :exception
|
364
|
+
|
365
|
+
elsif match = scan(RE::PHP_END)
|
366
|
+
encoder.text_token match, :inline_delimiter
|
367
|
+
states = [:initial]
|
368
|
+
|
369
|
+
elsif match = scan(/<<<(?:(#{RE::IDENTIFIER})|"(#{RE::IDENTIFIER})"|'(#{RE::IDENTIFIER})')/o)
|
370
|
+
encoder.begin_group :string
|
371
|
+
# warn 'heredoc in heredoc?' if heredoc_delimiter
|
372
|
+
heredoc_delimiter = Regexp.escape(self[1] || self[2] || self[3])
|
373
|
+
encoder.text_token match, :delimiter
|
374
|
+
states.push self[3] ? :sqstring : :dqstring
|
375
|
+
heredoc_delimiter = /#{heredoc_delimiter}(?=;?$)/
|
376
|
+
|
377
|
+
elsif match = scan(/#{RE::OPERATOR}/o)
|
378
|
+
label_expected = match == ';'
|
379
|
+
if case_expected
|
380
|
+
label_expected = true if match == ':'
|
381
|
+
case_expected = false
|
382
|
+
end
|
383
|
+
encoder.text_token match, :operator
|
384
|
+
|
385
|
+
else
|
386
|
+
encoder.text_token getch, :error
|
387
|
+
|
388
|
+
end
|
389
|
+
|
390
|
+
when :sqstring
|
391
|
+
if match = scan(heredoc_delimiter ? /[^\\\n]+/ : /[^'\\]+/)
|
392
|
+
encoder.text_token match, :content
|
393
|
+
elsif !heredoc_delimiter && match = scan(/'/)
|
394
|
+
encoder.text_token match, :delimiter
|
395
|
+
encoder.end_group :string
|
396
|
+
delimiter = nil
|
397
|
+
label_expected = false
|
398
|
+
states.pop
|
399
|
+
elsif heredoc_delimiter && match = scan(/\n/)
|
400
|
+
if scan heredoc_delimiter
|
401
|
+
encoder.text_token "\n", :content
|
402
|
+
encoder.text_token matched, :delimiter
|
403
|
+
encoder.end_group :string
|
404
|
+
heredoc_delimiter = nil
|
405
|
+
label_expected = false
|
406
|
+
states.pop
|
407
|
+
else
|
408
|
+
encoder.text_token match, :content
|
409
|
+
end
|
410
|
+
elsif match = scan(heredoc_delimiter ? /\\\\/ : /\\[\\'\n]/)
|
411
|
+
encoder.text_token match, :char
|
412
|
+
elsif match = scan(/\\./m)
|
413
|
+
encoder.text_token match, :content
|
414
|
+
elsif match = scan(/\\/)
|
415
|
+
encoder.text_token match, :error
|
416
|
+
else
|
417
|
+
states.pop
|
418
|
+
end
|
419
|
+
|
420
|
+
when :dqstring
|
421
|
+
if match = scan(heredoc_delimiter ? /[^${\\\n]+/ : (delimiter == '"' ? /[^"${\\]+/ : /[^`${\\]+/))
|
422
|
+
encoder.text_token match, :content
|
423
|
+
elsif !heredoc_delimiter && match = scan(delimiter == '"' ? /"/ : /`/)
|
424
|
+
encoder.text_token match, :delimiter
|
425
|
+
encoder.end_group :string
|
426
|
+
delimiter = nil
|
427
|
+
label_expected = false
|
428
|
+
states.pop
|
429
|
+
elsif heredoc_delimiter && match = scan(/\n/)
|
430
|
+
if scan heredoc_delimiter
|
431
|
+
encoder.text_token "\n", :content
|
432
|
+
encoder.text_token matched, :delimiter
|
433
|
+
encoder.end_group :string
|
434
|
+
heredoc_delimiter = nil
|
435
|
+
label_expected = false
|
436
|
+
states.pop
|
437
|
+
else
|
438
|
+
encoder.text_token match, :content
|
439
|
+
end
|
440
|
+
elsif match = scan(/\\(?:x[0-9A-Fa-f]{1,2}|[0-7]{1,3})/)
|
441
|
+
encoder.text_token match, :char
|
442
|
+
elsif match = scan(heredoc_delimiter ? /\\[nrtvf\\$]/ : (delimiter == '"' ? /\\[nrtvf\\$"]/ : /\\[nrtvf\\$`]/))
|
443
|
+
encoder.text_token match, :char
|
444
|
+
elsif match = scan(/\\./m)
|
445
|
+
encoder.text_token match, :content
|
446
|
+
elsif match = scan(/\\/)
|
447
|
+
encoder.text_token match, :error
|
448
|
+
elsif match = scan(/#{RE::VARIABLE}/o)
|
449
|
+
if check(/\[#{RE::IDENTIFIER}\]/o)
|
450
|
+
encoder.begin_group :inline
|
451
|
+
encoder.text_token match, :local_variable
|
452
|
+
encoder.text_token scan(/\[/), :operator
|
453
|
+
encoder.text_token scan(/#{RE::IDENTIFIER}/o), :ident
|
454
|
+
encoder.text_token scan(/\]/), :operator
|
455
|
+
encoder.end_group :inline
|
456
|
+
elsif check(/\[/)
|
457
|
+
match << scan(/\[['"]?#{RE::IDENTIFIER}?['"]?\]?/o)
|
458
|
+
encoder.text_token match, :error
|
459
|
+
elsif check(/->#{RE::IDENTIFIER}/o)
|
460
|
+
encoder.begin_group :inline
|
461
|
+
encoder.text_token match, :local_variable
|
462
|
+
encoder.text_token scan(/->/), :operator
|
463
|
+
encoder.text_token scan(/#{RE::IDENTIFIER}/o), :ident
|
464
|
+
encoder.end_group :inline
|
465
|
+
elsif check(/->/)
|
466
|
+
match << scan(/->/)
|
467
|
+
encoder.text_token match, :error
|
468
|
+
else
|
469
|
+
encoder.text_token match, :local_variable
|
470
|
+
end
|
471
|
+
elsif match = scan(/\{/)
|
472
|
+
if check(/\$/)
|
473
|
+
encoder.begin_group :inline
|
474
|
+
states[-1] = [states.last, delimiter]
|
475
|
+
delimiter = nil
|
476
|
+
states.push :php
|
477
|
+
encoder.text_token match, :delimiter
|
478
|
+
else
|
479
|
+
encoder.text_token match, :content
|
480
|
+
end
|
481
|
+
elsif match = scan(/\$\{#{RE::IDENTIFIER}\}/o)
|
482
|
+
encoder.text_token match, :local_variable
|
483
|
+
elsif match = scan(/\$/)
|
484
|
+
encoder.text_token match, :content
|
485
|
+
else
|
486
|
+
states.pop
|
487
|
+
end
|
488
|
+
|
489
|
+
when :class_expected
|
490
|
+
if match = scan(/\s+/)
|
491
|
+
encoder.text_token match, :space
|
492
|
+
elsif match = scan(/#{RE::IDENTIFIER}/o)
|
493
|
+
encoder.text_token match, :class
|
494
|
+
states.pop
|
495
|
+
else
|
496
|
+
states.pop
|
497
|
+
end
|
498
|
+
|
499
|
+
when :function_expected
|
500
|
+
if match = scan(/\s+/)
|
501
|
+
encoder.text_token match, :space
|
502
|
+
elsif match = scan(/&/)
|
503
|
+
encoder.text_token match, :operator
|
504
|
+
elsif match = scan(/#{RE::IDENTIFIER}/o)
|
505
|
+
encoder.text_token match, :function
|
506
|
+
states.pop
|
507
|
+
else
|
508
|
+
states.pop
|
509
|
+
end
|
510
|
+
|
511
|
+
else
|
512
|
+
raise_inspect 'Unknown state!', encoder, states
|
513
|
+
end
|
514
|
+
|
515
|
+
end
|
516
|
+
|
517
|
+
encoder
|
518
|
+
end
|
519
|
+
|
520
|
+
end
|
521
|
+
|
522
|
+
end
|
523
|
+
end
|
@@ -10,10 +10,12 @@ require 'coderay'
|
|
10
10
|
require 'coderay/helpers/file_type'
|
11
11
|
require 'milkode/common/util'
|
12
12
|
require 'milkode/cdweb/lib/coderay_html2'
|
13
|
+
require 'milkode/cdweb/lib/coderay_php_utf8'
|
13
14
|
|
14
15
|
module Milkode
|
15
16
|
class CodeRayWrapper
|
16
17
|
attr_reader :line_number_start
|
18
|
+
attr_reader :highlight_lines
|
17
19
|
|
18
20
|
def initialize(content, filename, match_lines = [])
|
19
21
|
@content = content
|
@@ -76,6 +78,8 @@ module Milkode
|
|
76
78
|
|
77
79
|
def file_type
|
78
80
|
case File.extname(@filename)
|
81
|
+
when ".php"
|
82
|
+
:php_utf8
|
79
83
|
when ".el"
|
80
84
|
# :scheme
|
81
85
|
CodeRay::FileType.fetch @filename, :plaintext
|
@@ -139,13 +139,15 @@ module Milkode
|
|
139
139
|
paths = records.map {|record|
|
140
140
|
DocumentRecord.new(record).shortpath.split("/")
|
141
141
|
}.find_all {|parts|
|
142
|
-
|
142
|
+
# 先頭フォルダ名が一致するものをピックアップ
|
143
|
+
parts.length > base_depth && parts[0, base_depth] == base_parts
|
143
144
|
}.map {|parts|
|
144
|
-
|
145
|
-
|
146
|
-
[path, is_file]
|
145
|
+
# [path, is_file]
|
146
|
+
[parts[0, base_depth + 1].join("/"), parts.length == base_depth + 1]
|
147
147
|
}.sort_by {|parts|
|
148
|
-
|
148
|
+
# 配列の比較を利用したディレクトリ優先ソート
|
149
|
+
# aaa, bbb/, aaa/, bbb -> [aaa/, bbb/, aaa, bbb]
|
150
|
+
[parts[1] ? 1 : 0, parts[0].downcase] # [is_file(int), path(downcase)]
|
149
151
|
}.uniq
|
150
152
|
|
151
153
|
paths
|
@@ -159,7 +161,9 @@ module Milkode
|
|
159
161
|
elsif (sort_kind)
|
160
162
|
sorted = @grndb.packages.sort(sort_kind)
|
161
163
|
else
|
162
|
-
|
164
|
+
# 大文字/小文字を無視してソートするため、速度を犠牲に
|
165
|
+
# sorted = @grndb.packages.sort("name", "ascending")
|
166
|
+
sorted = @grndb.packages.to_a.sort_by {|r| r.name.downcase}
|
163
167
|
end
|
164
168
|
|
165
169
|
sorted.map {|r| r.name}
|
@@ -197,7 +197,7 @@ EOF
|
|
197
197
|
url = "/home/" + record_link(record)
|
198
198
|
|
199
199
|
<<EOS
|
200
|
-
<dt class='result-record'><a href='#{url + "#n#{coderay.
|
200
|
+
<dt class='result-record'><a href='#{url + "#n#{coderay.highlight_lines[0]}"}'>#{Util::relative_path record.shortpath, @path}</a></dt>
|
201
201
|
<dd>
|
202
202
|
#{coderay.to_html_anchorlink(url)}
|
203
203
|
</dd>
|
@@ -222,7 +222,7 @@ EOS
|
|
222
222
|
EOS
|
223
223
|
end
|
224
224
|
|
225
|
-
def record_link(record)
|
225
|
+
def record_link(record)
|
226
226
|
Mkurl.new(record.shortpath, @params).inherit_query_shead
|
227
227
|
end
|
228
228
|
|
@@ -89,6 +89,17 @@ $(document).ready(function(){
|
|
89
89
|
update_package($("#updateOk").attr("milkode-package-name"));
|
90
90
|
return false;
|
91
91
|
});
|
92
|
+
|
93
|
+
var match = document.URL.match(/.+(#n\d+)$/);
|
94
|
+
if ( match ) {
|
95
|
+
$(match[1]).addClass("select-line");
|
96
|
+
} else {
|
97
|
+
$("#query").select();
|
98
|
+
}
|
99
|
+
|
100
|
+
$('#query').click(function(){
|
101
|
+
$(this).select();
|
102
|
+
});
|
92
103
|
});
|
93
104
|
|
94
105
|
function update_package(package_name)
|
@@ -111,3 +122,18 @@ function update_package(package_name)
|
|
111
122
|
}
|
112
123
|
);
|
113
124
|
}
|
125
|
+
|
126
|
+
function lineno_setup(path, lineno)
|
127
|
+
{
|
128
|
+
var n_lineno = "#n" + lineno;
|
129
|
+
|
130
|
+
var h = $('html, body');
|
131
|
+
var prev = h.scrollTop();
|
132
|
+
window.location.hash = n_lineno;
|
133
|
+
h.scrollTop(prev);
|
134
|
+
|
135
|
+
$(".code > pre > *").removeClass("select-line");
|
136
|
+
$(n_lineno).addClass("select-line");
|
137
|
+
$("#lineno-path").text(path + lineno);
|
138
|
+
$("#lineno-body").html($(n_lineno).html());
|
139
|
+
}
|
data/lib/milkode/cli.rb
CHANGED
@@ -8,7 +8,7 @@ require 'milkode/grep/cli_grep'
|
|
8
8
|
module Milkode
|
9
9
|
class CLI < Thor
|
10
10
|
class_option :help, :type => :boolean, :aliases => '-h', :desc => 'Help message.'
|
11
|
-
class_option :version, :type => :boolean, :
|
11
|
+
class_option :version, :type => :boolean, :desc => 'Show version.'
|
12
12
|
|
13
13
|
desc "init [db_dir]", "Initialize database directory. If db_dir is omitted"
|
14
14
|
option :default, :type => :boolean, :desc => "Init default db, ENV['MILKODE_DEFAULT_DIR'] or ~/.milkode."
|
@@ -52,11 +52,15 @@ EOF
|
|
52
52
|
end
|
53
53
|
|
54
54
|
desc "remove keyword_or_path1 [keyword_or_path2 ...]", "Remove package"
|
55
|
-
option :all, :type => :boolean, :desc => 'Remove all.'
|
55
|
+
option :all, :type => :boolean, :aliases => '-a', :desc => 'Remove all.'
|
56
56
|
option :force, :type => :boolean, :aliases => '-f', :desc => 'Force remove.'
|
57
57
|
option :verbose, :type => :boolean, :aliases => '-v', :desc => 'Be verbose.'
|
58
58
|
def remove(*args)
|
59
|
-
|
59
|
+
if args.empty? && !options[:all]
|
60
|
+
CLI.task_help(shell, "remove")
|
61
|
+
else
|
62
|
+
cdstk.remove(args, options)
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
desc "list [package1 package2 ...]", "List package"
|
@@ -98,8 +102,8 @@ EOF
|
|
98
102
|
|
99
103
|
desc "setdb [dbpath]", "Set default db to dbpath"
|
100
104
|
option :reset, :type => :boolean, :aliases => '--default', :desc => 'Reset to the system default database.'
|
101
|
-
def setdb(
|
102
|
-
cdstk.setdb(
|
105
|
+
def setdb(*args)
|
106
|
+
cdstk.setdb(args, options)
|
103
107
|
end
|
104
108
|
|
105
109
|
desc "mcd", "Generate `mcd' command"
|
@@ -59,6 +59,7 @@ module Milkode
|
|
59
59
|
{ :name => 'SVG' , :suffixs => ['svg'] },
|
60
60
|
{ :name => 'Tcl' , :suffixs => ['tcl'] },
|
61
61
|
{ :name => 'Text' , :suffixs => ['txt'] },
|
62
|
+
{ :name => 'Visual Studio' , :suffixs => ['csproj', 'vbproj', 'sln'] },
|
62
63
|
{ :name => 'XML' , :suffixs => ['xml'] },
|
63
64
|
{ :name => 'Yaml' , :suffixs => ['yml', 'yaml'] },
|
64
65
|
# { :name => '' , :suffixs => [] , :filenames => [] },
|
data/lib/milkode/common/util.rb
CHANGED
@@ -327,7 +327,13 @@ module Milkode
|
|
327
327
|
private
|
328
328
|
|
329
329
|
def load_content(filename)
|
330
|
-
|
330
|
+
str = File.read(filename)
|
331
|
+
begin
|
332
|
+
Kconv.kconv(str, Kconv::UTF8)
|
333
|
+
rescue ArgumentError
|
334
|
+
Util.warning_alert($stdout, "skip kconv. file size too big (or negative string size) : #{filename}.")
|
335
|
+
str
|
336
|
+
end
|
331
337
|
end
|
332
338
|
|
333
339
|
def package_expression(record, packages)
|
data/milkode.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{milkode}
|
8
|
-
s.version = "0.9.
|
8
|
+
s.version = "0.9.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["ongaeshi"]
|
12
|
-
s.date = %q{2012-
|
12
|
+
s.date = %q{2012-11-14}
|
13
13
|
s.description = %q{Line based local source code search engine & grep-command & web-app.}
|
14
14
|
s.email = %q{ongaeshi0621@gmail.com}
|
15
15
|
s.executables = ["gmilk", "milk"]
|
@@ -37,6 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
"lib/milkode/cdweb/cli_cdweb.rb",
|
38
38
|
"lib/milkode/cdweb/config.ru",
|
39
39
|
"lib/milkode/cdweb/lib/coderay_html2.rb",
|
40
|
+
"lib/milkode/cdweb/lib/coderay_php_utf8.rb",
|
40
41
|
"lib/milkode/cdweb/lib/coderay_wrapper.rb",
|
41
42
|
"lib/milkode/cdweb/lib/command.rb",
|
42
43
|
"lib/milkode/cdweb/lib/database.rb",
|
@@ -186,7 +187,7 @@ Gem::Specification.new do |s|
|
|
186
187
|
s.specification_version = 3
|
187
188
|
|
188
189
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
189
|
-
s.add_runtime_dependency(%q<termcolor>, [">= 1.2.0"])
|
190
|
+
s.add_runtime_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
|
190
191
|
s.add_runtime_dependency(%q<rroonga>, [">= 1.1.0"])
|
191
192
|
s.add_runtime_dependency(%q<rack>, [">= 1.3.4"])
|
192
193
|
s.add_runtime_dependency(%q<sinatra>, [">= 1.2.6"])
|
@@ -201,7 +202,7 @@ Gem::Specification.new do |s|
|
|
201
202
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
202
203
|
s.add_development_dependency(%q<rack-test>, [">= 0"])
|
203
204
|
else
|
204
|
-
s.add_dependency(%q<termcolor>, [">= 1.2.0"])
|
205
|
+
s.add_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
|
205
206
|
s.add_dependency(%q<rroonga>, [">= 1.1.0"])
|
206
207
|
s.add_dependency(%q<rack>, [">= 1.3.4"])
|
207
208
|
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
|
@@ -217,7 +218,7 @@ Gem::Specification.new do |s|
|
|
217
218
|
s.add_dependency(%q<rack-test>, [">= 0"])
|
218
219
|
end
|
219
220
|
else
|
220
|
-
s.add_dependency(%q<termcolor>, [">= 1.2.0"])
|
221
|
+
s.add_dependency(%q<termcolor>, [">= 1.2.0", "< 1.2.2"])
|
221
222
|
s.add_dependency(%q<rroonga>, [">= 1.1.0"])
|
222
223
|
s.add_dependency(%q<rack>, [">= 1.3.4"])
|
223
224
|
s.add_dependency(%q<sinatra>, [">= 1.2.6"])
|
data/test/test_plang_detector.rb
CHANGED
@@ -19,6 +19,7 @@ module Milkode
|
|
19
19
|
assert_equal 'Ruby' , PlangDetector.new('template.rb').name
|
20
20
|
assert_equal 'README' , PlangDetector.new('readme.txt').name
|
21
21
|
assert_equal 'JavaScript' , PlangDetector.new('main.js').name
|
22
|
+
assert_equal 'Visual Studio', PlangDetector.new('hoge.sln').name
|
22
23
|
end
|
23
24
|
|
24
25
|
def test_unknown
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milkode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
|
-
-
|
10
|
-
|
11
|
-
version: 0.9.3.1
|
9
|
+
- 4
|
10
|
+
version: 0.9.4
|
12
11
|
platform: ruby
|
13
12
|
authors:
|
14
13
|
- ongaeshi
|
@@ -16,7 +15,7 @@ autorequire:
|
|
16
15
|
bindir: bin
|
17
16
|
cert_chain: []
|
18
17
|
|
19
|
-
date: 2012-
|
18
|
+
date: 2012-11-14 00:00:00 +09:00
|
20
19
|
default_executable:
|
21
20
|
dependencies:
|
22
21
|
- !ruby/object:Gem::Dependency
|
@@ -34,6 +33,14 @@ dependencies:
|
|
34
33
|
- 2
|
35
34
|
- 0
|
36
35
|
version: 1.2.0
|
36
|
+
- - <
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
hash: 27
|
39
|
+
segments:
|
40
|
+
- 1
|
41
|
+
- 2
|
42
|
+
- 2
|
43
|
+
version: 1.2.2
|
37
44
|
requirement: *id001
|
38
45
|
- !ruby/object:Gem::Dependency
|
39
46
|
type: :runtime
|
@@ -267,6 +274,7 @@ files:
|
|
267
274
|
- lib/milkode/cdweb/cli_cdweb.rb
|
268
275
|
- lib/milkode/cdweb/config.ru
|
269
276
|
- lib/milkode/cdweb/lib/coderay_html2.rb
|
277
|
+
- lib/milkode/cdweb/lib/coderay_php_utf8.rb
|
270
278
|
- lib/milkode/cdweb/lib/coderay_wrapper.rb
|
271
279
|
- lib/milkode/cdweb/lib/command.rb
|
272
280
|
- lib/milkode/cdweb/lib/database.rb
|