openskip-skip_embedded 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +9 -0
- data/Rakefile +1 -0
- data/generators/skip_embedded_init/skip_embedded_init_generator.rb +4 -3
- data/generators/skip_embedded_init/templates/app/views/layouts/skip_embedded.html.erb +18 -54
- data/generators/skip_embedded_init/templates/app/views/shared/_common_header.html.erb +8 -0
- data/generators/skip_embedded_init/templates/app/views/shared/_flash_message.html.erb +0 -1
- data/generators/skip_embedded_init/templates/app/views/shared/_footer.html.erb +18 -0
- data/generators/skip_embedded_init/templates/app/views/shared/_header.html.erb +23 -0
- data/generators/skip_embedded_init/templates/app/views/shared/_skip_full_text_search_form.html.erb +1 -1
- data/generators/skip_embedded_init/templates/config/initial_settings.yml +5 -5
- data/generators/skip_embedded_init/templates/public/images/footer_logo.png +0 -0
- data/generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_header.sass +1 -0
- data/lib/skip_embedded.rb +1 -1
- data/lib/skip_embedded/rp_service/util.rb +4 -4
- data/lib/skip_embedded/types/content_type.rb +11 -9
- data/lib/skip_embedded/validations_file.rb +3 -36
- data/script/skip-gen.sh +2 -2
- data/spec/skip_embedded/validations_file_spec.rb +228 -0
- metadata +76 -58
data/ChangeLog
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
* refactor ValidationFile class and add spec
|
2
|
+
|
3
|
+
== 0.9.9 / 2009-06-04
|
4
|
+
* import iframe_upload.js
|
5
|
+
|
6
|
+
== 0.9.8 / 2009-06-04
|
7
|
+
* divide generator init, javascript and stylesheet
|
8
|
+
* move stylesheet and javascript to skip_embedded sub direcotry
|
9
|
+
|
1
10
|
== 0.9.7 / 2009-06-04
|
2
11
|
* fixed GET request problem when OAuth request
|
3
12
|
|
data/Rakefile
CHANGED
@@ -63,6 +63,7 @@ spec = Gem::Specification.new do |s|
|
|
63
63
|
s.add_dependency "moro-repim", ">=0.1.7"
|
64
64
|
s.add_dependency "json"
|
65
65
|
s.add_dependency "oauth"
|
66
|
+
s.add_dependency 'haml'
|
66
67
|
|
67
68
|
s.files = %w(README.rdoc ChangeLog Rakefile) +
|
68
69
|
Dir.glob("{bin,doc,test,lib,templates,generators,extras,website,script}/**/*") +
|
@@ -3,18 +3,19 @@ class SkipEmbeddedInitGenerator < Rails::Generator::Base
|
|
3
3
|
record do |m|
|
4
4
|
assets = %w[
|
5
5
|
app/views/layouts/skip_embedded.html.erb
|
6
|
+
app/views/shared/_common_header.html.erb
|
7
|
+
app/views/shared/_footer.html.erb
|
8
|
+
app/views/shared/_header.html.erb
|
6
9
|
app/views/shared/_flash_message.html.erb
|
7
10
|
app/views/shared/_skip_full_text_search_form.html.erb
|
8
11
|
config/initial_settings.yml
|
9
12
|
lib/tasks/skip_embedded.rake
|
13
|
+
public/images/footer_logo.png
|
10
14
|
]
|
11
15
|
|
12
16
|
assets.map{|asset| File.dirname(asset) }.uniq.each{|asset| m.directory(asset) }
|
13
17
|
assets.each{|asset| m.file asset, asset }
|
14
18
|
|
15
|
-
m.dependency('skip_embedded_javascripts', [])
|
16
|
-
m.dependency('skip_embedded_stylesheets', [])
|
17
|
-
|
18
19
|
insert_application_helper(m)
|
19
20
|
insert_application_controller(m)
|
20
21
|
insert_sessions_controller(m)
|
@@ -1,62 +1,26 @@
|
|
1
1
|
<?xml version="1.0" encoding="utf-8"?>
|
2
2
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
3
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
|
4
|
-
<head>
|
5
|
-
|
6
|
-
|
7
|
-
<
|
4
|
+
<head>
|
5
|
+
<%= render :partial => 'shared/common_header' %>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<%= render :partial => "shared/header" %>
|
9
|
+
<%= render :partial => "shared/flash_message" %>
|
8
10
|
|
9
|
-
|
10
|
-
<%= stylesheet_link_tag("sprites/sprites") %>
|
11
|
-
|
12
|
-
<%= yield :stylesheet %>
|
13
|
-
<%= javascript_include_tag(:jquery) %>
|
14
|
-
</head>
|
15
|
-
<body>
|
16
|
-
<div id="header">
|
17
|
-
<div id="logo">
|
18
|
-
<span class="app-name">SKIIP ---INSERT YOUR APP NAME---</span>
|
19
|
-
</div>
|
20
|
-
|
21
|
-
<div id="menu">
|
22
|
-
<% if signed_in? -%>
|
23
|
-
<div class="item" style="color: black;">
|
24
|
-
<%=h current_user.identity_url %>
|
25
|
-
</div>
|
26
|
-
<div class="item"><%= link_to "自分の管理", user_path(current_user) %></div>
|
27
|
-
<div class="item"><a href="FIXME" target="_blank">ヘルプ</a></div>
|
28
|
-
<div class="item"><%= link_to "ログアウト", signout_url %></div>
|
29
|
-
<% else %>
|
30
|
-
<div class="item"><%= link_to "ログイン", signin_url %></div>
|
31
|
-
<% end %>
|
32
|
-
<br style="clear: left" />
|
33
|
-
|
34
|
-
</div>
|
35
|
-
<% if SkipEmbedded::InitialSettings["skip_collaboration"]["fulltext_search"] -%>
|
36
|
-
<%= render(:partial => "shared/skip_full_text_search_form") %>
|
37
|
-
<% end -%>
|
38
|
-
</div>
|
39
|
-
<%= render :partial=>"shared/flash_message" %>
|
40
|
-
|
41
|
-
<div id="main">
|
42
|
-
<div id="tab_body">
|
11
|
+
<div id="main">
|
43
12
|
<%= yield %>
|
44
13
|
</div>
|
45
|
-
</div>
|
46
14
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
<%
|
57
|
-
|
58
|
-
<%= yield :javascript_initializer %>
|
59
|
-
});
|
60
|
-
<% end -%>
|
15
|
+
<%= render :partial => "shared/footer" %>
|
16
|
+
<%= javascript_include_tag :jquery %>
|
17
|
+
<%= javascript_include_tag :skip_embedded, :cache => "skip_embedded" %>
|
18
|
+
<%= javascript_include_tag(URI.join(SkipEmbedded::InitialSettings["skip_collaboration"]["skip_url"], "services/skip_header.js").to_s) if SkipEmbedded::InitialSettings["skip_collaboration"]["skip_url"] %>
|
19
|
+
<%= yield :javascript_includes %>
|
20
|
+
<% javascript_tag do -%>
|
21
|
+
jQuery(function(){
|
22
|
+
<%= yield :javascript_initializer %>
|
23
|
+
});
|
24
|
+
<% end -%>
|
25
|
+
</body>
|
61
26
|
</html>
|
62
|
-
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
2
|
+
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
3
|
+
<link rel="shortcut icon" href="<%= controller.request.relative_url_root %>/favicon.ico" />
|
4
|
+
<title><%=h @title %></title>
|
5
|
+
|
6
|
+
<%= stylesheet_link_tag :skip_embedded %>
|
7
|
+
<%= stylesheet_link_tag :skip_embedded_sprites %>
|
8
|
+
<%= yield :stylesheet %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<div id="footer">
|
2
|
+
<div class="info">
|
3
|
+
<div class="first">
|
4
|
+
<%= link_to_function _("About this site"), "open_site()" %>
|
5
|
+
|
|
6
|
+
<%= link_to_function _("Rule to use"), "open_rule()" %>
|
7
|
+
|
|
8
|
+
<%= link_to_function _("FIXME"), "open_rule()" %>
|
9
|
+
</div>
|
10
|
+
<div class="second">
|
11
|
+
<%= "お問い合わせはこちら | Since 2008 SKIP" %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
<div class="powered_by">
|
15
|
+
powered by
|
16
|
+
<%= link_to(image_tag("footer_logo.png"), "http://www.openskip.org/") %>
|
17
|
+
</div>
|
18
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div id="header">
|
2
|
+
<div id="global_top">
|
3
|
+
<div id="application_link">
|
4
|
+
</div>
|
5
|
+
<div id="menu">
|
6
|
+
<% if signed_in? -%>
|
7
|
+
<%=h current_user.identity_url %>|
|
8
|
+
<%= link_to "自分の管理", user_path(current_user) %>|
|
9
|
+
<%= link_to "ログアウト", signout_url %>
|
10
|
+
<% else %>
|
11
|
+
<%= link_to "ログイン", signin_url %>
|
12
|
+
<% end %>
|
13
|
+
<br style="clear: left" />
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<div id="logo">
|
17
|
+
<span class="app-name">SKIP ---INSERT YOUR APP NAME---</span>
|
18
|
+
</div>
|
19
|
+
<div class="banner"></div>
|
20
|
+
<% if SkipEmbedded::InitialSettings["skip_collaboration"]["fulltext_search"] -%>
|
21
|
+
<%= render(:partial => "shared/skip_full_text_search_form") %>
|
22
|
+
<% end -%>
|
23
|
+
</div>
|
@@ -1,15 +1,15 @@
|
|
1
1
|
development:
|
2
2
|
skip_collaboration:
|
3
|
-
skip_url: "http://
|
4
|
-
secret_key:
|
3
|
+
skip_url: "http://localhost:3000/"
|
4
|
+
secret_key: change-me
|
5
5
|
fulltext_search:
|
6
6
|
endpoint: "/search/full_text_search"
|
7
7
|
query_name: "full_text_query"
|
8
8
|
fixed_op:
|
9
|
-
|
10
|
-
fixed_openid_server_url: "http://localhost:
|
9
|
+
disabled: false
|
10
|
+
fixed_openid_server_url: "http://localhost:3000/"
|
11
11
|
acceptable_op_urls:
|
12
|
-
- "http://localhost:
|
12
|
+
- "http://localhost:3000/"
|
13
13
|
|
14
14
|
test:
|
15
15
|
skip_collaboration:
|
data/lib/skip_embedded.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
module SkipEmbedded
|
2
2
|
module RpService
|
3
3
|
module Util
|
4
|
-
def user_data(identity_url, name, display_name, admin = false)
|
4
|
+
def user_data(identity_url, name, display_name, admin = false, delete = false)
|
5
5
|
{:identity_url => identity_url, :name => name,
|
6
|
-
:display_name => display_name, :admin => admin}.reject{|k,v| v.nil? }
|
6
|
+
:display_name => display_name, :admin => admin, :delete? => delete}.reject{|k,v| v.nil? }
|
7
7
|
end
|
8
8
|
|
9
|
-
def group_data(gid, name, display_name, members)
|
9
|
+
def group_data(gid, name, display_name, members, delete = false)
|
10
10
|
{:gid => gid, :name => name, :display_name => display_name,
|
11
|
-
:members => members}.reject{|k,v| v.nil? }
|
11
|
+
:members => members, :delete? => delete}.reject{|k,v| v.nil? }
|
12
12
|
end
|
13
13
|
module_function :user_data, :group_data
|
14
14
|
end
|
@@ -14,15 +14,17 @@
|
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
16
|
module SkipEmbedded
|
17
|
-
module Types
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
module Types
|
18
|
+
module ContentType
|
19
|
+
CONTENT_TYPE_IMAGES = {
|
20
|
+
:jpg => 'image/jpg,image/jpeg,image/pjpeg',
|
21
|
+
:jpeg => 'image/jpg,image/jpeg,image/pjpeg',
|
22
|
+
:png => 'image/png,image/x-png',
|
23
|
+
:gif => 'image/gif',
|
24
|
+
:bmp => 'image/bmp'
|
25
|
+
}.freeze
|
25
26
|
|
26
|
-
|
27
|
+
DEFAULT_CONTENT_TYPE = "application/octet-stream"
|
28
|
+
end
|
27
29
|
end
|
28
30
|
end
|
@@ -13,9 +13,11 @@
|
|
13
13
|
# You should have received a copy of the GNU General Public License
|
14
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
+
require 'skip_embedded/types/content_type'
|
17
|
+
|
16
18
|
module SkipEmbedded
|
17
19
|
module ValidationsFile
|
18
|
-
include Types::ContentType
|
20
|
+
include SkipEmbedded::Types::ContentType
|
19
21
|
def valid_presence_of_file(file)
|
20
22
|
unless file.is_a?(ActionController::UploadedFile)
|
21
23
|
errors.add_to_base "ファイルが指定されていません。"
|
@@ -41,41 +43,6 @@ module SkipEmbedded
|
|
41
43
|
true
|
42
44
|
end
|
43
45
|
|
44
|
-
def valid_size_of_file(file)
|
45
|
-
if file.size == 0
|
46
|
-
errors.add_to_base "存在しないもしくはサイズ0のファイルはアップロードできません。"
|
47
|
-
elsif file.size > SkipEmbedded::InitialSettings['max_share_file_size'].to_i
|
48
|
-
errors.add_to_base "#{SkipEmbedded::InitialSettings['max_share_file_size'].to_i/1.megabyte}Mバイト以上のファイルはアップロードできません。"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def valid_max_size_per_owner_of_file(file, owner_symbol)
|
53
|
-
if (FileSizeCounter.per_owner(owner_symbol) + file.size) > SkipEmbedded::InitialSettings['max_share_file_size_per_owner'].to_i
|
54
|
-
errors.add_to_base "共有ファイル保存領域の利用容量が最大値を越えてしまうためアップロードできません。"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def valid_max_size_of_system_of_file(file)
|
59
|
-
if (FileSizeCounter.per_system + file.size) > SkipEmbedded::InitialSettings['max_share_file_size_of_system'].to_i
|
60
|
-
errors.add_to_base "システム全体における共有ファイル保存領域の利用容量が最大値を越えてしまうためアップロードできません。"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
class FileSizeCounter
|
65
|
-
def self.per_owner owner_symbol
|
66
|
-
sum = 0
|
67
|
-
sum += ShareFile.total_share_file_size(owner_symbol)
|
68
|
-
sum
|
69
|
-
end
|
70
|
-
def self.per_system
|
71
|
-
sum = 0
|
72
|
-
Dir.glob("#{SkipEmbedded::InitialSettings['share_file_path']}/**/*").each do |f|
|
73
|
-
sum += File.stat(f).size
|
74
|
-
end
|
75
|
-
sum
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
46
|
private
|
80
47
|
def verify_extension? file_name, content_type
|
81
48
|
!disallow_extensions.any?{|extension| extension == file_name.split('.').last } &&
|
data/script/skip-gen.sh
CHANGED
@@ -48,12 +48,13 @@ diff --git a/skip-sample/config/environment.rb b/skip-sample/config/environment.
|
|
48
48
|
index a0fb06a..bda6d11 100644
|
49
49
|
--- a/skip-sample/config/environment.rb
|
50
50
|
+++ b/skip-sample/config/environment.rb
|
51
|
-
@@ -25,6 +25,
|
51
|
+
@@ -25,6 +25,9 @@ Rails::Initializer.run do |config|
|
52
52
|
# config.gem "bj"
|
53
53
|
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
54
54
|
# config.gem "aws-s3", :lib => "aws/s3"
|
55
55
|
+ config.gem 'moro-repim', :lib => 'repim', :source => 'http://gems.github.com/'
|
56
56
|
+ config.gem 'openskip-skip_embedded', :lib => 'skip_embedded', :source => 'http://gems.github.com/'
|
57
|
+
+ config.gem 'haml'
|
57
58
|
|
58
59
|
# Only load the plugins named here, in the order given. By default, all plugins
|
59
60
|
# in vendor/plugins are loaded in alphabetical order.
|
@@ -64,4 +65,3 @@ rake skip_embedded:thirdparty
|
|
64
65
|
rm app/views/layouts/sessions.html.erb public/index.html
|
65
66
|
|
66
67
|
cd -
|
67
|
-
|
@@ -0,0 +1,228 @@
|
|
1
|
+
# SKIP(Social Knowledge & Innovation Platform)
|
2
|
+
# Copyright (C) 2008-2009 TIS Inc.
|
3
|
+
#
|
4
|
+
# This program is free software: you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation, either version 3 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU General Public License
|
14
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
16
|
+
require 'skip_embedded/validations_file'
|
17
|
+
require 'skip_embedded/types/content_type'
|
18
|
+
|
19
|
+
class ValidateFileClass
|
20
|
+
include SkipEmbedded::ValidationsFile
|
21
|
+
|
22
|
+
attr_accessor :file
|
23
|
+
end
|
24
|
+
|
25
|
+
describe SkipEmbedded::ValidationsFile do
|
26
|
+
before do
|
27
|
+
@vf = mock_model_class
|
28
|
+
@muf = mock_uploaed_file
|
29
|
+
end
|
30
|
+
describe "#valid_presence_of_file" do
|
31
|
+
describe "ファイルが設定されている場合" do
|
32
|
+
it "trueを返すこと" do
|
33
|
+
@vf.valid_presence_of_file(@muf).should be_true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
describe "ファイルが設定されていない場合" do
|
37
|
+
it "falseを返ること" do
|
38
|
+
@vf.valid_presence_of_file("string").should be_false
|
39
|
+
end
|
40
|
+
it "エラーが追加されること" do
|
41
|
+
@vf.errors.should_receive(:add_to_base).with("ファイルが指定されていません。")
|
42
|
+
@vf.valid_presence_of_file("string")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#valid_extension_of_file" do
|
48
|
+
describe "ファイルの形式が不正な場合" do
|
49
|
+
it "エラーが追加されること" do
|
50
|
+
@vf.errors.should_receive(:add_to_base).with("この形式のファイルは、アップロードできません。")
|
51
|
+
@vf.should_receive(:verify_extension?).and_return(false)
|
52
|
+
@vf.send!(:valid_extension_of_file, @muf)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#valid_content_type_of_file' do
|
58
|
+
describe 'ファイルの拡張子に対するContentTypeが不正な場合' do
|
59
|
+
before do
|
60
|
+
@muf.stub!(:original_filename).and_return('image.jpg')
|
61
|
+
@muf.stub!(:content_type).and_return('image/gif')
|
62
|
+
@vf.errors.should_receive(:add_to_base).with('この形式のファイルは、アップロードできません。')
|
63
|
+
@vf.valid_content_type_of_file(@muf)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
describe '拡張子がjpgの場合' do
|
67
|
+
before do
|
68
|
+
@muf.stub!(:original_filename).and_return('image.jpg')
|
69
|
+
end
|
70
|
+
describe 'content_typeがimage/jpgの場合' do
|
71
|
+
before do
|
72
|
+
@muf.stub!(:content_type).and_return('image/jpg')
|
73
|
+
end
|
74
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
75
|
+
end
|
76
|
+
describe 'content_typeがimage/jpegの場合' do
|
77
|
+
before do
|
78
|
+
@muf.stub!(:content_type).and_return('image/jpeg')
|
79
|
+
end
|
80
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
81
|
+
end
|
82
|
+
describe 'content_typeがimage/pjpeg(プログレッシブ画像)の場合' do
|
83
|
+
before do
|
84
|
+
@muf.stub!(:content_type).and_return('image/pjpeg')
|
85
|
+
end
|
86
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
87
|
+
end
|
88
|
+
end
|
89
|
+
describe '拡張子がjpegの場合' do
|
90
|
+
before do
|
91
|
+
@muf.stub!(:original_filename).and_return('image.jpeg')
|
92
|
+
end
|
93
|
+
describe 'content_typeがimage/jpgの場合' do
|
94
|
+
before do
|
95
|
+
@muf.stub!(:content_type).and_return('image/jpg')
|
96
|
+
end
|
97
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
98
|
+
end
|
99
|
+
describe 'content_typeがimage/jpegの場合' do
|
100
|
+
before do
|
101
|
+
@muf.stub!(:content_type).and_return('image/jpeg')
|
102
|
+
end
|
103
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
104
|
+
end
|
105
|
+
describe 'content_typeがimage/pjpeg(プログレッシブ画像)の場合' do
|
106
|
+
before do
|
107
|
+
@muf.stub!(:content_type).and_return('image/pjpeg')
|
108
|
+
end
|
109
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
110
|
+
end
|
111
|
+
end
|
112
|
+
describe '拡張子がpngの場合' do
|
113
|
+
before do
|
114
|
+
@muf.stub!(:original_filename).and_return('image.png')
|
115
|
+
end
|
116
|
+
describe 'content_typeがimage/pngの場合' do
|
117
|
+
before do
|
118
|
+
@muf.stub!(:content_type).and_return('image/png')
|
119
|
+
end
|
120
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
121
|
+
end
|
122
|
+
describe 'content_typeがimage/x-pngの場合' do
|
123
|
+
before do
|
124
|
+
@muf.stub!(:content_type).and_return('image/x-png')
|
125
|
+
end
|
126
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
127
|
+
end
|
128
|
+
end
|
129
|
+
describe '拡張子がgifの場合' do
|
130
|
+
before do
|
131
|
+
@muf.stub!(:original_filename).and_return('image.gif')
|
132
|
+
end
|
133
|
+
describe 'content_typeがimage/gifの場合' do
|
134
|
+
before do
|
135
|
+
@muf.stub!(:content_type).and_return('image/gif')
|
136
|
+
end
|
137
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
138
|
+
end
|
139
|
+
end
|
140
|
+
describe '拡張子がbmpの場合' do
|
141
|
+
before do
|
142
|
+
@muf.stub!(:original_filename).and_return('image.bmp')
|
143
|
+
end
|
144
|
+
describe 'content_typeがimage/bmpの場合' do
|
145
|
+
before do
|
146
|
+
@muf.stub!(:content_type).and_return('image/bmp')
|
147
|
+
end
|
148
|
+
it { @vf.valid_content_type_of_file(@muf).should be_true }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#verify_extension?' do
|
154
|
+
before do
|
155
|
+
@disallow_extension = 'disallow_extension'
|
156
|
+
@vf.should_receive(:disallow_extensions).and_return([@disallow_extension])
|
157
|
+
end
|
158
|
+
describe '許可されない拡張子の場合' do
|
159
|
+
it 'falseが返ること' do
|
160
|
+
@vf.send(:verify_extension?, "file.#{@disallow_extension}", 'content_type').should be_false
|
161
|
+
end
|
162
|
+
end
|
163
|
+
describe '許可される拡張子の場合' do
|
164
|
+
before do
|
165
|
+
@allow_extension = 'allow_extension'
|
166
|
+
@disallow_content_type = 'disallow_content_type'
|
167
|
+
@vf.should_receive(:disallow_content_types).and_return([@disallow_content_type])
|
168
|
+
end
|
169
|
+
describe '許可されるcontent_typeの場合' do
|
170
|
+
before do
|
171
|
+
@allow_content_type = 'allow_content_type'
|
172
|
+
end
|
173
|
+
it 'trueが返ること' do
|
174
|
+
@vf.send(:verify_extension?, "file.#{@allow_extension}", @allow_content_type).should be_true
|
175
|
+
end
|
176
|
+
end
|
177
|
+
describe '許可されないcontent_typeの場合' do
|
178
|
+
it 'falseが返ること' do
|
179
|
+
@vf.send(:verify_extension?, "file.#{@allow_extension}", @disallow_content_type).should be_false
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
describe '#disallow_content_types' do
|
186
|
+
it 'text/htmlが含まれること' do
|
187
|
+
@vf.send!(:disallow_content_types).include?('text/html').should be_true
|
188
|
+
end
|
189
|
+
it 'application/x-javascriptが含まれること' do
|
190
|
+
@vf.send!(:disallow_content_types).include?('application/x-javascript').should be_true
|
191
|
+
end
|
192
|
+
it 'image/bmpが含まれること' do
|
193
|
+
@vf.send!(:disallow_content_types).include?('image/bmp').should be_true
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
describe '#disallow_extensions' do
|
198
|
+
it 'htmlが含まれること' do
|
199
|
+
@vf.send!(:disallow_extensions).include?('html').should be_true
|
200
|
+
end
|
201
|
+
it 'htmが含まれること' do
|
202
|
+
@vf.send!(:disallow_extensions).include?('htm').should be_true
|
203
|
+
end
|
204
|
+
it 'jsが含まれること' do
|
205
|
+
@vf.send!(:disallow_extensions).include?('js').should be_true
|
206
|
+
end
|
207
|
+
it 'bmpが含まれること' do
|
208
|
+
@vf.send!(:disallow_extensions).include?('bmp').should be_true
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def mock_model_class
|
213
|
+
errors = mock('errors')
|
214
|
+
errors.stub!(:add_to_base)
|
215
|
+
|
216
|
+
vf = ValidateFileClass.new
|
217
|
+
vf.stub!(:errors).and_return(errors)
|
218
|
+
vf
|
219
|
+
end
|
220
|
+
|
221
|
+
def mock_uploaed_file options = {}
|
222
|
+
file = mock('file', { :original_filename => "file1.png", :content_type => "image/png", :size => 1000, :read => "" }.merge(options))
|
223
|
+
file.stub!(:is_a?).with(ActionController::UploadedFile).and_return(true)
|
224
|
+
# 以下をやらないとパラメータの中身がHashかどうかのチェックがらしく、リクエストが飛ばなくなるので
|
225
|
+
file.stub!(:is_a?).with(Hash).and_return(false)
|
226
|
+
file
|
227
|
+
end
|
228
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openskip-skip_embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MAEDA Naoki
|
@@ -11,7 +11,7 @@ autorequire:
|
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
13
|
|
14
|
-
date: 2009-06-
|
14
|
+
date: 2009-06-10 00:00:00 -07:00
|
15
15
|
default_executable: skip-gen
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
@@ -44,6 +44,16 @@ dependencies:
|
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: "0"
|
46
46
|
version:
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: haml
|
49
|
+
type: :runtime
|
50
|
+
version_requirement:
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
version:
|
47
57
|
description: Utilities to collabolate SKIP, opensource buisiness SNS.
|
48
58
|
email: info@openskip.org
|
49
59
|
executables:
|
@@ -58,88 +68,95 @@ files:
|
|
58
68
|
- ChangeLog
|
59
69
|
- Rakefile
|
60
70
|
- bin/skip-gen
|
71
|
+
- lib/skip_embedded.rb
|
61
72
|
- lib/skip_embedded
|
62
|
-
- lib/skip_embedded/fulltext_search_cache
|
63
|
-
- lib/skip_embedded/fulltext_search_cache/builder_base.rb
|
64
|
-
- lib/skip_embedded/fulltext_search_cache/mediator.rb
|
65
|
-
- lib/skip_embedded/fulltext_search_cache/partial_loader.rb
|
66
|
-
- lib/skip_embedded/fulltext_search_cache.rb
|
67
|
-
- lib/skip_embedded/helpers
|
68
|
-
- lib/skip_embedded/helpers/sprite.rb
|
69
|
-
- lib/skip_embedded/helpers/ui.rb
|
70
|
-
- lib/skip_embedded/helpers.rb
|
71
73
|
- lib/skip_embedded/initial_settings.rb
|
72
|
-
- lib/skip_embedded/op_fixation.rb
|
73
74
|
- lib/skip_embedded/open_id_sso
|
74
|
-
- lib/skip_embedded/open_id_sso/authentication.rb
|
75
75
|
- lib/skip_embedded/open_id_sso/session_management.rb
|
76
|
-
- lib/skip_embedded/
|
77
|
-
- lib/skip_embedded/
|
78
|
-
- lib/skip_embedded/rp_service/http_connection.rb
|
79
|
-
- lib/skip_embedded/rp_service/oauth_proxy.rb
|
80
|
-
- lib/skip_embedded/rp_service/util.rb
|
76
|
+
- lib/skip_embedded/open_id_sso/authentication.rb
|
77
|
+
- lib/skip_embedded/op_fixation.rb
|
81
78
|
- lib/skip_embedded/types
|
82
79
|
- lib/skip_embedded/types/content_type.rb
|
80
|
+
- lib/skip_embedded/helpers
|
81
|
+
- lib/skip_embedded/helpers/sprite.rb
|
82
|
+
- lib/skip_embedded/helpers/ui.rb
|
83
83
|
- lib/skip_embedded/validations_file.rb
|
84
|
+
- lib/skip_embedded/web_service_util.rb
|
85
|
+
- lib/skip_embedded/fulltext_search_cache.rb
|
84
86
|
- lib/skip_embedded/web_service_util
|
85
|
-
- lib/skip_embedded/web_service_util/client.rb
|
86
87
|
- lib/skip_embedded/web_service_util/server.rb
|
87
|
-
- lib/skip_embedded/web_service_util.rb
|
88
|
-
- lib/skip_embedded.rb
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
88
|
+
- lib/skip_embedded/web_service_util/client.rb
|
89
|
+
- lib/skip_embedded/helpers.rb
|
90
|
+
- lib/skip_embedded/fulltext_search_cache
|
91
|
+
- lib/skip_embedded/fulltext_search_cache/partial_loader.rb
|
92
|
+
- lib/skip_embedded/fulltext_search_cache/builder_base.rb
|
93
|
+
- lib/skip_embedded/fulltext_search_cache/mediator.rb
|
94
|
+
- lib/skip_embedded/rp_service
|
95
|
+
- lib/skip_embedded/rp_service/oauth_proxy.rb
|
96
|
+
- lib/skip_embedded/rp_service/http_connection.rb
|
97
|
+
- lib/skip_embedded/rp_service/util.rb
|
98
|
+
- lib/skip_embedded/rp_service/client.rb
|
99
|
+
- generators/skip_embedded_stylesheets
|
100
|
+
- generators/skip_embedded_stylesheets/templates
|
101
|
+
- generators/skip_embedded_stylesheets/templates/public
|
102
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets
|
103
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass
|
104
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded
|
105
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_base.sass
|
106
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_header.sass
|
107
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/editor_area.sass
|
108
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_footer.sass
|
109
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_embedded.sass
|
110
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/skip_embedded
|
111
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/skip_embedded/sprites.png
|
112
|
+
- generators/skip_embedded_stylesheets/templates/public/stylesheets/skip_embedded/sprites.css
|
113
|
+
- generators/skip_embedded_stylesheets/skip_embedded_stylesheets_generator.rb
|
93
114
|
- generators/skip_embedded_init
|
94
|
-
- generators/skip_embedded_init/skip_embedded_init_generator.rb
|
95
115
|
- generators/skip_embedded_init/templates
|
116
|
+
- generators/skip_embedded_init/templates/public
|
117
|
+
- generators/skip_embedded_init/templates/public/images
|
118
|
+
- generators/skip_embedded_init/templates/public/images/footer_logo.png
|
96
119
|
- generators/skip_embedded_init/templates/app
|
97
120
|
- generators/skip_embedded_init/templates/app/views
|
98
|
-
- generators/skip_embedded_init/templates/app/views/layouts
|
99
|
-
- generators/skip_embedded_init/templates/app/views/layouts/skip_embedded.html.erb
|
100
121
|
- generators/skip_embedded_init/templates/app/views/shared
|
101
|
-
- generators/skip_embedded_init/templates/app/views/shared/_flash_message.html.erb
|
102
122
|
- generators/skip_embedded_init/templates/app/views/shared/_skip_full_text_search_form.html.erb
|
103
|
-
- generators/skip_embedded_init/templates/
|
104
|
-
- generators/skip_embedded_init/templates/
|
123
|
+
- generators/skip_embedded_init/templates/app/views/shared/_flash_message.html.erb
|
124
|
+
- generators/skip_embedded_init/templates/app/views/shared/_header.html.erb
|
125
|
+
- generators/skip_embedded_init/templates/app/views/shared/_footer.html.erb
|
126
|
+
- generators/skip_embedded_init/templates/app/views/shared/_common_header.html.erb
|
127
|
+
- generators/skip_embedded_init/templates/app/views/layouts
|
128
|
+
- generators/skip_embedded_init/templates/app/views/layouts/skip_embedded.html.erb
|
105
129
|
- generators/skip_embedded_init/templates/lib
|
106
130
|
- generators/skip_embedded_init/templates/lib/tasks
|
107
131
|
- generators/skip_embedded_init/templates/lib/tasks/skip_embedded.rake
|
132
|
+
- generators/skip_embedded_init/templates/config
|
133
|
+
- generators/skip_embedded_init/templates/config/initial_settings.yml
|
134
|
+
- generators/skip_embedded_init/skip_embedded_init_generator.rb
|
135
|
+
- generators/skip_embedded_assets
|
136
|
+
- generators/skip_embedded_assets/skip_embedded_assets_generator.rb
|
137
|
+
- generators/skip_embedded
|
138
|
+
- generators/skip_embedded/skip_embedded_generator.rb
|
108
139
|
- generators/skip_embedded_javascripts
|
109
|
-
- generators/skip_embedded_javascripts/skip_embedded_javascripts_generator.rb
|
110
140
|
- generators/skip_embedded_javascripts/templates
|
111
141
|
- generators/skip_embedded_javascripts/templates/public
|
112
142
|
- generators/skip_embedded_javascripts/templates/public/blank.html
|
113
143
|
- generators/skip_embedded_javascripts/templates/public/javascripts
|
114
144
|
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded
|
145
|
+
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded/iframe_upload.js
|
146
|
+
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded/skip_fckeditor_config.js
|
115
147
|
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded/dropdown_navigation.js
|
116
148
|
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded/flash_message.js
|
117
|
-
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded/iframe_upload.js
|
118
149
|
- generators/skip_embedded_javascripts/templates/public/javascripts/skip_embedded/labeled_text_field.js
|
119
|
-
- generators/skip_embedded_javascripts/
|
120
|
-
- generators/skip_embedded_stylesheets
|
121
|
-
- generators/skip_embedded_stylesheets/skip_embedded_stylesheets_generator.rb
|
122
|
-
- generators/skip_embedded_stylesheets/templates
|
123
|
-
- generators/skip_embedded_stylesheets/templates/public
|
124
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets
|
125
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass
|
126
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded
|
127
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/editor_area.sass
|
128
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_base.sass
|
129
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_embedded.sass
|
130
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_footer.sass
|
131
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/sass/skip_embedded/skip_header.sass
|
132
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/skip_embedded
|
133
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/skip_embedded/sprites.css
|
134
|
-
- generators/skip_embedded_stylesheets/templates/public/stylesheets/skip_embedded/sprites.png
|
150
|
+
- generators/skip_embedded_javascripts/skip_embedded_javascripts_generator.rb
|
135
151
|
- script/skip-gen.sh
|
136
|
-
- spec/
|
137
|
-
- spec/skip_embedded/fulltext_search_cache/mediator_spec.rb
|
138
|
-
- spec/skip_embedded/fulltext_search_cache/partial_loader_spec.rb
|
152
|
+
- spec/spec_helper.rb
|
139
153
|
- spec/skip_embedded/initial_setting_spec.rb
|
140
|
-
- spec/skip_embedded/
|
154
|
+
- spec/skip_embedded/validations_file_spec.rb
|
141
155
|
- spec/skip_embedded/web_service_util_spec.rb
|
142
|
-
- spec/
|
156
|
+
- spec/skip_embedded/op_fixation_spec.rb
|
157
|
+
- spec/skip_embedded/fulltext_search_cache/mediator_spec.rb
|
158
|
+
- spec/skip_embedded/fulltext_search_cache/partial_loader_spec.rb
|
159
|
+
- spec/skip_embedded/fulltext_search_cache/builder_base_spec.rb
|
143
160
|
- rails/init.rb
|
144
161
|
has_rdoc: false
|
145
162
|
homepage: http://github.com/openskip/skip_embedded/tree/master
|
@@ -179,9 +196,10 @@ signing_key:
|
|
179
196
|
specification_version: 3
|
180
197
|
summary: Utilities to collabolate SKIP, opensource buisiness SNS.
|
181
198
|
test_files:
|
182
|
-
- spec/skip_embedded/fulltext_search_cache/builder_base_spec.rb
|
183
|
-
- spec/skip_embedded/fulltext_search_cache/mediator_spec.rb
|
184
|
-
- spec/skip_embedded/fulltext_search_cache/partial_loader_spec.rb
|
185
199
|
- spec/skip_embedded/initial_setting_spec.rb
|
186
|
-
- spec/skip_embedded/
|
200
|
+
- spec/skip_embedded/validations_file_spec.rb
|
187
201
|
- spec/skip_embedded/web_service_util_spec.rb
|
202
|
+
- spec/skip_embedded/op_fixation_spec.rb
|
203
|
+
- spec/skip_embedded/fulltext_search_cache/mediator_spec.rb
|
204
|
+
- spec/skip_embedded/fulltext_search_cache/partial_loader_spec.rb
|
205
|
+
- spec/skip_embedded/fulltext_search_cache/builder_base_spec.rb
|