Permalink
Browse files

Forgot those

  • Loading branch information...
1 parent 8d489f7 commit 736e1befee6b4c1569c6900495a1701bb5c58919 @bbenezech committed Aug 19, 2009
Showing with 273 additions and 0 deletions.
  1. +20 −0 MIT-LICENSE
  2. +62 −0 README.rdoc
  3. +23 −0 Rakefile
  4. +150 −0 example-template.rb
  5. +10 −0 init.rb
  6. +7 −0 install.rb
  7. +1 −0 uninstall.rb
View
@@ -0,0 +1,20 @@
+Copyright (c) 2009 [name of plugin creator]
+
+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.
View
@@ -0,0 +1,62 @@
+= Papermill
+
+Asset management made easy.. Painfully easy.
+Try the demo to see for yourself.
+
+See papermill_module.rb for a complete list of available options.
+These options can be application wide, for a class, or set at the last moment for the helper.
+Or just use defaults, I try very hard to set them as logical as possible.
+
+In your model :
+
+ papermill :assets
+
+In your layout :
+ <%= papermill_stylesheet_tag %>
+ <%= papermill_javascript_tag :with_jquery => true %>
+
+In your edit form :
+
+ f.images_upload(:my_image_gallery)
+ f.image_upload(:header_image)
+
+Finally, in your views :
+
+ # Some template image :
+ <%= image_tag @article.assets(:header_image).first.url("800x>") %>
+
+ # Some image gallery :
+ <ul>
+ <% @article.assets(:my_image_gallery).each do |image| %>
+ <li><%= link_to(image_tag(image.url("100x100>")), image.url) %></li>
+ <% end %>
+ </ul>
+
+
+== Word of caution :
+
+Beta.
+
+This is xNIX only (system("rm ...")).
+
+You'll need rails 2.3, since this is an engine. Anyway, copying the controller/view/routes to your project will make it work on an older version of rails.
+
+You'll need rails 2.2, since their are calls to I18n.t. But it shouldn't be too hard to work-around either.
+
+== Usage :
+
+=== Demo :
+
+You can use the custom template generator (save it to your ruby development directory) to get an example application up and running in no time.
+
+Also see exemple-template.rb to get up-to-date installation steps.
+
+ rails -m path/to/exemple-template.rb papermill-example
+
+=== Translation :
+
+Papermill is fully Rails 2.2 I18n-able.
+
+Copy config/locale/papermill.yml to your root config/locale folder to modify any wording in a any locale.
+
+Copyright (c) 2009 Benoit Bénézech, released under the MIT license
View
@@ -0,0 +1,23 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the papermill plugin.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the papermill plugin.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Papermill'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
View
@@ -0,0 +1,150 @@
+#run "echo TODO > README"
+
+gem 'sqlite3-ruby', :lib => "sqlite3" # for the demo
+gem 'ryanb-acts-as-list', :lib => 'acts_as_list', :source => 'http://gems.github.com' # or any equivalent
+gem 'mime-types', :lib => 'mime/types' # Needed to get the right Mime::Type when uploading with swfupload. Can be removed if you override PapermillAsset#swfupload_data=
+gem "paperclip" # this is what it's all about.
+gem "rsl-stringex", :lib => "stringex", :source => 'http://gems.github.com' # needed for to_url. Can be removed easily if you provide another String#to_url.
+
+rake "gems:install"
+plugin "papermill", :git => "git://github.com/BBenezech/papermill.git"
+generate :papermill, "PapermillMigration"
+generate :scaffold, "article title:string"
+rake "db:migrate"
+
+git :init
+file ".gitignore", <<-END
+.DS_Store
+log/*.log
+tmp/**/*
+config/database.yml
+db/*.sqlite3
+END
+
+file "app/views/articles/edit.html.erb", <<-END
+<h1>Editing article</h1>
+
+<% form_for(@article) do |f| %>
+ <%= f.error_messages %>
+ <p>
+ <%= f.label :title %><br />
+ <%= f.text_field :title %>
+ </p>
+ <p>
+ <%= f.label :images %><br />
+ <%= f.images_upload(:images) %>
+ </p>
+ <p>
+ <%= f.label :image %><br />
+ <%= f.image_upload(:image) %>
+ </p>
+ <p>
+ <%= f.label :assets %><br />
+ <%= f.assets_upload(:assets) %>
+ </p>
+ <p>
+ <%= f.label :asset %><br />
+ <%= f.asset_upload(:asset) %>
+ </p>
+ <p>
+ <%= f.submit 'Update' %>
+ </p>
+<% end %>
+
+<%= link_to 'Show', @article %> |
+<%= link_to 'Back', articles_path %>
+END
+
+file "app/views/articles/new.html.erb", <<-END
+<h1>New article</h1>
+
+<% form_for(@article) do |f| %>
+ <%= f.error_messages %>
+ <p>
+ <%= f.label :title %><br />
+ <%= f.text_field :title %>
+ </p>
+ <p>
+ <%= f.label :images %><br />
+ <%= f.images_upload(:images) %>
+ </p>
+ <p>
+ <%= f.label :image %><br />
+ <%= f.image_upload(:image) %>
+ </p>
+ <p>
+ <%= f.label :assets %><br />
+ <%= f.assets_upload(:assets) %>
+ </p>
+ <p>
+ <%= f.label :asset %><br />
+ <%= f.asset_upload(:asset) %>
+ </p>
+ <p>
+ <%= f.submit 'Create' %>
+ </p>
+<% end %>
+
+<%= link_to 'Back', articles_path %>END
+
+
+file "app/views/articles/show.html.erb", <<-END
+<p>
+ <b>Title:</b>
+ <%=h @article.title %>
+</p>
+<p>
+ <% @article.assets(:images).each do |image| %>
+ <%= link_to(image_tag(image.url("100x100#")), image.url) %>
+ <% end %>
+</p>
+<p>
+ <% image = @article.asset(:image) %>
+ <%= link_to(image_tag(image.url("100x100#")), image.url) if image %>
+</p>
+<p>
+ <ul>
+ <% @article.assets(:assets).each do |asset| %>
+ <li><%= link_to asset.name, asset.url %></li>
+ <% end %>
+ </ul>
+</p>
+<p>
+ <% asset = @article.asset(:asset) %>
+ <%= link_to(asset.name, asset.url) if asset %>
+</p>
+
+<%= link_to 'Edit', edit_article_path(@article) %> |
+<%= link_to 'Back', articles_path %>
+END
+
+
+
+file "app/views/layouts/application.html.erb", <<-END
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
+ <title>Papermill Demo</title>
+ <%= stylesheet_link_tag 'scaffold' %>
+ <%= papermill_stylesheet_tag %>
+ </head>
+ <body>
+ <%= yield %>
+ </body>
+ <%= papermill_javascript_tag :with_jquery => true %>
+</html>
+END
+
+file "app/models/article.rb", <<-END
+ class Article < ActiveRecord::Base
+ papermill
+ end
+END
+run "rm app/views/layouts/articles.html.erb"
+run "rm public/index.html"
+route "map.root :controller => 'articles'"
+
+git :add => ".", :commit => "-m 'initial commit'"
View
10 init.rb
@@ -0,0 +1,10 @@
+require 'core_extensions'
+Object.send :include, ObjectExtensions
+Hash.send :include, HashExtensions
+String.send :include, StringExtensions
+
+I18n.load_path = [File.join(File.dirname(__FILE__), 'config/locale/papermill.yml')] + I18n.load_path
+
+require 'papermill'
+ActionView::Base.send :include, PapermillHelper
+ActiveRecord::Base.send :include, Papermill
View
@@ -0,0 +1,7 @@
+require "fileutils"
+
+FileUtils.cp_r(
+ Dir[File.join(File.dirname(__FILE__), 'public')],
+ File.join(RAILS_ROOT),
+ :verbose => true
+)
View
@@ -0,0 +1 @@
+# Uninstall hook code here

0 comments on commit 736e1be

Please sign in to comment.