filemanager 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/CHANGELOG +3 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README +32 -0
  4. data/Rakefile +30 -0
  5. data/lib/filemanager.rb +59 -0
  6. data/lib/filemanager/controller.rb +197 -0
  7. data/lib/locale.rb +183 -0
  8. data/lib/locale/base.rb +60 -0
  9. data/lib/locale/cgi.rb +103 -0
  10. data/lib/locale/jruby.rb +36 -0
  11. data/lib/locale/object.rb +233 -0
  12. data/lib/locale/posix.rb +22 -0
  13. data/lib/locale/win32.rb +49 -0
  14. data/lib/locale/win32_table.rb +235 -0
  15. data/rails/app/controllers/fm/filemanager_controller.rb +23 -0
  16. data/rails/app/helpers/fm/filemanager_helper.rb +61 -0
  17. data/rails/app/views/fm/filemanager/index.html.erb +509 -0
  18. data/rails/app/views/fm/filemanager/view.html.erb +67 -0
  19. data/rails/config/filemanager.yml +16 -0
  20. data/rails/fm_temp/temp +0 -0
  21. data/rails/public/filemanager/images/avi.gif +0 -0
  22. data/rails/public/filemanager/images/box.gif +0 -0
  23. data/rails/public/filemanager/images/bullet.gif +0 -0
  24. data/rails/public/filemanager/images/close.gif +0 -0
  25. data/rails/public/filemanager/images/closelabel.gif +0 -0
  26. data/rails/public/filemanager/images/doc.gif +0 -0
  27. data/rails/public/filemanager/images/donate-button.gif +0 -0
  28. data/rails/public/filemanager/images/download-icon.gif +0 -0
  29. data/rails/public/filemanager/images/folder.gif +0 -0
  30. data/rails/public/filemanager/images/gif.gif +0 -0
  31. data/rails/public/filemanager/images/htm.gif +0 -0
  32. data/rails/public/filemanager/images/html.gif +0 -0
  33. data/rails/public/filemanager/images/image-1.jpg +0 -0
  34. data/rails/public/filemanager/images/image.gif +0 -0
  35. data/rails/public/filemanager/images/jpg.gif +0 -0
  36. data/rails/public/filemanager/images/loading.gif +0 -0
  37. data/rails/public/filemanager/images/mov.gif +0 -0
  38. data/rails/public/filemanager/images/nextlabel.gif +0 -0
  39. data/rails/public/filemanager/images/pdf.gif +0 -0
  40. data/rails/public/filemanager/images/png.gif +0 -0
  41. data/rails/public/filemanager/images/ppt.gif +0 -0
  42. data/rails/public/filemanager/images/prevlabel.gif +0 -0
  43. data/rails/public/filemanager/images/rar.gif +0 -0
  44. data/rails/public/filemanager/images/rm.gif +0 -0
  45. data/rails/public/filemanager/images/rmvb.gif +0 -0
  46. data/rails/public/filemanager/images/separator.gif +0 -0
  47. data/rails/public/filemanager/images/spacer.gif +0 -0
  48. data/rails/public/filemanager/images/swf.gif +0 -0
  49. data/rails/public/filemanager/images/thumb-1.jpg +0 -0
  50. data/rails/public/filemanager/images/tool_copy.gif +0 -0
  51. data/rails/public/filemanager/images/tool_cut.gif +0 -0
  52. data/rails/public/filemanager/images/tool_del.gif +0 -0
  53. data/rails/public/filemanager/images/tool_folder.gif +0 -0
  54. data/rails/public/filemanager/images/tool_imagemanager.gif +0 -0
  55. data/rails/public/filemanager/images/tool_new.gif +0 -0
  56. data/rails/public/filemanager/images/tool_paste.gif +0 -0
  57. data/rails/public/filemanager/images/tool_props.gif +0 -0
  58. data/rails/public/filemanager/images/tool_refresh.gif +0 -0
  59. data/rails/public/filemanager/images/tool_unzip.gif +0 -0
  60. data/rails/public/filemanager/images/tool_upload.gif +0 -0
  61. data/rails/public/filemanager/images/tool_zip.gif +0 -0
  62. data/rails/public/filemanager/images/txt.gif +0 -0
  63. data/rails/public/filemanager/images/unknown.gif +0 -0
  64. data/rails/public/filemanager/images/wmv.gif +0 -0
  65. data/rails/public/filemanager/images/xls.gif +0 -0
  66. data/rails/public/filemanager/images/zip.gif +0 -0
  67. data/rails/public/filemanager/javascripts/builder.js +136 -0
  68. data/rails/public/filemanager/javascripts/effects.js +1122 -0
  69. data/rails/public/filemanager/javascripts/filemanager.js +6 -0
  70. data/rails/public/filemanager/javascripts/lang/en.js +31 -0
  71. data/rails/public/filemanager/javascripts/lang/zh_CN.js +31 -0
  72. data/rails/public/filemanager/javascripts/lightbox.js +497 -0
  73. data/rails/public/filemanager/javascripts/prototype.js +4221 -0
  74. data/rails/public/filemanager/javascripts/prototype_ext.js +117 -0
  75. data/rails/public/filemanager/javascripts/scriptaculous.js +58 -0
  76. data/rails/public/filemanager/javascripts/translate.js +42 -0
  77. data/rails/public/filemanager/stylesheets/filelist.css +147 -0
  78. data/rails/public/filemanager/stylesheets/general.css +135 -0
  79. data/rails/public/filemanager/stylesheets/lightbox.css +27 -0
  80. data/rails/public/fm_resources/resources.txt +1 -0
  81. metadata +147 -0
@@ -0,0 +1,60 @@
1
+ =begin
2
+ locale/posix.rb
3
+
4
+ Copyright (C) 2002-2007 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: base.rb,v 1.1 2007/11/08 16:57:49 mutoh Exp $
10
+ =end
11
+
12
+
13
+ module Locale
14
+ # Locale::SystemBase module. This module overrides from other concrete modules.
15
+ # This is a low-level class. Application shouldn't use this directly.
16
+ module SystemBase
17
+ @@default_locale = Locale::Object.new("C", nil, "UTF-8")
18
+
19
+ def default_locale # :nodoc:
20
+ @@default_locale
21
+ end
22
+
23
+ # Gets the charset of the locale.
24
+ # * locale: Locale::Object
25
+ # * Returns the charset of the locale
26
+ def get_charset(locale)
27
+ locale.charset || @@default_locale.charset
28
+ end
29
+
30
+ # Gets the system locale using setlocale and nl_langinfo.
31
+ # * Returns the system locale (Locale::Object).
32
+ def locale_from_env
33
+ locale = nil
34
+ # At least one environment valiables should be set on *nix system.
35
+ [ENV["LC_ALL"], ENV["LC_MESSAGES"], ENV["LANG"]].each do |loc|
36
+ if loc != nil and loc.size > 0
37
+ locale = Locale::Object.new(loc)
38
+ locale.charset ||= get_charset(locale)
39
+ break
40
+ end
41
+ end
42
+ locale
43
+ end
44
+
45
+ # Gets the system locale.
46
+ # * Returns the system locale (Locale::Object)
47
+ def system
48
+ locale_from_env || default_locale
49
+ end
50
+
51
+ # Gets the charset of the locale.
52
+ # * locale: Locale::Object
53
+ # * Returns: the charset of the locale
54
+ def charset
55
+ # locale parameter is ignored now.
56
+ system.charset
57
+ end
58
+ end
59
+ end
60
+
data/lib/locale/cgi.rb ADDED
@@ -0,0 +1,103 @@
1
+ =begin
2
+ locale/cgi.rb
3
+
4
+ Copyright (C) 2002-2007 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: cgi.rb,v 1.2 2007/11/08 16:44:22 mutoh Exp $
10
+ =end
11
+
12
+ require 'locale/base'
13
+
14
+ module Locale
15
+ # Locale::System module for CGI.
16
+ # This is a low-level class. Application shouldn't use this directly.
17
+ module SystemCGI
18
+ extend SystemBase
19
+
20
+ @@default_locale = Locale::Object.new("en", nil, "UTF-8")
21
+ @@cgi = nil
22
+
23
+ module_function
24
+ # Gets the default locale using setlocale and nl_langinfo.
25
+ # * Returns the system locale (Locale::Object).
26
+ def system
27
+ return @@default_locale unless @@cgi
28
+ cgi_ = cgi
29
+ if cgi_.has_key?("lang") and ret = cgi_["lang"] and ret.size > 0
30
+ elsif ret = cgi_.cookies["lang"][0]
31
+ elsif lang = cgi_.accept_language and lang.size > 0
32
+ num = lang.index(/;|,/)
33
+ ret = num ? lang[0, num] : lang
34
+ else
35
+ ret = @@default_locale.to_str
36
+ end
37
+
38
+ codesets = cgi_.accept_charset
39
+ if codesets and codesets.size > 0
40
+ num = codesets.index(',')
41
+ codeset = num ? codesets[0, num] : codesets
42
+ codeset = @@default_locale.charset if codeset == "*"
43
+ else
44
+ codeset = @@default_locale.charset
45
+ end
46
+ Locale::Object.new(ret, nil, codeset)
47
+ end
48
+
49
+
50
+ # Sets a CGI object.
51
+ # * cgi_: CGI object
52
+ # * Returns: self
53
+ def set_cgi(cgi_)
54
+ @@cgi = cgi_
55
+ self
56
+ end
57
+
58
+ # Sets a CGI object.
59
+ # * cgi_: CGI object
60
+ # * Returns: cgi_
61
+ def cgi=(cgi_)
62
+ set_cgi(cgi_)
63
+ cgi_
64
+ end
65
+
66
+ # Gets the CGI object. If it is nil, returns new CGI object.
67
+ # * Returns: the CGI object
68
+ def cgi
69
+ @@cgi = CGI.new unless @@cgi
70
+ @@cgi
71
+ end
72
+
73
+ # Gets the default Locale::Object.
74
+ # * Returns: the default locale
75
+ def default_locale
76
+ @@default_locale
77
+ end
78
+ end
79
+ @@locale_system_module = SystemCGI
80
+
81
+ module_function
82
+ # Sets a CGI object.
83
+ # * cgi_: CGI object
84
+ # * Returns: self
85
+ def set_cgi(cgi_)
86
+ @@locale_system_module.set_cgi(cgi_)
87
+ self
88
+ end
89
+
90
+ # Sets a CGI object.
91
+ # * cgi_: CGI object
92
+ # * Returns: cgi_
93
+ def cgi=(cgi_)
94
+ set_cgi(cgi_)
95
+ cgi_
96
+ end
97
+
98
+ # Gets the CGI object. If it is nil, returns new CGI object.
99
+ # * Returns: the CGI object
100
+ def cgi
101
+ @@locale_system_module.cgi
102
+ end
103
+ end
@@ -0,0 +1,36 @@
1
+ =begin
2
+ locale/jruby.rb
3
+
4
+ Copyright (C) 2007 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: jruby.rb,v 1.3 2008/03/21 06:28:10 mutoh Exp $
10
+ =end
11
+
12
+ require 'locale/base'
13
+ require 'java'
14
+
15
+ module Locale
16
+ # Locale::SystemJRuby module for JRuby
17
+ # This is a low-level class. Application shouldn't use this directly.
18
+ module SystemJRuby
19
+ extend SystemBase
20
+
21
+ if java.lang.System.getProperties['os.name'].downcase =~ /windows/
22
+ require 'locale/win32_table'
23
+
24
+ extend ::Locale::SystemWin32Table
25
+ end
26
+
27
+ module_function
28
+ def default_locale #:nodoc:
29
+ locale = java.util.Locale.getDefault
30
+ charset = java.nio.charset.Charset.defaultCharset.name
31
+ Locale::Object.new(locale.to_s, nil, charset)
32
+ end
33
+ end
34
+ @@locale_system_module = SystemJRuby
35
+ end
36
+
@@ -0,0 +1,233 @@
1
+ =begin
2
+ locale/object.rb - Locale::Object
3
+
4
+ Copyright (C) 2006,2007 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: object.rb,v 1.3 2008/01/27 10:58:10 mutoh Exp $
10
+ =end
11
+
12
+
13
+ module Locale
14
+ class Object
15
+ attr_reader :language, :country, :charset, :script, :variant, :modifier, :orig_str
16
+
17
+ # Set the language. e.g.) ja, en, fr, ...
18
+ def language=(val)
19
+ @language = val
20
+ clear
21
+ end
22
+
23
+ # Set the country. e.g.) JP, US, FR, ...
24
+ def country=(val)
25
+ @country = val
26
+ clear
27
+ end
28
+
29
+ # Set the charset. e.g.) UTF-8, EUC-JP, Shift_JIS
30
+ def charset=(val)
31
+ @charset = val
32
+ clear
33
+ end
34
+
35
+ # Set the script. e.g.) Latn
36
+ def script=(val)
37
+ @script = val
38
+ clear
39
+ end
40
+
41
+ # Set the variant. e.g.) Hant
42
+ def variant=(val)
43
+ @variant = val
44
+ clear
45
+ end
46
+
47
+ # Set the modifier. e.g.) curreny=DDM
48
+ def modifier=(val)
49
+ @modifier = val
50
+ clear
51
+ end
52
+
53
+ # A fallback locale. With GetText, you don't need to set English(en,C,POSIX)
54
+ # by yourself because English is used as the last fallback locale anytime.
55
+ attr_accessor :fallback
56
+
57
+ # Parse POSIX or RFC 3066 style locale name to Array.
58
+ #
59
+ # * locale_name: locale name as String
60
+ #
61
+ # * Basic POSIX format: <language>_<COUNTRY>.<charset>@<modifier>
62
+ # * Both of POSIX and C are converted to "en".
63
+ # * Basic RFC3066 format: <language>-<COUNTRY>
64
+ # * Win32 format: <language>-<COUNTRY>-<Script>_<sort order>
65
+ # * CLDR format: <language>_<Script>_<COUNTRY>_<variant>@<modifier>
66
+ # * Some broken format: <language>_<country>_<script> # Don't use this.
67
+ # * The max locale format is below:
68
+ # * <language>-<COUNTRY>-<Script>_<sort order>.<charset>@<modifier>
69
+ # * format: <language>_<Script>_<COUNTRY>_<variant>@<modifier>
70
+ # * both of '-' and '_' are separators.
71
+ # * each elements are omittable.
72
+ #
73
+ # (e.g.) uz-UZ-Latn, ja_JP.eucJP, wa_BE.iso885915@euro
74
+ # * Returns: [language, country, charset, script, modifier]
75
+ # * language: a lowercase ISO 639(or 639-2/T) language code.
76
+ # * country: an uppercase ISO 3166-1 country/region identifier.
77
+ # * charset: charset(codeset) (no standard)
78
+ # * script: an initial-uppercase ISO 15924 script code.
79
+ # * variant: variant value in CLDR or sort order in Win32.
80
+ # * modifier: (no standard)
81
+ #
82
+ # (e.g.)
83
+ # "ja_JP.eucJP" => ["ja", "JP", "eucJP", nil, nil]
84
+ # "ja-jp.utf-8" => ["ja", "JP", "utf-8", nil, nil]
85
+ # "ja-jp" => ["ja", "JP", nil, nil, nil]
86
+ # "ja" => ["ja", nil, nil, nil, nil]
87
+ # "uz@Latn" => ["uz", nil, nil, nil, "Latn"]
88
+ # "uz-UZ-Latn" => ["uz", "UZ", nil, "Latn", nil]
89
+ # "uz_UZ_Latn" => ["uz", "UZ", nil, "Latn", nil]
90
+ # "wa_BE.iso885915@euro" => ["wa", "BE", "iso885915", nil, "euro"]
91
+ # "C" => ["en", nil, nil, nil, nil]
92
+ # "POSIX" => ["en", nil, nil, nil, nil]
93
+ # "zh_Hant" => ["zh", nil, nil, "Hant", nil]
94
+ # "zh_Hant_HK" => ["zh", "HK", nil, "Hant", nil]
95
+ # "de_DE@collation=phonebook,currency=DDM" => ["de", "DE", nil, nil, "collation=phonebook,currency=DDM"]
96
+
97
+ def self.parse(locale_name)
98
+ lang_charset, modifier = locale_name.split(/@/)
99
+ lang, charset = lang_charset.split(/\./)
100
+ language, country, script, variant = lang.gsub(/_/, "-").split('-')
101
+ language = language ? language.downcase : nil
102
+ language = "en" if language == "c" || language == "posix"
103
+ if country
104
+ if country =~ /\A[A-Z][a-z]+\Z/ #Latn => script
105
+ tmp = script
106
+ script = country
107
+ if tmp =~ /\A[A-Z]+\Z/ #US => country
108
+ country = tmp
109
+ else
110
+ country = nil
111
+ variant = tmp
112
+ end
113
+ else
114
+ country = country.upcase
115
+ if script !~ /\A[A-Z][a-z]+\Z/ #Latn => script
116
+ variant = script
117
+ script = nil
118
+ end
119
+ end
120
+ end
121
+ [language, country, charset, script, variant, modifier]
122
+ end
123
+
124
+ # Initialize Locale::Object.
125
+ # * language_or_locale_name: language(ISO 639) or POSIX or RFC3066 style locale name
126
+ # * country: an uppercase ISO 3166-1 country/region identifier, or nil
127
+ # * charset: charset(codeset) (no standard), or nil
128
+ #
129
+ # Locale::Object.new("ja", "JP", "eucJP")
130
+ # -> language = "ja", country = "JP", charset = "eucJP".
131
+ # Locale::Object.new("ja", "JP")
132
+ # -> language = "ja", country = "JP", charset = nil.
133
+ # Locale::Object.new("ja_JP.eucJP")
134
+ # -> language = "ja", country = "JP", charset = "eucJP".
135
+ # Locale::Object.new("ja_JP.eucJP", nil, "UTF-8")
136
+ # -> language = "ja", country = "JP", charset = "UTF-8".
137
+ # Locale::Object.new("en-US", "CA")
138
+ # -> language = "en", country = "CA", charset = nil.
139
+ # Locale::Object.new("uz-uz-latn")
140
+ # -> language = "uz", country = "UZ", charset = nil, script = "Latn"
141
+ # Locale::Object.new("uz_UZ_Latn")
142
+ # -> language = "uz", country = "UZ", charset = nil, script = "Latn"
143
+ # Locale::Object.new("we_BE.iso885915@euro")
144
+ # -> language = "we", country = "BE", charset = "iso885915", modifier = "euroo".
145
+ # Locale::Object.new("C")
146
+ # -> language = "en", country = nil, charset = nil.
147
+ # Locale::Object.new("POSIX")
148
+ # -> language = "en", country = nil, charset = nil.
149
+ def initialize(language_or_locale_name, country = nil, charset = nil)
150
+ @orig_str = language_or_locale_name
151
+ @language, @country, @charset, @script, @variant, @modifier =
152
+ self.class.parse(language_or_locale_name)
153
+ @country = country if country
154
+ @charset = charset if charset
155
+ @fallback = nil
156
+ clear
157
+ end
158
+
159
+ def clear
160
+ @posix = nil
161
+ @iso3066 = nil
162
+ @win = nil
163
+ @general = nil
164
+ @hash = "#{self.class}:#{to_general}.#{@charset}@#{@modifier}".hash
165
+ end
166
+
167
+ # Returns the locale as POSIX format(but charset is ignored). (e.g.) "ja_JP"
168
+ def to_posix
169
+ return @posix if @posix
170
+ @posix = @language.dup
171
+
172
+ @posix << "_#{@country}" if @country
173
+ @posix
174
+ end
175
+
176
+ # Returns the locale as ISO3066 format. (e.g.) "ja-JP"
177
+ def to_iso3066
178
+ return @iso3066 if @iso3066
179
+
180
+ @iso3066 = @language.dup
181
+ @iso3066 << "-#{@country}" if @country
182
+ @iso3066
183
+ end
184
+
185
+ # Returns the locale as Win32 format. (e.g.) "az-AZ-Latn".
186
+ #
187
+ # This is used to find the charset from locale table.
188
+ def to_win
189
+ return @win if @win
190
+
191
+ @win = @language.dup
192
+ @win << "-#{@country}" if @country
193
+ @win << "-#{@script}" if @script
194
+ @win
195
+ end
196
+
197
+ # Returns the locale as 'ruby' general format. (e.g.) "az_AZ_Latn"
198
+ def to_general
199
+ return @general if @general
200
+
201
+ @general = @language.dup
202
+ @general << "_#{@country}" if @country
203
+ @general << "_#{@script}" if @script
204
+ @general
205
+ end
206
+
207
+ # Gets the locale informations as an Array.
208
+ # * Returns [language, country, charset, script, variant, modifier]
209
+ # * language: a lowercase ISO 639(or 639-2/T) language code.
210
+ # * country: an uppercase ISO 3166-1 country/region identifier.
211
+ # * charset: charset(codeset) (no standard)
212
+ # * script: an initial-uppercase ISO 15924 script code.
213
+ # * variant: variant value in CLDR or sort order in Win32.
214
+ # * modifier: (no standard)
215
+ def to_a
216
+ [@language, @country, @charset, @script, @variant, @modifier]
217
+ end
218
+
219
+ def ==(other) #:nodoc:
220
+ other != nil and @hash == other.hash
221
+ end
222
+
223
+ def eql?(other) #:nodoc:
224
+ self.==(other)
225
+ end
226
+
227
+ def hash #:nodoc:
228
+ @hash
229
+ end
230
+ alias :to_s :to_posix
231
+ alias :to_str :to_posix
232
+ end
233
+ end
@@ -0,0 +1,22 @@
1
+ =begin
2
+ locale/posix.rb
3
+
4
+ Copyright (C) 2002-2007 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: posix.rb,v 1.2 2007/11/08 16:44:22 mutoh Exp $
10
+ =end
11
+
12
+ require 'locale/base'
13
+
14
+ module Locale
15
+ # Locale::SystemPosix module for Posix OS (Unix)
16
+ # This is a low-level class. Application shouldn't use this directly.
17
+ module SystemPosix
18
+ extend SystemBase
19
+ end
20
+ @@locale_system_module = SystemPosix
21
+ end
22
+