Skip to content

Commit

Permalink
OS release
Browse files Browse the repository at this point in the history
  • Loading branch information
disolovyov committed Nov 2, 2012
0 parents commit 6a0571f
Show file tree
Hide file tree
Showing 103 changed files with 9,711 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.bundle/
log/*.log
pkg/
test/dummy/db/*.sqlite3
test/dummy/log/*.log
test/dummy/tmp/
test/dummy/.sass-cache
.DS_Store
vendor/bundle
test/dummy/vendor/bundle

.sass-cache

Gemfile.lock
test/dummy/Gemfile.lock
fog_credentials.yml
*.sublime-*
tmp/cache

30 changes: 30 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
source "http://rubygems.org"

# Declare your gem's dependencies in uploadcare-widget.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec

# jquery-rails is used by the dummy application
gem "jquery-rails"

# Declare any dependencies that are still in development here instead of in
# your gemspec. These might include edge Rails or gems from your path or
# Git. Remember to move these dependencies to your gemspec before releasing
# your gem to rubygems.org.

# To use debugger
# gem 'debugger'


gem 'rails', '3.2.8'
gem 'pry'
gem 'pry-rails'
gem 'sprockets'
gem 'sprockets-rails'
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'bourbon'
gem 'jquery-rails'
gem 'yui-compressor'
gem 'fog'
20 changes: 20 additions & 0 deletions MIT-LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright 2012 YOURNAME

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 changes: 27 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
This is the [Uploadcare](http://uploadcare.com) widget source.
It can also be used as an ordinary Rails plugin.

## Rails Plugin

Add `uploadcare-widget` to your Gemfile in the `assets` section
and add this line to your JavaScript:

// = require uploadcare/widget

... and to your CSS:

// = require uploadcare/widget

The official [Uploadcare documentation](http://uploadcare.com/documentation/)
has more information on using the widget itself.

## Building Your Own

You need a working Ruby 1.9 environment with [Bundler](http://gembundler.com/).

* `bundle install` to get build dependencies.
* `bundle exec rake js:latest:build` to build assets
to the **pkg/latest** directory (with the “latest” suffix).
* `bundle exec rake js:release:build` to build assets
to the **pkg/version** folder (with the current version suffix).
The version is specified in `lib/uploadcare-widget/version.rb`.
193 changes: 193 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
#!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'UploadcareWidget'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')
rdoc.rdoc_files.include('lib/**/*.rb')
end


Bundler::GemHelper.install_tasks

require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end


task :default => :test

def in_root(file)
File.expand_path("../#{file}", __FILE__)
end

def write_file(filename, contents)
dir = in_root(File.join('pkg', File.dirname(filename)))
FileUtils.mkdir_p(dir) unless Dir.exists?(dir)
widget_path = in_root("pkg/#{filename}")
File.open(widget_path, "wb") do |f|
f.write(contents)
end
puts "Created #{widget_path}"
end

def upload_file(bucket_name, credentials, filename, key, content_type)
storage = Fog::Storage.new credentials
directory = storage.directories.get(bucket_name)

file = directory.files.create(
key: key,
body: File.read(in_root("pkg/#{filename}")),
public: true,
content_type: content_type
)
puts "Uploaded #{CGI::unescape file.public_url}"
end

def setup_prefix(version)
Rails.application.config.assets.prefix = "widget/#{version}"
end

def header_comment(version)
<<-eos
/*
* Uploadcare (#{version})
* Date: #{Time.now}
* Rev: #{`git rev-parse --verify HEAD`[0..9]}
*/
eos
end

def build_widget(version)
comment = header_comment(version)
js = Rails.application.assets['uploadcare/widget.js'].source

write_file(
"#{version}/uploadcare-#{version}.min.js",
comment + YUI::JavaScriptCompressor.new.compress(js)
)
write_file(
"#{version}/uploadcare-#{version}.js",
comment + js
)

css = Rails.application.assets['uploadcare/widget.css'].source
write_file(
"#{version}/widget.css",
comment + YUI::CssCompressor.new.compress(css)
)

write_file(
"#{version}/zerospace-webfont.eot",
Rails.application.assets['inline-blocks/zerospace-webfont.eot'].source
)
end

def upload_widget(version)
credentials = {
fog: {
provider: 'AWS',
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
aws_secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
},
bucket_name: ENV['AWS_BUCKET_NAME']
}

upload_file(credentials[:bucket_name], credentials[:fog],
"#{version}/uploadcare-#{version}.min.js",
"#{Rails.application.config.assets.prefix}/uploadcare/uploadcare-#{version}.min.js",
'application/javascript'
)
upload_file(credentials[:bucket_name], credentials[:fog],
"#{version}/uploadcare-#{version}.js",
"#{Rails.application.config.assets.prefix}/uploadcare/uploadcare-#{version}.js",
'application/javascript'
)

upload_file(credentials[:bucket_name], credentials[:fog],
"#{version}/widget.css",
"#{Rails.application.config.assets.prefix}/uploadcare/widget.css",
'text/css'
)
upload_file(credentials[:bucket_name], credentials[:fog],
"#{version}/zerospace-webfont.eot",
"#{Rails.application.config.assets.prefix}/inline-blocks/zerospace-webfont.eot",
'application/vnd.ms-fontobject'
)
end

namespace :js do
task :application do
require 'rubygems'
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __FILE__)
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
# require "active_record/railtie"
require "action_controller/railtie"
require "active_resource/railtie"
require "sprockets/railtie"

if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test)))
end

class Application < Rails::Application
config.encoding = "utf-8"
config.assets.enabled = true
config.assets.version = rand # no cache
config.assets.compress = false
config.assets.compile = true
config.assets.digest = false
config.assets.debug = false

config.active_support.deprecation = :notify
config.assets.js_compressor = :yui
config.action_controller.asset_host = 'https://ucarecdn.com'
end
Application.initialize!
end

namespace :latest do
task build: [:application] do
setup_prefix('latest')
build_widget('latest')
end

task upload: [:application] do
setup_prefix('latest')
upload_widget('latest')
end
end

namespace :release do
task build: [:application] do
setup_prefix(UploadcareWidget::VERSION)
build_widget(UploadcareWidget::VERSION)
end

task upload: [:application] do
setup_prefix(UploadcareWidget::VERSION)
upload_widget(UploadcareWidget::VERSION)
end
end

task latest: ["latest:build", "latest:upload"]
task release: ["release:build", "release:upload"]
end
Binary file added app/assets/images/uploadcare/buttons.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/uploadcare/dialog-support.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/uploadcare/dialog-tabs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
7 changes: 7 additions & 0 deletions app/assets/javascripts/uploadcare/core/boot.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# = require ./coffeescript_extensions
# = require ./initialize
# = require ./jquery
# = require ./jquery-role
# = require ./raphael
# ≠ require ./testing
# = require ./pusher
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
window.uploadcare ||= new Object

((glob) ->
glob.namespace = (target, name, block) ->
[target, name, block] = [(if typeof exports isnt 'undefined' then exports else window), arguments...] if arguments.length < 3
top = target
target = target[item] or= {} for item in name.split '.'
block target, top

glob.extend = (obj, mixin) ->
for name, method of mixin
obj[name] = method

glob.include = (klass, mixin) ->
glob.extend klass.prototype, mixin
) window.uploadcare
Loading

0 comments on commit 6a0571f

Please sign in to comment.