Project

General

Profile

« Previous | Next » 

Revision b689e231

Added by Marc Dequènes over 15 years ago

  • ID b689e2317b0b8e1772a0ff52ce619090038d98dc

Initial version

View differences:

.htaccess
# General Apache options
<IfModule mod_fastcgi.c>
AddHandler fastcgi-script .fcgi
</IfModule>
<IfModule mod_fcgid.c>
AddHandler fcgid-script .fcgi
</IfModule>
<IfModule mod_cgi.c>
AddHandler cgi-script .cgi
</IfModule>
Options +FollowSymLinks +ExecCGI
# If you don't want Rails to look in certain directories,
# use the following rewrite rules so that Apache won't rewrite certain requests
#
# Example:
# RewriteCond %{REQUEST_URI} ^/notrails.*
# RewriteRule .* - [L]
# Redirect all requests not available on the filesystem to Rails
# By default the cgi dispatcher is used which is very slow
#
# For better performance replace the dispatcher with the fastcgi one
#
# Example:
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
RewriteEngine On
# If your Rails application is accessed via an Alias directive,
# then you MUST also set the RewriteBase in this htaccess file.
#
# Example:
# Alias /myrailsapp /path/to/myrailsapp/public
# RewriteBase /myrailsapp
RewriteRule ^$ index.html [QSA]
RewriteRule ^([^.]+)$ $1.html [QSA]
RewriteCond %{REQUEST_FILENAME} !-f
#<IfModule mod_fastcgi.c>
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
#</IfModule>
#<IfModule mod_fcgid.c>
# RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
#</IfModule>
<IfModule mod_cgi.c>
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
</IfModule>
# In case Rails experiences terminal errors
# Instead of displaying this message you can supply a file here which will be rendered instead
#
# Example:
# ErrorDocument 500 /500.html
ErrorDocument 500 "<h2>Application error</h2>Rails application failed to start properly"
README
== Welcome to Rails
Rails is a web-application and persistence framework that includes everything
needed to create database-backed web-applications according to the
Model-View-Control pattern of separation. This pattern splits the view (also
called the presentation) into "dumb" templates that are primarily responsible
for inserting pre-built data in between HTML tags. The model contains the
"smart" domain objects (such as Account, Product, Person, Post) that holds all
the business logic and knows how to persist themselves to a database. The
controller handles the incoming requests (such as Save New Account, Update
Product, Show Post) by manipulating the model and directing data to the view.
In Rails, the model is handled by what's called an object-relational mapping
layer entitled Active Record. This layer allows you to present the data from
database rows as objects and embellish these data objects with business logic
methods. You can read more about Active Record in
link:files/vendor/rails/activerecord/README.html.
The controller and view are handled by the Action Pack, which handles both
layers by its two parts: Action View and Action Controller. These two layers
are bundled in a single package due to their heavy interdependence. This is
unlike the relationship between the Active Record and Action Pack that is much
more separate. Each of these packages can be used independently outside of
Rails. You can read more about Action Pack in
link:files/vendor/rails/actionpack/README.html.
== Getting Started
1. At the command prompt, start a new Rails application using the <tt>rails</tt> command
and your application name. Ex: rails myapp
(If you've downloaded Rails in a complete tgz or zip, this step is already done)
2. Change directory into myapp and start the web server: <tt>script/server</tt> (run with --help for options)
3. Go to http://localhost:3000/ and get "Welcome aboard: You’re riding the Rails!"
4. Follow the guidelines to start developing your application
== Web Servers
By default, Rails will try to use Mongrel and lighttpd if they are installed, otherwise
Rails will use WEBrick, the webserver that ships with Ruby. When you run script/server,
Rails will check if Mongrel exists, then lighttpd and finally fall back to WEBrick. This ensures
that you can always get up and running quickly.
Mongrel is a Ruby-based webserver with a C component (which requires compilation) that is
suitable for development and deployment of Rails applications. If you have Ruby Gems installed,
getting up and running with mongrel is as easy as: <tt>gem install mongrel</tt>.
More info at: http://mongrel.rubyforge.org
If Mongrel is not installed, Rails will look for lighttpd. It's considerably faster than
Mongrel and WEBrick and also suited for production use, but requires additional
installation and currently only works well on OS X/Unix (Windows users are encouraged
to start with Mongrel). We recommend version 1.4.11 and higher. You can download it from
http://www.lighttpd.net.
And finally, if neither Mongrel or lighttpd are installed, Rails will use the built-in Ruby
web server, WEBrick. WEBrick is a small Ruby web server suitable for development, but not
for production.
But of course its also possible to run Rails on any platform that supports FCGI.
Apache, LiteSpeed, IIS are just a few. For more information on FCGI,
please visit: http://wiki.rubyonrails.com/rails/pages/FastCGI
== Debugging Rails
Sometimes your application goes wrong. Fortunately there are a lot of tools that
will help you debug it and get it back on the rails.
First area to check is the application log files. Have "tail -f" commands running
on the server.log and development.log. Rails will automatically display debugging
and runtime information to these files. Debugging info will also be shown in the
browser on requests from 127.0.0.1.
You can also log your own messages directly into the log file from your code using
the Ruby logger class from inside your controllers. Example:
class WeblogController < ActionController::Base
def destroy
@weblog = Weblog.find(params[:id])
@weblog.destroy
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
end
end
The result will be a message in your log file along the lines of:
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1
More information on how to use the logger is at http://www.ruby-doc.org/core/
Also, Ruby documentation can be found at http://www.ruby-lang.org/ including:
* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
These two online (and free) books will bring you up to speed on the Ruby language
and also on programming in general.
== Debugger
Debugger support is available through the debugger command when you start your Mongrel or
Webrick server with --debugger. This means that you can break out of execution at any point
in the code, investigate and change the model, AND then resume execution! Example:
class WeblogController < ActionController::Base
def index
@posts = Post.find(:all)
debugger
end
end
So the controller will accept the action, run the first line, then present you
with a IRB prompt in the server window. Here you can do things like:
>> @posts.inspect
=> "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
#<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
>> @posts.first.title = "hello from a debugger"
=> "hello from a debugger"
...and even better is that you can examine how your runtime objects actually work:
>> f = @posts.first
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
>> f.
Display all 152 possibilities? (y or n)
Finally, when you're ready to resume execution, you enter "cont"
== Console
You can interact with the domain model by starting the console through <tt>script/console</tt>.
Here you'll have all parts of the application configured, just like it is when the
application is running. You can inspect domain models, change values, and save to the
database. Starting the script without arguments will launch it in the development environment.
Passing an argument will specify a different environment, like <tt>script/console production</tt>.
To reload your controllers and models after launching the console run <tt>reload!</tt>
== Description of Contents
app
Holds all the code that's specific to this particular application.
app/controllers
Holds controllers that should be named like weblogs_controller.rb for
automated URL mapping. All controllers should descend from ApplicationController
which itself descends from ActionController::Base.
app/models
Holds models that should be named like post.rb.
Most models will descend from ActiveRecord::Base.
app/views
Holds the template files for the view that should be named like
weblogs/index.erb for the WeblogsController#index action. All views use eRuby
syntax.
app/views/layouts
Holds the template files for layouts to be used with views. This models the common
header/footer method of wrapping views. In your views, define a layout using the
<tt>layout :default</tt> and create a file named default.erb. Inside default.erb,
call <% yield %> to render the view using this layout.
app/helpers
Holds view helpers that should be named like weblogs_helper.rb. These are generated
for you automatically when using script/generate for controllers. Helpers can be used to
wrap functionality for your views into methods.
config
Configuration files for the Rails environment, the routing map, the database, and other dependencies.
db
Contains the database schema in schema.rb. db/migrate contains all
the sequence of Migrations for your schema.
doc
This directory is where your application documentation will be stored when generated
using <tt>rake doc:app</tt>
lib
Application specific libraries. Basically, any kind of custom code that doesn't
belong under controllers, models, or helpers. This directory is in the load path.
public
The directory available for the web server. Contains subdirectories for images, stylesheets,
and javascripts. Also contains the dispatchers and the default HTML files. This should be
set as the DOCUMENT_ROOT of your web server.
script
Helper scripts for automation and generation.
test
Unit and functional tests along with fixtures. When using the script/generate scripts, template
test files will be generated for you and placed in this directory.
vendor
External libraries that the application depends on. Also includes the plugins subdirectory.
This directory is in the load path.
Rakefile
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
TODO
Application:
Framework:
- finish restful_support rework (response handler at least)
- add proper CSS support to HtmlHelpers
app/controllers/admin.rb
module Admin
class AdminController < ApplicationController
end
end
app/controllers/admin/artwork_conditions_controller.rb
class Admin::ArtworkConditionsController < Admin::AdminController
simple_rest_support
end
app/controllers/admin/artwork_groups_controller.rb
class Admin::ArtworkGroupsController < Admin::AdminController
simple_rest_support ArtworkSet
def select_for_artwork_set
vars = {:form_object => params[:form_object], :form_field => params[:form_field], :artwork_set_id => params[:artwork_set_id]}
if params[:artwork_set_id] == params[:initial_artwork_set_id]
vars[:selected] = params[:initial_artwork_group_id].to_i
end
render :partial => action_name, :locals => vars
end
end
app/controllers/admin/artwork_materials_controller.rb
class Admin::ArtworkMaterialsController < Admin::AdminController
simple_rest_support
end
app/controllers/admin/artwork_placement_reasons_controller.rb
class Admin::ArtworkPlacementReasonsController < Admin::AdminController
simple_rest_support
end
app/controllers/admin/artwork_sets_controller.rb
class Admin::ArtworkSetsController < Admin::AdminController
simple_rest_support
end
app/controllers/admin/artwork_sizes_controller.rb
# arts uses centimeter and not milimeter, but mm is better for storage
class Admin::ArtworkSizesController < Admin::AdminController
simple_rest_support
private
def prepared_params
p = resource_params.dup
p[:height] = cm_to_mm(p[:height]) if p[:height]
p[:width] = cm_to_mm(p[:width]) if p[:width]
return p
end
def prepared_object(orig_artwork_size)
artwork_size = orig_artwork_size.dup
artwork_size.height = mm_to_cm(artwork_size.height)
artwork_size.width = mm_to_cm(artwork_size.width)
return artwork_size
end
end
app/controllers/admin/artwork_step_images_controller.rb
class Admin::ArtworkStepImagesController < Admin::AdminController
simple_rest_support Artwork
before_filter :load_form_data, :only => [:index]
private
def load_form_data
@artwork_step_images = @artwork.artwork_step_images.paginate(:all, :order => params[:sort], :page => params[:page])
end
end
app/controllers/admin/artworks_controller.rb
class Admin::ArtworksController < Admin::AdminController
simple_rest_support
before_filter :load_form_data, :only => [:new, :create, :edit, :update]
private
def load_form_data
@artwork_sets = ArtworkSet.find(:all, :order => "name ASC")
@artwork_materials = ArtworkMaterial.find(:all, :order => "name ASC")
@artwork_conditions = ArtworkCondition.find(:all, :order => "position ASC")
@artwork_placement_reasons = ArtworkPlacementReason.find(:all, :order => "name ASC")
@techniques = Technique.find(:all, :order => "name ASC")
end
end
app/controllers/admin/techniques_controller.rb
class Admin::TechniquesController < Admin::AdminController
simple_rest_support
end
app/controllers/application.rb
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
require 'gettext/rails'
require 'exif'
require 'utils'
require 'mycyma'
#Mime::Type.register "image/svg+xml", :svg
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
rescue_from RestfulSupport::ResourceNotFound, :with => :render_404
rescue_from RestfulSupport::UnrelatedResources, :with => :render_404
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => '86f01f14fc184c81bf152965a2bccb88'
init_gettext MyCyma::Info::app_name
def initialize
super
@config = MyCyma::Config.instance
end
def render_404
render :template => "common/404", :layout => ! request.xhr?, :status => :not_found
return false
end
end
app/controllers/mycyma_controller.rb
class MycymaController < ApplicationController
end
app/controllers/welcome_controller.rb
class WelcomeController < ApplicationController
end
app/helpers/application_helper.rb
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
ICONS_FORMAT = :png
ICONS_SIZES = {
:small => "22x22",
:medium => "24x24",
:large => "48x48"
}
ICONS_SUBPATH = "icon-set"
def self.included(base)
Object.const_set(:SORTABLE_COLUMN_ASC, icons_subpath("actions/down", :small)) unless Object.const_defined? :SORTABLE_COLUMN_ASC
Object.const_set(:SORTABLE_COLUMN_DESC, icons_subpath("actions/up", :small)) unless Object.const_defined? :SORTABLE_COLUMN_DESC
end
def observe_field_with_reload(field_id, options = {})
observe_field(field_id, options) + "\n" +
update_page_tag do |page|
page << "Event.observe(window, 'load', function() {"
page << "element = document.getElementById('#{field_id}');"
page << "value = element.value;"
page << remote_function(options)
page << "});"
end
end
def observe_field_trigger(field_id, with_reload = true)
update_page_tag do |page|
page << "new Form.Element.EventObserver('#{field_id}', function() {"
page << "element = document.getElementById('#{field_id}');"
page << "value = element.value;"
yield(page)
page << "});"
if with_reload
page << "Event.observe(window, 'load', function() {"
page << "element = document.getElementById('#{field_id}');"
page << "value = element.value;"
yield(page)
page << "});"
end
end
end
def render_flash_messages
html = ""
["error", "warning", "notice"].each do |type|
ve = visual_effect(:highlight, type, :duration => 2.0) + "\\n"
unless flash[type.intern].nil?
html << content_tag("div", flash[type.intern].to_s,
:id => type,
:class => "flash")
end
end
content_tag("div", html, :id => "flash")
end
def icons_subpath(image_name, size_name)
image_file = image_name + "." + ICONS_FORMAT.to_s
if ICONS_FORMAT == :svg
File.join(ICONS_SUBPATH, "scalable", image_file)
else
File.join(ICONS_SUBPATH, ICONS_SIZES[size_name], image_file)
end
end
module_function :icons_subpath
def display_icon_tag(image_name, size_name, html_options = {})
if ICONS_FORMAT == :svg
width, height = ICONS_SIZES[size_name].split("x")
"<object type=\"image/svg+xml\" data=\"#{path_to_image(icons_subpath(image_name, size_name))}\" width=\"#{width}\" height=\"#{height}\"/>"
else
image_tag icons_subpath(image_name, size_name), html_options
end
end
def display_image_submit_tag(image_name, size_name, html_options = {})
image_submit_tag icons_subpath(image_name, size_name), html_options
end
def display_standard_item_actions(obj = nil)
obj = resource_object if obj.nil?
res = resource_family(obj)
disp = ""
disp += link_to display_icon_tag('actions/document-properties', :medium, :title => _("Modify")), edit_polymorphic_path(res.dup)
disp += link_to display_icon_tag('actions/edit-delete', :medium, :title => _("Delete")), polymorphic_path(res.dup), :method => :delete, :confirm => _("Are you sure?")
return disp
end
def display_action_placeholder
"<div class='action-placeholder'> </div>"
end
# use with acts_as_lists
def display_list_item_actions(obj)
obj = resouce_object if obj.nil?
res = resource_family(obj)
path = polymorphic_url(res.dup, :action => "move", :routing_type => :path)
disp = ""
if obj.first?
2.times { disp += display_action_placeholder }
else
disp += link_to display_icon_tag('actions/go-top', :medium, :title => _("Move to top")), path + "?type=move_to_top", :method => :put
disp += link_to display_icon_tag('actions/go-up', :medium, :title => _("Move up")), path + "?type=move_higher", :method => :put
end
if obj.last?
2.times { disp += display_action_placeholder }
else
disp += link_to display_icon_tag('actions/go-down', :medium, :title => _("Move down")), path + "?type=move_lower", :method => :put
disp += link_to display_icon_tag('actions/go-bottom', :medium, :title => _("Move to bottom")), path + "?type=move_to_bottom", :method => :put
end
return disp
end
def display_new_action(text = nil)
text = sprintf(_("New %s"), _(resource_model.human_name)) if text.nil?
res = resource_family(resource_model.new)
link_to(display_icon_tag('actions/document-new', :medium, :title => text) +
" <span class=\"middle\">" + text + "</span>", new_polymorphic_path(res.dup))
end
def display_standard_form_buttons
res = resource_family(resource_model.new)
"<div class=\"actions\">" + display_image_submit_tag('actions/gtk-ok', :medium, :title => _("Add")) +
"<div class=\"big-action-placeholder\"></div>" +
link_to(display_icon_tag('actions/gtk-cancel', :medium, :title => _("Cancel")), polymorphic_path(res.dup)) +
"</div>"
end
def link_to_resource(obj, text)
link_to text, resource_path(obj)
end
def link_to_resource_index(text)
link_to(display_icon_tag('actions/document-open', :medium, :title => text) +
" <span class=\"middle\">" + text + "</span>", resource_index_path)
end
def display_alert(text)
"<p>" + display_icon_tag('status/important', :large, :title => _("Alert !") ) +
"<span class=\"alert\">" + text + "</span></p>"
end
def link_to_parent_resource_index(text)
link_to(display_icon_tag('actions/back', :medium, :title => text) +
" <span class=\"middle\">" + text + "</span>", parent_resource_index_path)
end
def blank_option
"<option value=\"\"></option>"
end
def title_option(text)
"<option value=\"\" disabled=\"disabled\">#{text}</option>"
end
def conditional_hidden_style(obj, field)
" style=\"display: none\";" unless obj and obj.send(field)
end
def link_to_child(obj, child, text)
link_to text, child_polymorphic_path(obj, child)
end
def link_to_children_index(obj, children_model, title, with_count = true, text = nil)
method = discover_associated_model_method(obj.class, children_model)
in_link = display_icon_tag('mimetypes/package', :medium, :title => title)
in_link += " <span class=\"middle\">#{text}</span>" if text
html = link_to(in_link, child_index_polymorphic_path(obj, children_model))
html += " (" + obj.send(method).size.to_s + ")" if with_count
return html
end
def display_boolean(bool, colors = true)
text = bool ? _("Yes") : _("No")
if colors
css_class = bool ? "boolean-true" : "boolean-false"
"<span class=\"#{css_class}\">#{text}</span>"
else
text
end
end
def display_timestamp(timestamp)
timestamp.strftime("%Y-%m-%d %H:%M") if timestamp
end
def display_list(list, ordered = false)
tag = (ordered) ? "ol" : "ul"
html = "<#{tag}>"
list.each {|el| html += "<li>#{el}</li>" }
html += "</#{tag}>"
end
def form_comment(cat)
cat.field :comment, _("Comment:") + sprintf(_("<br/>(with %s<br/>formating)"), link_to("Textile", "http://hobix.com/textile/", :popup => true)), :text_area, :cols => 60, :rows => 10
end
def table_comment(table, comment)
table.content [_("Comment:"), textilize(comment)]
end
def table_timestamp_info(table, obj)
table.content [_("Created at:"), obj.created_at]
table.content [_("Updated at:"), obj.updated_at]
end
def display_thumbnail(img, thumb_name = nil)
return if img.nil?
unless File.exists? img.full_filename(thumb_name)
img.saved_attachment = true
img.after_process_attachment
end
image_tag(img.public_filename(thumb_name))
end
end
app/helpers/html_builder_helper.rb
module HtmlBuilderHelper
def stacking_table(caption = nil, html_options = {}, &block)
HtmlBuilder::StackingTable.new(caption, html_options).build(&block)
end
def stacking_form(form, caption = nil, html_options = {}, &block)
HtmlBuilder::StackingForm.new(self, form, caption, html_options).build(&block)
end
def conditional_form_block(form, tag_id, obj, field, condition = "value != ''", &block)
HtmlBuilder::ConditionalFormBlock.new(self, form, tag_id, obj, field, condition).build(&block)
end
end
app/models/artwork.rb
class Artwork < ActiveRecord::Base
belongs_to :artwork_set
belongs_to :artwork_group
belongs_to :artwork_material
belongs_to :artwork_size
belongs_to :artwork_condition
belongs_to :artwork_placement_reason
has_many :artwork_step_images, :order => "date ASC"
has_and_belongs_to_many :techniques, :order => "name ASC"
validates_presence_of :title, :artwork_material_id, :artwork_size_id, :artwork_condition_id
validates_uniqueness_of :title
validates_length_of :title, :within => 1..256, :allow_blank => true
validates_length_of :placement_location, :within => 1..256, :allow_blank => true
validates_associated :artwork_set, :artwork_group, :artwork_material, :artwork_size, :artwork_condition
before_save {|model| model.artwork_group = nil if model.artwork_set.nil? }
def image
return nil if self.artwork_step_images.empty?
self.artwork_step_images.last
end
end
app/models/artwork_condition.rb
class ArtworkCondition < ActiveRecord::Base
has_many :artworks, :order => "title ASC"
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :within => 1..64, :allow_blank => true
acts_as_list
end
app/models/artwork_group.rb
class ArtworkGroup < ActiveRecord::Base
belongs_to :artwork_set
has_many :artworks, :order => "title ASC"
validates_presence_of :name, :artwork_set_id
validates_uniqueness_of :name
validates_length_of :name, :within => 1..128, :allow_blank => true
validates_associated :artwork_set
end
app/models/artwork_material.rb
class ArtworkMaterial < ActiveRecord::Base
has_many :artworks, :order => "title ASC"
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :within => 1..128, :allow_blank => true
end
app/models/artwork_placement_reason.rb
class ArtworkPlacementReason < ActiveRecord::Base
has_many :artworks, :order => "title ASC"
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :within => 1..64, :allow_blank => true
end
app/models/artwork_set.rb
class ArtworkSet < ActiveRecord::Base
has_many :artworks, :order => "title ASC"
has_many :artwork_groups, :order => "name ASC", :dependent => :destroy
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :within => 1..128, :allow_blank => true
end
app/models/artwork_size.rb
class ArtworkSize < ActiveRecord::Base
has_many :artworks, :order => "title ASC"
validates_presence_of :height, :width
validates_acceptance_of :height, :if => Proc.new {|artwork_size| artwork_size.height <= 0 }, :message => _("must be a positive non-zero number")
validates_acceptance_of :width, :if => Proc.new {|artwork_size| artwork_size.width <= 0 }, :message => _("must be a positive non-zero number")
validates_uniqueness_of :width, :scope => [:height], :message => _("is invalid, because this (height, width) couple already exist")
def human_size
"#{height} x #{width}"
end
end
app/models/artwork_step.rb
class ArtworkStep < ActiveRecord::Base
belongs_to :artwork
def self.base_upload_path
"public/images/artwork_steps"
end
def human_size
"#{height} x #{width}"
end
end
app/models/artwork_step_image.rb
class ArtworkStepImage < ArtworkStep
has_many :artwork_step_thumbnails, :foreign_key => 'parent_id'
has_attachment :content_type => :image,
:max_size => MyCyma::Config.instance.max_uploaded_image_size_mb.megabyte,
:storage => :file_system,
:path_prefix => base_upload_path(),
:thumbnails => MyCyma::Config.instance.thumbnail_param_list,
:thumbnail_class => ArtworkStepThumbnail
validates_presence_of :filename, :date, :artwork_id #, :void
validates_uniqueness_of :filename, :scope => :artwork_id
validates_as_attachment
public :after_process_attachment
attr_accessor :saved_attachment
end
app/models/artwork_step_thumbnail.rb
class ArtworkStepThumbnail < ArtworkStep
belongs_to :artwork_step_image, :foreign_key => 'parent_id'
has_attachment :content_type => :image,
:storage => :file_system,
:path_prefix => base_upload_path()
end
app/models/technique.rb
class Technique < ActiveRecord::Base
has_and_belongs_to_many :artworks, :order => "title ASC"
validates_presence_of :name
validates_uniqueness_of :name
validates_uniqueness_of :acronym, :allow_nil => true
validates_length_of :name, :within => 1..128, :allow_blank => true
validates_length_of :acronym, :within => 1..8, :allow_blank => true
end
app/views/admin/artwork_conditions/_form.rhtml
<p>
<%
form_for_resource do |f|
%>
<%=
stacking_form(f) do |table|
table.field :name, _("Name:"), :text_field
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_conditions/edit.rhtml
<h2><%= _("Modify Artwork Condition") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_conditions/index.rhtml
<h2><%= _("List of Artwork Conditions") %></h2>
<p>
<table>
<tr><th><%= _("Name") %></th><th><%= _("Actions") %></th></tr>
<% resource_model.find(:all, :order => "position ASC").each do |artwork_condition| %>
<tr><td><%= artwork_condition.name %></td><td class="actions"><%= display_list_item_actions(artwork_condition) %><%= display_standard_item_actions(artwork_condition) %></td></tr>
<% end %>
</table>
<%= display_new_action %>
</p>
app/views/admin/artwork_conditions/new.rhtml
<h2><%= _("New Artwork Condition") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Add")} %>
app/views/admin/artwork_conditions/show.rhtml
<h2><%= sprintf(_("Artwork Condition \#%u"), @artwork_condition.id) %></h2>
<p>
<%=
stacking_table do |table|
table.content [_("Name:"), @artwork_condition.name]
end
%>
<%= display_standard_item_actions %>
</p>
<p><%= link_to_resource_index _("Display all artwork conditions") %></p>
app/views/admin/artwork_groups/_form.rhtml
<p>
<%
form_for_resource do |f|
%>
<%=
stacking_form(f) do |table|
table.field :name, _("Name:"), :text_field
form_comment(table)
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_groups/_select_for_artwork_set.rhtml
<%-
if form_object and form_field and artwork_set_id and artwork_set_id != ""
obj_s = form_object.to_sym
field_s = form_field.to_sym
selected = nil unless defined?(selected)
el_id = "#{obj_s}_#{field_s}"
-%>
<option value=""></option>
<%= options_from_collection_for_select ArtworkGroup.find(:all, :conditions => {:artwork_set_id => artwork_set_id}, :order => "name ASC"), :id, :name, selected %>
<%=
update_page_tag do |page|
page << "$('#{el_id}').fire('change');"
end
%>
<%- end -%>
app/views/admin/artwork_groups/edit.rhtml
<h2><%= _("Modify Artwork Group") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_groups/index.rhtml
<h2><%= _("List of Artwork Groups in Set") %> '<%= link_to @artwork_set.name, parent_resource_path %>'</h2>
<p>
<table>
<tr><th><%= _("Name") %></th><th><%= _("Actions") %></th></tr>
<% @artwork_groups = @artwork_set.artwork_groups.paginate(:all, :order => "name ASC", :page => params[:page]) %>
<% @artwork_groups.each do |artwork_group| %>
<tr><td><%= artwork_group.name %></td><td class="actions"><%= display_standard_item_actions(artwork_group) %></td></tr>
<% end %>
</table>
<%= will_paginate @artwork_groups %>
<%= display_new_action %>
</p>
<p><%= link_to_parent_resource_index _("Back to artwork sets list") %></p>
app/views/admin/artwork_groups/new.rhtml
<h2><%= _("New Artwork Group") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Add")} %>
app/views/admin/artwork_groups/show.rhtml
<h2><%= sprintf(_("Artwork Group \#%u"), @artwork_group.id) %></h2>
<p>
<%=
stacking_table do |table|
table.content [_("Name:"), @artwork_group.name]
table_timestamp_info(table, @artwork_group)
table_comment(table, @artwork_group.comment)
end
%>
<%= display_standard_item_actions %>
</p>
<p><%= link_to_resource_index _("Display all artwork groups") %></p>
app/views/admin/artwork_materials/_form.rhtml
<p>
<%
form_for_resource do |f|
%>
<%=
stacking_form(f) do |table|
table.field :name, _("Name:"), :text_field
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_materials/edit.rhtml
<h2><%= _("Modify Artwork Material") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_materials/index.rhtml
<h2><%= _("List of Artwork Materials") %></h2>
<p>
<table>
<tr><th><%= _("Name") %></th><th><%= _("Actions") %></th></tr>
<% resource_model.find(:all, :order => "name ASC").each do |artwork_material| %>
<tr><td><%= artwork_material.name %></td><td class="actions"><%= display_standard_item_actions(artwork_material) %></td></tr>
<% end %>
</table>
<%= display_new_action %>
</p>
app/views/admin/artwork_materials/new.rhtml
<h2><%= _("New Artwork Material") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Add")} %>
app/views/admin/artwork_materials/show.rhtml
<h2><%= sprintf(_("Artwork Material \#%u"), @artwork_material.id) %></h2>
<p>
<%=
stacking_table do |table|
table.content [_("Name:"), @artwork_material.name]
end
%>
<%= display_standard_item_actions %>
</p>
<p><%= link_to_resource_index _("Display all artwork materials") %></p>
app/views/admin/artwork_placement_reasons/_form.rhtml
<p>
<%
form_for_resource do |f|
%>
<%=
stacking_form(f) do |table|
table.field :name, _("Name:"), :text_field
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_placement_reasons/edit.rhtml
<h2><%= _("Modify Artwork Placement Reason") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_placement_reasons/index.rhtml
<h2><%= _("List of Artwork Placement Reasons") %></h2>
<p>
<table>
<tr><th><%= _("Name") %></th><th><%= _("Actions") %></th></tr>
<% resource_model.find(:all, :order => "name ASC").each do |artwork_placement_reason| %>
<tr><td><%= artwork_placement_reason.name %></td><td class="actions"><%= display_standard_item_actions(artwork_placement_reason) %></td></tr>
<% end %>
</table>
<%= display_new_action %>
</p>
app/views/admin/artwork_placement_reasons/new.rhtml
<h2><%= _("New Artwork Placement Reason") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Add")} %>
app/views/admin/artwork_placement_reasons/show.rhtml
<h2><%= sprintf(_("Artwork Placement Reason \#%u"), @artwork_placement_reason.id) %></h2>
<p>
<%=
stacking_table do |table|
table.content [_("Name:"), @artwork_placement_reason.name]
end
%>
<%= display_standard_item_actions %>
</p>
<p><%= link_to_resource_index _("Display all artwork materials") %></p>
app/views/admin/artwork_sets/_form.rhtml
<p>
<%
form_for_resource do |f|
%>
<%=
stacking_form(f) do |table|
table.field :name, _("Name:"), :text_field
form_comment(table)
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_sets/edit.rhtml
<h2><%= _("Modify Artwork Set") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_sets/index.rhtml
<h2><%= _("List of Artwork Sets") %></h2>
<p>
<table>
<tr><th><%= _("Name") %></th><th><%= _("Groups") %></th><th><%= _("Actions") %></th></tr>
<% @artwork_sets = resource_model.paginate(:all, :order => "name ASC", :page => params[:page]) %>
<% @artwork_sets.each do |artwork_set| %>
<tr><td><%= artwork_set.name %></td><td class="resource_children"><%= link_to_children_index artwork_set, ArtworkGroup, _("View Groups") %></td><td class="actions"><%= display_standard_item_actions(artwork_set) %></span></td></tr>
<% end %>
</table>
<%= will_paginate @artwork_sets %>
<%= display_new_action %>
</p>
app/views/admin/artwork_sets/new.rhtml
<h2><%= _("New Artwork Set") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Add")} %>
app/views/admin/artwork_sets/show.rhtml
<h2><%= sprintf(_("Artwork Set \#%u"), @artwork_set.id) %></h2>
<p>
<%=
stacking_table do |table|
table.content [_("Name:"), @artwork_set.name]
table_timestamp_info(table, @artwork_set)
table_comment(table, @artwork_set.comment)
end
%>
<%= display_standard_item_actions %>
</p>
<p><%= link_to_resource_index _("Display all sets") %></p>
app/views/admin/artwork_sizes/_form.rhtml
<p>
<%
form_for_resource do |f|
%>
<%=
stacking_form(f) do |table|
table.field :height, _("Height (cm):"), :text_field, :value => mm_to_cm(@artwork_size.height), :size => 5
table.field :width, _("Width (cm):"), :text_field, :value => mm_to_cm(@artwork_size.width), :size => 5
table.field :standard, _("Standard?"), :check_box
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_sizes/_selector.rhtml
<%
standard_sizes = options_from_collection_for_select ArtworkSize.find(:all, :order => "height ASC, width ASC", :conditions => {:standard => true}), :id, :human_size
custom_sizes = options_from_collection_for_select ArtworkSize.find(:all, :order => "height ASC, width ASC", :conditions => {:standard => false}), :id, :human_size
sizes_choice = title_option(_("== Standard Sizes ==")) + standard_sizes + title_option(_("== Custom Sizes ==")) + custom_sizes
%>
<select id="<%= form_object %>_<%= form_field %>" name="<%= form_object %>[<%= form_field%>]"><%= sizes_choice %></select>
app/views/admin/artwork_sizes/edit.rhtml
<h2><%= _("Modify Artwork Size") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_sizes/index.rhtml
<h2><%= _("List of Artwork Sizes") %></h2>
<p>
<table>
<tr><th><%= _("Height (cm)") %></th><th><%= _("Width (cm)") %></th><th><%= _("Standard?") %></th><th><%= _("Actions") %></th></tr>
<% resource_model.find(:all, :order => "height ASC, width ASC").each do |artwork_size| %>
<tr><td><%= mm_to_cm(artwork_size.height) %></td><td><%= mm_to_cm(artwork_size.width) %></td><td><%= artwork_size.standard ? _("Yes") : _("No") %></td><td class="actions"><%= display_standard_item_actions(artwork_size) %></td></tr>
<% end %>
</table>
<%= display_new_action %>
</p>
app/views/admin/artwork_sizes/new.rhtml
<h2><%= _("New Artwork Size") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Add")} %>
app/views/admin/artwork_sizes/show.rhtml
<h2><%= sprintf(_("Artwork Size \#%u"), @artwork_size.id) %></h2>
<p>
<%=
stacking_table do |table|
table.content [_("Height (cm):"), mm_to_cm(@artwork_size.height)]
table.content [_("Width (cm):"), mm_to_cm(@artwork_size.width)]
table.content [_("Standard?"), display_boolean(@artwork_size.standard)]
end
%>
<%= display_standard_item_actions %>
</p>
<p><%= link_to_resource_index _("Display all artwork sizes") %></p>
app/views/admin/artwork_step_images/_form.rhtml
<p>
<%
form_for_resource :html => {:multipart => true} do |f|
%>
<%=
stacking_form(f) do |table|
table.field :date, _("Date:"), :date_select
table.field :uploaded_data, _("Image:"), :file_field
form_comment(table)
table.content display_standard_form_buttons
end
%>
<%
end
%>
</p>
app/views/admin/artwork_step_images/edit.rhtml
<h2><%= _("Modify Artwork Step") %></h2>
<%= error_messages_for_resource %>
<%= render :partial => "form", :locals => {:submit_label => _("Modify")} %>
app/views/admin/artwork_step_images/index.rhtml
<h2><%= sprintf(_("Steps in Artwork '%s'"), @artwork.title) %></h2>
<% repeat_links_size = 3 %>
<% if @artwork_step_images.size > repeat_links_size %>
<p><%= link_to_parent_resource_index _("Back to artworks list") %></p>
<% end %>
<p>
<% if @artwork_step_images.size > repeat_links_size %>
<%= display_new_action _("New artwork step") %>
<%= will_paginate @artwork_step_images %>
<% end %>
<table>
<tr>
<th><%= sortable_header :date, :label => _("Date"), :default => true %></th>
<th><%= _("Preview") %></th>
<th><%= _("Actions") %></th>
</tr>
<% @artwork_step_images.each do |artwork_step_image| %>
<tr>
<td><%= artwork_step_image.date %></td>
<td><%= link_to_resource artwork_step_image, display_thumbnail(artwork_step_image, :thumb_big) %></td>
<td class="actions"><%= display_standard_item_actions(artwork_step_image) %></td>
</tr>
<% end %>
</table>
<%= will_paginate @artwork_step_images %>
<%= display_new_action _("New artwork step") %>
</p>
<p><%= link_to_parent_resource_index _("Back to artworks list") %></p>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff