redactor_s3 0.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e12f897ffc4c3a07d5d402817df954c4174f27cc
4
+ data.tar.gz: ee4b26125ff17eeb3aa9d4927fdc1f29b8616966
5
+ SHA512:
6
+ metadata.gz: eca361228fc7b10f3fac57e72fc715197a6e6a614f5f0a858f9ef90499884357bd8401a6addde6f910e9c4ee29a36c20a7b0b048540e3cc97ff3f3d481983bb7
7
+ data.tar.gz: 46cc3a4730abfadf02f3e332c32fcbad6d73807d685a7a9e1971ccd50d4b131843e404f7d5288d339fcaa869d9def906d0731232a643909e517ed15f472ba400
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = RedactorS3
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RedactorS3'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ module RedactorS3
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,19 @@
1
+ require_dependency "redactor_s3/application_controller"
2
+ require_dependency "aws-sdk"
3
+ require_dependency "jbuilder"
4
+
5
+ module RedactorS3
6
+ class FilesController < ApplicationController
7
+ def success
8
+ settings = Settings.new
9
+ render json: { filelink: "http://#{settings.s3_host}/#{params[:key]}" }
10
+ end
11
+
12
+ def index
13
+ @settings = Settings.new
14
+ s3 = AWS::S3.new access_key_id: @settings.access_key, secret_access_key: @settings.secret_key, s3_endpoint: @settings.endpoint
15
+ bucket = s3.buckets[@settings.bucket]
16
+ @files = bucket.objects.with_prefix(@settings.prefix)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ module RedactorS3
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module RedactorS3
2
+ module FilesHelper
3
+ end
4
+ end
@@ -0,0 +1,43 @@
1
+ module RedactorS3
2
+ class Settings
3
+ attr_accessor :application_host, :bucket, :access_key, :secret_key, :endpoint, :s3_host, :prefix
4
+
5
+ def initialize
6
+ @application_host = RedactorS3.application_host
7
+ @bucket = RedactorS3.bucket
8
+ @access_key = RedactorS3.access_key
9
+ @secret_key = RedactorS3.secret_key
10
+
11
+ @endpoint = RedactorS3.endpoint || 's3.amazonaws.com'
12
+ @s3_host = RedactorS3.s3_host || "#{@bucket}.#{@endpoint}"
13
+ @prefix = RedactorS3.prefix || 'files/'
14
+ end
15
+
16
+ def bucket_url
17
+ "http://#{@bucket}.#{@endpoint}"
18
+ end
19
+
20
+ def success_url
21
+ "http://#{@application_host}/s3/success"
22
+ end
23
+
24
+ def policy
25
+ policy_json="{'expiration': '2020-01-01T00:00:00Z',
26
+ 'conditions': [
27
+ {'bucket': '#{@bucket}'},
28
+ ['starts-with', '$key', ''],
29
+ {'acl': 'public-read'},
30
+ {'success_action_redirect': '#{success_url}'},
31
+ ['starts-with', '$Content-Type', ''],
32
+ ['content-length-range', 0, 1048576]
33
+ ]
34
+ }"
35
+
36
+ Base64.encode64(policy_json).gsub("\n","")
37
+ end
38
+
39
+ def signature
40
+ Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest::Digest.new('sha1'), @secret_key, policy)).gsub("\n","")
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>RedactorS3</title>
5
+ <%= stylesheet_link_tag "redactor_s3/application", media: "all" %>
6
+ <%= javascript_include_tag "redactor_s3/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,10 @@
1
+ <% settings = RedactorS3::Settings.new %>
2
+ <input type="hidden" id="aws_key" name="aws_key" value="<%= settings.prefix %>${filename}">
3
+ <input type="hidden" id="aws_access_key" name="aws_access_key" value="<%= settings.access_key %>">
4
+ <input type="hidden" id="aws_acl" name="aws_acl" value="public-read">
5
+ <input type="hidden" id="aws_success_path" name="aws_success_path" value="<%= settings.success_url %>">
6
+ <input type="hidden" id="aws_policy" name="aws_policy" value="<%= settings.policy %>">
7
+ <input type="hidden" id="aws_signature" name="aws_signature" value="<%= settings.signature %>">
8
+ <input type="hidden" id="aws_content_type" name="aws_content_type" value="">
9
+ <input type="hidden" id="aws_endpoint" name="aws_endpoint" value="<%= settings.bucket_url %>">
10
+ <input type="hidden" id="aws_files_path" name="aws_files_path" value="/s3/files">
@@ -0,0 +1,4 @@
1
+ json.array! @files do |file|
2
+ json.thumb "#{@settings.bucket_url}/#{file.key}"
3
+ json.image "#{@settings.bucket_url}/#{file.key}"
4
+ end
@@ -0,0 +1,11 @@
1
+ # # These are required options
2
+ # RedactorS3.application_host = 'www.example.com' # your domain
3
+ # RedactorS3.bucket = 'mybucket' # your s3 bucket name
4
+ # RedactorS3.access_key = 'AWS_ACCESS_KEY_ID' # your aws access key id
5
+ # RedactorS3.secret_key = 'AWS_SECRET_ACCESS_KEY' #your aws secret access key
6
+
7
+
8
+ # # These are optinal options
9
+ # RedactorS3.endpoint = 's3-eu-west-1.amazonaws.com' # use this for eu buckets
10
+ # RedactorS3.s3_host = 'mybucket.example.com' # use this if you have a alias for your s3 bucket
11
+ # RedactorS3.prefix = 'files' # all uploads goes the this folder
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ RedactorS3::Engine.routes.draw do
2
+ get "success" => "files#success"
3
+ get "files" => "files#index"
4
+ end
@@ -0,0 +1,5 @@
1
+ require "redactor_s3/engine"
2
+
3
+ module RedactorS3
4
+ mattr_accessor :application_host, :access_key, :secret_key, :bucket, :s3_host, :endpoint, :prefix
5
+ end
@@ -0,0 +1,8 @@
1
+ module RedactorS3
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RedactorS3
4
+ config.generators do |g|
5
+ g.test_framework :rspec, :view_specs => false
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module RedactorS3
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :redactor_s3 do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redactor_s3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Aske Hansen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: aws-sdk
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jbuilder
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: This gem makes it easy to integrate redactor.js with amazon s3
84
+ email:
85
+ - aske@deeco.dk
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - app/assets/javascripts/redactor_s3/application.js
91
+ - app/assets/javascripts/redactor_s3/files.js
92
+ - app/assets/stylesheets/redactor_s3/application.css
93
+ - app/assets/stylesheets/redactor_s3/files.css
94
+ - app/controllers/redactor_s3/application_controller.rb
95
+ - app/controllers/redactor_s3/files_controller.rb
96
+ - app/helpers/redactor_s3/application_helper.rb
97
+ - app/helpers/redactor_s3/files_helper.rb
98
+ - app/models/redactor_s3/settings.rb
99
+ - app/views/layouts/redactor_s3/application.html.erb
100
+ - app/views/redactor_s3/files/_config.html.erb
101
+ - app/views/redactor_s3/files/index.jbuilder
102
+ - config/initializers/redactor_s3.rb
103
+ - config/routes.rb
104
+ - lib/redactor_s3/engine.rb
105
+ - lib/redactor_s3/version.rb
106
+ - lib/redactor_s3.rb
107
+ - lib/tasks/redactor_s3_tasks.rake
108
+ - MIT-LICENSE
109
+ - Rakefile
110
+ - README.rdoc
111
+ homepage: https://github.com/askehansen/redactor_s3
112
+ licenses: []
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.0.2
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Integrate redactor.js and amazon s3
134
+ test_files: []