1
0
mirror of https://github.com/danbee/danbarberphoto synced 2025-03-04 08:49:07 +00:00

Transitioned to Rails 3 and Ruby 1.9.2. All working!

This commit is contained in:
Dan Barber 2010-10-11 07:40:17 -04:00
parent a08636598c
commit e66e75c808
280 changed files with 5882 additions and 37484 deletions

4
.gitignore vendored
View File

@ -1 +1,5 @@
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
public/system

271
README
View File

@ -1,14 +1,15 @@
== Welcome to Rails
Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.
Rails is a web-application framework that includes everything needed to create
database-backed web applications according to the Model-View-Control pattern.
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.
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
@ -21,89 +22,40 @@ 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
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
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
1. At the command prompt, create a new Rails application:
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
2. Change directory to <tt>myapp</tt> and start the web server:
<tt>cd myapp; rails server</tt> (run with --help for options)
== Web Servers
3. Go to http://localhost:3000/ and you'll see:
"Welcome aboard: You're riding Ruby on Rails!"
By default, Rails will try to use Mongrel if it's are installed when started with script/server, otherwise Rails will use WEBrick, the webserver that ships with Ruby. But you can also use Rails
with a variety of other web servers.
4. Follow the guidelines to start developing your application. You can find
the following resources handy:
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
Say other Ruby web servers like Thin and Ebb or regular web servers like Apache or LiteSpeed or
Lighttpd or IIS. The Ruby web servers are run through Rack and the latter can either be setup to use
FCGI or proxy to a pack of Mongrels/Thin/Ebb servers.
== Apache .htaccess example for FCGI/CGI
# General Apache options
AddHandler fastcgi-script .fcgi
AddHandler cgi-script .cgi
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
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
# 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"
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
== Debugging Rails
Sometimes your application goes wrong. Fortunately there are a lot of tools that
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.
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:
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
@ -115,26 +67,27 @@ the Ruby logger class from inside your controllers. Example:
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
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:
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
several books available online as well:
* The Learning Ruby (Pickaxe) Book: http://www.ruby-doc.org/docs/ProgrammingRuby/
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
* 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.
These two 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!
You need to install ruby-debug to run the server in debugging mode. With gems, use 'gem install ruby-debug'
Example:
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! You need to install ruby-debug to run the server in debugging
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
class WeblogController < ActionController::Base
def index
@ -147,97 +100,157 @@ 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\"}>]"
=> "[#<Post:0x14a6be8
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
#<Post:0x14a6620
@attributes={"title"=>"Rails", "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:
...and even better, 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"
Finally, when you're ready to resume execution, you can 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>.
The console is a Ruby shell, which allows you to interact with your
application's domain model. 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.
To start the console, run <tt>rails console</tt> from the application
directory.
Options:
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
made to the database.
* Passing an environment name as an argument will load the corresponding
environment. Example: <tt>rails console production</tt>.
To reload your controllers and models after launching the console run
<tt>reload!</tt>
More information about irb can be found at:
link:http://www.rubycentral.com/pickaxe/irb.html
To reload your controllers and models after launching the console run <tt>reload!</tt>
== dbconsole
You can go to the command line of your database directly through <tt>script/dbconsole</tt>.
You would be connected to the database with the credentials defined in database.yml.
Starting the script without arguments will connect you to the development database. Passing an
argument will connect you to a different database, like <tt>script/dbconsole production</tt>.
Currently works for mysql, postgresql and sqlite.
You can go to the command line of your database directly through <tt>rails
dbconsole</tt>. You would be connected to the database with the credentials
defined in database.yml. Starting the script without arguments will connect you
to the development database. Passing an argument will connect you to a different
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
PostgreSQL and SQLite 3.
== Description of Contents
The default directory structure of a generated Ruby on Rails application:
|-- app
| |-- controllers
| |-- helpers
| |-- models
| `-- views
| `-- layouts
|-- config
| |-- environments
| |-- initializers
| `-- locales
|-- db
|-- doc
|-- lib
| `-- tasks
|-- log
|-- public
| |-- images
| |-- javascripts
| `-- stylesheets
|-- script
| `-- performance
|-- test
| |-- fixtures
| |-- functional
| |-- integration
| |-- performance
| `-- unit
|-- tmp
| |-- cache
| |-- pids
| |-- sessions
| `-- sockets
`-- vendor
`-- plugins
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.
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.
Holds models that should be named like post.rb. Models descend from
ActiveRecord::Base by default.
app/views
Holds the template files for the view that should be named like
weblogs/index.html.erb for the WeblogsController#index action. All views use eRuby
syntax.
weblogs/index.html.erb for the WeblogsController#index action. All views use
eRuby syntax by default.
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.html.erb. Inside default.html.erb,
call <% yield %> to render the view using this layout.
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.html.erb.
Inside default.html.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.
Holds view helpers that should be named like weblogs_helper.rb. These are
generated for you automatically when using generators 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.
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.
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>
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.
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.
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.
Unit and functional tests along with fixtures. When using the rails generate
command, 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.
If the app has frozen rails, those gems also go here, under vendor/rails/.
This directory is in the load path.
External libraries that the application depends on. Also includes the plugins
subdirectory. If the app has frozen rails, those gems also go here, under
vendor/rails/. This directory is in the load path.

View File

@ -1,10 +1,7 @@
# 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 File.expand_path('../config/application', __FILE__)
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
Photos::Application.load_tasks

View File

@ -1,4 +1,2 @@
# Controller generated by Typus, use it to extend admin functionality.
class Admin::CategoriesController < Admin::MasterController
class Admin::CategoriesController < Admin::ResourcesController
end

View File

@ -1,4 +1,2 @@
# Controller generated by Typus, use it to extend admin functionality.
class Admin::PhotosController < Admin::MasterController
class Admin::PhotosController < Admin::ResourcesController
end

View File

@ -1,4 +0,0 @@
# Controller generated by Typus, use it to extend admin functionality.
class Admin::TypusUsersController < Admin::MasterController
end

View File

@ -1,10 +1,3 @@
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
# Scrub sensitive parameters from your log
# filter_parameter_logging :password
protect_from_forgery
end

View File

@ -1,3 +1,2 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end

View File

@ -1,11 +1,11 @@
<div class="sg-5 page-links">
<% if @categories.previous_page -%>
<%= link_to '<div>&larr;</div>', { :page => @categories.previous_page }, :class => 'prev-link' %>
<%= link_to raw('<div>&larr;</div>'), { :page => @categories.previous_page }, :class => 'prev-link' %>
<% end %>
</div>
<div class="sg-5 page-links">
<% if @categories.next_page -%>
<%= link_to '<div>&rarr;</div>', { :page => @categories.next_page }, :class => 'next-link' %>
<%= link_to raw('<div>&rarr;</div>'), { :page => @categories.next_page }, :class => 'next-link' %>
<% end %>
</div>
</div>
@ -17,14 +17,14 @@
<% @photos.each do |photo| %>
<div class="sg-11 photo" style="background: url('<%= photo.photo.url(:size11) %>')">
<%= link_to '&nbsp;', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
<%= link_to '', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
</div>
<% end %>
<% @categories.each do |category| %>
<div class="category sg-5" style="background: <%= category.base_colour %>">
<%= link_to '<h3>'+h(category.name.downcase)+'</h3>', category_photos_path(category) %>
<%= link_to raw('<h3>'+h(category.name.downcase)+'</h3>'), category_photos_path(category) %>
</div>
<% end %>
@ -33,14 +33,4 @@
</div>
<% end %>
<!--<div class="sg-5" style="background: #222;">
</div>
<div class="sg-5" style="background: #333;">
</div>
<div class="sg-5" style="background: #555;">
</div>
<div class="sg-5 contact">
<%= link_to '<div>contact</div>', :action => 'contact' %>
</div>-->
</div>

View File

@ -19,7 +19,7 @@
<div class="sgParent sg-12">
<div id="header" class="sg-11">
<%= link_to '<h1>'+image_tag('title.png')+'</h1>', '/' %>
<%= link_to image_tag('title.png'), '/' %>
</div>
<%= yield %>

View File

@ -1,7 +1,7 @@
<div class="sg-5 about">
</div>
<div class="sg-5 portfolio">
<%= link_to '<div>portfolio</div>', :controller => 'categories' %>
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
</div>
</div>
@ -20,7 +20,7 @@
<div class="sg-5" style="background: #555;">
</div>
<div class="sg-5 contact">
<%= link_to '<div>contact</div>', :action => 'contact' %>
<%= link_to raw('<span>contact</span>'), :action => 'contact' %>
</div>
</div>

View File

@ -1,8 +1,8 @@
<div class="sg-5 about">
<%= link_to '<div>about</div>', :action => 'about' %>
<%= link_to raw('<span>about</span>'), :action => 'about' %>
</div>
<div class="sg-5 portfolio">
<%= link_to '<div>portfolio</div>', :controller => 'categories' %>
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
</div>
</div>
@ -14,5 +14,5 @@
<div class="sg-5" style="background: #555;">
</div>
<div class="sg-5 contact">
<%= link_to '<div>contact</div>', :action => 'contact' %>
<%= link_to raw('<span>contact</span>'), :action => 'contact' %>
</div>

View File

@ -1,11 +1,11 @@
<div class="sg-5 page-links">
<% if @photos.previous_page -%>
<%= link_to '<div>&larr;</div>', { :page => @photos.previous_page }, :class => 'prev-link' %>
<%= link_to raw('<div>&larr;</div>'), { :page => @photos.previous_page }, :class => 'prev-link' %>
<% end %>
</div>
<div class="sg-5 page-links">
<% if @photos.next_page -%>
<%= link_to '<div>&rarr;</div>', { :page => @photos.next_page }, :class => 'next-link' %>
<%= link_to raw('<div>&rarr;</div>'), { :page => @photos.next_page }, :class => 'next-link' %>
<% end %>
</div>
</div>
@ -14,7 +14,7 @@
<% if @category %>
<div class="sg-5 category" style="background: <%= @category.base_colour %>">
<%= link_to '<h3>'+h(@category.name.downcase)+'</h3><div class="arrow">&uarr;</div>', categories_url %>
<%= link_to raw('<h3>'+h(@category.name.downcase)+'</h3><div class="arrow">&uarr;</div>'), categories_url %>
</div>
<% else %>
<div class="sg-5 category" style="background: #333;">
@ -27,7 +27,7 @@
<% @photos.each do |photo| %>
<div class="sg-5 photo" style="background: url('<%= photo.photo.url(:size5) %>')">
<%= link_to '&nbsp;', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
<%= link_to '', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
</div>
<% end %>

View File

@ -1,110 +1,13 @@
# Don't change this file!
# Configure your app in config/environment.rb and config/environments/*.rb
require 'rubygems'
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
module Rails
class << self
def boot!
unless booted?
preinitialize
pick_boot.run
end
end
def booted?
defined? Rails::Initializer
end
def pick_boot
(vendor_rails? ? VendorBoot : GemBoot).new
end
def vendor_rails?
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
def preinitialize
load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
"#{RAILS_ROOT}/config/preinitializer.rb"
end
end
class Boot
def run
load_initializer
Rails::Initializer.run(:set_load_path)
end
end
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
Rails::Initializer.run(:install_gem_spec_stubs)
Rails::GemDependency.add_frozen_gem_path
end
end
class GemBoot < Boot
def load_initializer
self.class.load_rubygems
load_rails_gem
require 'initializer'
end
def load_rails_gem
if version = self.class.gem_version
gem 'rails', version
else
gem 'rails'
end
rescue Gem::LoadError => load_error
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
exit 1
end
class << self
def rubygems_version
Gem::RubyGemsVersion rescue nil
end
def gem_version
if defined? RAILS_GEM_VERSION
RAILS_GEM_VERSION
elsif ENV.include?('RAILS_GEM_VERSION')
ENV['RAILS_GEM_VERSION']
else
parse_gem_version(read_environment_rb)
end
end
def load_rubygems
min_version = '1.3.2'
require 'rubygems'
unless rubygems_version >= min_version
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
def parse_gem_version(text)
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
end
private
def read_environment_rb
File.read("#{RAILS_ROOT}/config/environment.rb")
end
end
end
end
# All that for this:
Rails.boot!
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)

View File

@ -1,43 +1,5 @@
# Be sure to restart your server when you modify this file
# Load the rails application
require File.expand_path('../application', __FILE__)
# Specifies gem version of Rails to use when vendor/rails is not present
RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
# Specify gems that this application depends on and have them installed with rake gems:install
# config.gem "bj"
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
# config.gem "sqlite3-ruby", :lib => "sqlite3"
# config.gem "aws-s3", :lib => "aws/s3"
config.gem "mini_exiftool"
config.gem "will_paginate"
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Skip frameworks you're not going to use. To use Rails without a database,
# you must remove the Active Record framework.
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# Activate observers that should always be running
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names.
config.time_zone = 'UTC'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
# config.i18n.default_locale = :de
end
# Initialize the rails application
Photos::Application.initialize!

View File

@ -1,17 +1,26 @@
# Settings specified here will take precedence over those in config/environment.rb
Photos::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_view.debug_rjs = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
# Only use best-standards-support built into browsers
config.action_dispatch.best_standards_support = :builtin
end
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false

View File

@ -1,28 +1,49 @@
# Settings specified here will take precedence over those in config/environment.rb
Photos::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.action_view.cache_template_loading = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# See everything in the log (default is :info)
# config.log_level = :debug
# Specifies the header that your server uses for sending files
config.action_dispatch.x_sendfile_header = "X-Sendfile"
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# For nginx:
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# If you have no front-end server that supports something like X-Sendfile,
# just comment this out and Rails will serve the files
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# See everything in the log (default is :info)
# config.log_level = :debug
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Enable threaded mode
# config.threadsafe!
# Use a different cache store in production
# config.cache_store = :mem_cache_store
# Disable Rails's static asset server
# In production, Apache or nginx will already do this
config.serve_static_assets = false
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
# Disable delivery errors, bad email addresses will be ignored
# config.action_mailer.raise_delivery_errors = false
# Enable threaded mode
# config.threadsafe!
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation can not be found)
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end

View File

@ -1,28 +1,35 @@
# Settings specified here will take precedence over those in config/environment.rb
Photos::Application.configure do
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Log error messages when you accidentally call methods on nil.
config.whiny_nils = true
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_view.cache_template_loading = true
# Show full error reports and disable caching
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Raise exceptions instead of rendering exception templates
config.action_dispatch.show_exceptions = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Disable request forgery protection in test environment
config.action_controller.allow_forgery_protection = false
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Use SQL instead of Active Record's schema dumper when creating the test database.
# This is necessary if your schema can't be completely dumped by the schema dumper,
# like if you have constraints or database-specific column types
# config.active_record.schema_format = :sql
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end

View File

@ -3,5 +3,5 @@
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!

View File

@ -4,4 +4,4 @@
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
ActionController::Base.cookie_verifier_secret = '753efedb9ba8c926e9053ad138f162b2100fe0569940ff9b0fdea8d3ebb973c12a5028923f5557270806b20084e154ea28550234639ec67542fa49aa603454c9';
ActionController::Base.cookie_verifier_secret = 'b1d6b935fa81c698e8da3f2452f0aabc70c70c06903b6a9f281caf8cdb64ed4f4eaeb02c19077c642dee2dcb40191780fbe028fb7c6274f8a47550ec6b2c7663';

View File

@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format
# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'

View File

@ -1,21 +0,0 @@
# Be sure to restart your server when you modify this file.
# These settings change the behavior of Rails 2 apps and will be defaults
# for Rails 3. You can remove this initializer when Rails 3 is released.
if defined?(ActiveRecord)
# Include Active Record class name as root for JSON serialized output.
ActiveRecord::Base.include_root_in_json = true
# Store the full class name (including module namespace) in STI type column.
ActiveRecord::Base.store_full_sti_class = true
end
ActionController::Routing.generate_best_match = false
# Use ISO 8601 format for JSON serialized times and dates.
ActiveSupport.use_standard_json_time_format = true
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
# if you're including raw json in an HTML page.
ActiveSupport.escape_html_entities_in_json = false

View File

@ -1,15 +1,8 @@
# Be sure to restart your server when you modify this file.
# Your secret key for verifying cookie session data integrity.
# If you change this key, all old sessions will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
ActionController::Base.session = {
:key => '_photos_session',
:secret => 'ed6e47eac508a8c65c3c07ed65c888777d4282f081da72cfdd2b19cf8ff553a655b3fc44e6a92c85c396444359539934e1f1c2ea1558dcd0fafc80699cfc5694'
}
Photos::Application.config.session_store :cookie_store, :key => '_photos_session'
# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
# (create the session table with "rake db:sessions:create")
# ActionController::Base.session_store = :active_record_store
# Photos::Application.config.session_store :active_record_store

View File

@ -1,26 +1,26 @@
# Be sure to restart your server when you modify this file.
Typus.setup do |config|
# System wide options
# Application name.
config.admin_title = "Dan Barber Photography"
# config.admin_sub_title = ""
Typus::Configuration.options[:app_name] = 'photos'
# Typus::Configuration.options[:email] = 'admin@example.com'
# Typus::Configuration.options[:file_preview] = :typus_preview
# Typus::Configuration.options[:file_thumbnail] = :typus_thumbnail
# Typus::Configuration.options[:relationship] = 'typus_users'
# Typus::Configuration.options[:root] = 'admin'
Typus::Configuration.options[:user_class_name] = 'TypusUser'
Typus::Configuration.options[:user_fk] = 'typus_user_id'
# When mailer_sender is set, password recover is enabled. This email
# address will be used in Admin::Mailer.
# config.mailer_sender = "admin@example.com"
# Model options which can also be defined by model on the yaml files.
# Define file attachment settings.
# config.file_preview = :typus_preview
# config.file_thumbnail = :typus_thumbnail
# Typus::Configuration.options[:default_action_on_item] = 'edit'
# Typus::Configuration.options[:end_year] = Time.now.year + 1
# Typus::Configuration.options[:form_rows] = 15
# Typus::Configuration.options[:index_after_save] = true
# Typus::Configuration.options[:minute_step] = 5
# Typus::Configuration.options[:nil] = 'nil'
# Typus::Configuration.options[:on_header] = false
# Typus::Configuration.options[:only_user_items] = false
# Typus::Configuration.options[:per_page] = 15
# Typus::Configuration.options[:sidebar_selector] = 5
# Typus::Configuration.options[:start_year] = Time.now.year - 10
# Authentication: +:none+, +:http_basic+
# Run `rails g typus:migration` if you need an advanced authentication system.
# config.authentication = :none
# Define username and password for +:http_basic+ authentication
# config.username = "admin"
# config.password = "columbia"
# Define available languages on the admin interface.
# config.available_locales = [:en]
end

View File

@ -2,4 +2,4 @@
# See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
hello: "Hello world"
hello: "Hello world"

View File

@ -1,52 +1,70 @@
ActionController::Routing::Routes.draw do |map|
Typus::Routes.draw(map)
# The priority is based upon order of creation: first created -> highest priority.
Photos::Application.routes.draw do
# The priority is based upon order of creation:
# first created -> highest priority.
# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action
# Sample of named route:
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
# This route can be invoked with purchase_url(:id => product.id)
# Sample resource route (maps HTTP verbs to controller actions automatically):
# map.resources :products
# resources :products
# Sample resource route with options:
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
# resources :products do
# member do
# get 'short'
# post 'toggle'
# end
#
# collection do
# get 'sold'
# end
# end
# Sample resource route with sub-resources:
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
# resources :products do
# resources :comments, :sales
# resource :seller
# end
# Sample resource route with more complex sub-resources
# map.resources :products do |products|
# products.resources :comments
# products.resources :sales, :collection => { :recent => :get }
# resources :products do
# resources :comments
# resources :sales do
# get 'recent', :on => :collection
# end
# end
# Sample resource route within a namespace:
# map.namespace :admin do |admin|
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
# admin.resources :products
# namespace :admin do
# # Directs /admin/products/* to Admin::ProductsController
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => "welcome#index"
# See how all your routes lay out with "rake routes"
# Install the default routes as the lowest priority.
# Note: These default routes make all actions in every controller accessible via GET requests. You should
# consider removing or commenting them out if you're using named routes and resources.
map.resources :categories, :has_many => :photos
map.resources :photos
resources :categories do
resources :photos
end
map.root :controller => "pages"
map.pages ':action', :controller => 'pages'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
resources :photos
root :to => 'pages#index'
match 'about' => 'pages#about'
match 'contact' => 'pages#contact'
# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
match ':controller(/:action(/:id(.:format)))'
end

View File

@ -1,11 +1,12 @@
# Models
This is an example of a **Typus** enabled model with all available
options. You can use this example to customize your YAML files which
only have set the most common settings.
This is an example of a **Typus** enabled model with all available options. You
can use this example to customize your YAML files which only have set the most
common settings.
Post:
fields:
default: id, title, category_id, created_at, is_published?
list: id, title, category_id, created_at, is_published?
form: title, body, is_published?, created_at
show: title, category, is_published?
@ -25,7 +26,7 @@ only have set the most common settings.
index: cleanup
edit: send_as_newsletter
show: rebuild
export: csv, xml, pdf
export: csv, xml
order_by: created_at
relationships:
filters: is_published?, created_at, category_id
@ -33,25 +34,23 @@ only have set the most common settings.
application: Application
description: Some text to describe the model
options:
action_after_save: :index
default_action_on_item: show
end_year: 2015
form_rows: 25
index_after_save: false
minute_step: 15
nil: 'nil'
on_header: true
only_user_items: true
per_page: 5
sidebar_selector: 5
start_year: 1990
Note: To define namespace models use :: as a separator. (i.e. Delayed::Job)
# Roles
In this file you can configure the actions available for each of
your models on the application. You can also use the 'all' shortcut
to allow the user the access to all actions.
In this file you can configure the actions available for each of your models on
the application. You can also use the 'all' shortcut to allow the user the
access to all actions.
admin:
Post: create, read, update, delete
@ -62,10 +61,8 @@ to allow the user the access to all actions.
Post: create, read, update
Category: read, update
You can also define `resources` which are not related to a model,
for example to control MemCached or see the Starling queue
statistics.
You can also define `resources` which are not related to a model, for example
to control `Redis`.
admin:
Starling: index
MemCached: index, cleanup
Redis: index, flush_all

View File

@ -5,22 +5,20 @@
Category:
fields:
default: name, photo_id, base_colour, sort
list: name, photo_id, base_colour, sort
form: name, description, photo_id, base_colour, sort
order_by:
relationships: photos
filters:
search: name
application: photos
application: Photos
Photo:
fields:
default: photo_file_name, photo_content_type, photo_file_size, photo_updated_at, title, sort
list: photo_file_name, categories, photo_content_type, photo_file_size, photo_updated_at, title, sort
form: photo, flickr_url, title, description, sort
default: title, sort
form: photo, title, description, flickr_url, sort
order_by:
relationships: categories
filters:
search: title
application: photos
application: Photos

View File

@ -1,17 +0,0 @@
# Typus Models Configuration File
#
# Use the README file as a reference to customize settings.
TypusUser:
fields:
default: first_name, last_name, email, role, status
list: email, role, status
form: first_name, last_name, role, email, password, password_confirmation, language
options:
selectors: role, language
booleans:
status: Active, Inactive
filters: status, role
search: first_name, last_name, email, role
application: Admin Panel
description: Admin Panel Users Administration

View File

@ -1,6 +0,0 @@
# Typus Roles Configuration File
#
# Use the README file as a reference to customize settings.
admin:
TypusUser: all

Binary file not shown.

View File

@ -1,22 +0,0 @@
class CreateTypusUsers < ActiveRecord::Migration
def self.up
create_table :typus_users do |t|
t.string :first_name, :default => "", :null => false
t.string :last_name, :default => "", :null => false
t.string :role, :null => false
t.string :email, :null => false
t.boolean :status, :default => false
t.string :token, :null => false
t.string :salt, :null => false
t.string :crypted_password, :null => false
t.string :preferences
t.timestamps
end
end
def self.down
drop_table :typus_users
end
end

View File

@ -1,15 +1,16 @@
# This file is auto-generated from the current state of the database. Instead of editing this file,
# please use the migrations feature of Active Record to incrementally modify your database, and
# then regenerate this schema definition.
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
# to create the application database on another system, you should be using db:schema:load, not running
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20101008175640) do
ActiveRecord::Schema.define(:version => 20101008172319) do
create_table "categories", :force => true do |t|
t.string "name"
@ -39,18 +40,4 @@ ActiveRecord::Schema.define(:version => 20101008175640) do
t.integer "sort"
end
create_table "typus_users", :force => true do |t|
t.string "first_name", :default => "", :null => false
t.string "last_name", :default => "", :null => false
t.string "role", :null => false
t.string "email", :null => false
t.boolean "status", :default => false
t.string "token", :null => false
t.string "salt", :null => false
t.string "crypted_password", :null => false
t.string "preferences"
t.datetime "created_at"
t.datetime "updated_at"
end
end

View File

@ -2,6 +2,6 @@
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Major.create(:name => 'Daley', :city => cities.first)
# Mayor.create(:name => 'Daley', :city => cities.first)

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,19 @@
<!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">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The page you were looking for doesn't exist (404)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
@ -27,4 +23,4 @@
<p>You may have mistyped the address or the page may have moved.</p>
</div>
</body>
</html>
</html>

View File

@ -1,23 +1,19 @@
<!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">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>The change you wanted was rejected (422)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
@ -27,4 +23,4 @@
<p>Maybe you tried to change something you didn't have access to.</p>
</div>
</body>
</html>
</html>

View File

@ -1,23 +1,19 @@
<!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">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>We're sorry, but something went wrong (500)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>

View File

@ -1,8 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Ruby on Rails: Welcome aboard</title>
<style type="text/css" media="screen">
body {
@ -14,20 +12,20 @@
font-size: 13px;
color: #333;
}
h1 {
font-size: 28px;
color: #000;
}
a {color: #03c}
a:hover {
background-color: #03c;
color: white;
text-decoration: none;
}
#page {
background-color: #f0f0f0;
width: 750px;
@ -35,7 +33,7 @@
margin-left: auto;
margin-right: auto;
}
#content {
float: left;
background-color: white;
@ -44,7 +42,7 @@
padding: 25px;
width: 500px;
}
#sidebar {
float: right;
width: 175px;
@ -53,7 +51,7 @@
#footer {
clear: both;
}
#header, #about, #getting-started {
padding-left: 75px;
@ -73,18 +71,19 @@
font-weight: normal;
font-size: 16px;
}
#about h3 {
margin: 0;
margin-bottom: 10px;
font-size: 14px;
}
#about-content {
background-color: #ffd;
border: 1px solid #fc0;
margin-left: -11px;
margin-left: -55px;
margin-right: -10px;
}
#about-content table {
margin-top: 10px;
@ -99,7 +98,12 @@
}
#about-content td.name {color: #555}
#about-content td.value {color: #000}
#about-content ul {
padding: 0;
list-style-type: none;
}
#about-content.failure {
background-color: #fcc;
border: 1px solid #f00;
@ -108,8 +112,8 @@
margin: 0;
padding: 10px;
}
#getting-started {
border-top: 1px solid #ccc;
margin-top: 25px;
@ -145,21 +149,8 @@
color: #555;
font-size: 13px;
}
#search {
margin: 0;
padding-top: 10px;
padding-bottom: 10px;
font-size: 11px;
}
#search input {
font-size: 11px;
margin: 2px;
}
#search-text {width: 170px}
#sidebar ul {
margin-left: 0;
padding-left: 0;
@ -176,29 +167,19 @@
#sidebar ul.links li {
margin-bottom: 5px;
}
</style>
<script type="text/javascript" src="javascripts/prototype.js"></script>
<script type="text/javascript" src="javascripts/effects.js"></script>
<script type="text/javascript">
function about() {
if (Element.empty('about-content')) {
new Ajax.Updater('about-content', 'rails/info/properties', {
method: 'get',
onFailure: function() {Element.classNames('about-content').add('failure')},
onComplete: function() {new Effect.BlindDown('about-content', {duration: 0.25})}
});
} else {
new Effect[Element.visible('about-content') ?
'BlindUp' : 'BlindDown']('about-content', {duration: 0.25});
}
}
window.onload = function() {
$('search-text').value = '';
$('search').onsubmit = function() {
$('search-text').value = 'site:rubyonrails.org ' + $F('search-text');
}
info = document.getElementById('about-content');
if (window.XMLHttpRequest)
{ xhr = new XMLHttpRequest(); }
else
{ xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
xhr.open("GET","rails/info/properties",false);
xhr.send("");
info.innerHTML = xhr.responseText;
info.style.display = 'block'
}
</script>
</head>
@ -206,23 +187,6 @@
<div id="page">
<div id="sidebar">
<ul id="sidebar-items">
<li>
<form id="search" action="http://www.google.com/search" method="get">
<input type="hidden" name="hl" value="en" />
<input type="text" id="search-text" name="q" value="site:rubyonrails.org " />
<input type="submit" value="Search" /> the Rails site
</form>
</li>
<li>
<h3>Join the community</h3>
<ul class="links">
<li><a href="http://www.rubyonrails.org/">Ruby on Rails</a></li>
<li><a href="http://weblog.rubyonrails.org/">Official weblog</a></li>
<li><a href="http://wiki.rubyonrails.org/">Wiki</a></li>
</ul>
</li>
<li>
<h3>Browse the documentation</h3>
<ul class="links">
@ -245,17 +209,17 @@
<h3><a href="rails/info/properties" onclick="about(); return false">About your application&rsquo;s environment</a></h3>
<div id="about-content" style="display: none"></div>
</div>
<div id="getting-started">
<h1>Getting started</h1>
<h2>Here&rsquo;s how to get rolling:</h2>
<ol>
<ol>
<li>
<h2>Use <tt>script/generate</tt> to create your models and controllers</h2>
<h2>Use <code>rails generate</code> to create your models and controllers</h2>
<p>To see all available options, run it without parameters.</p>
</li>
<li>
<h2>Set up a default route and remove or rename this file</h2>
<p>Routes are set up in config/routes.rb.</p>
@ -263,13 +227,13 @@
<li>
<h2>Create your database</h2>
<p>Run <tt>rake db:migrate</tt> to create your database. If you're not using SQLite (the default), edit <tt>config/database.yml</tt> with your username and password.</p>
<p>Run <code>rake db:migrate</code> to create your database. If you're not using SQLite (the default), edit <code>config/database.yml</code> with your username and password.</p>
</li>
</ol>
</div>
</div>
<div id="footer">&nbsp;</div>
</div>
</body>
</html>
</html>

View File

@ -1,6 +1,8 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2008 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
// (c) 2005-2008 Jon Tirsen (http://www.tirsen.com)
// script.aculo.us controls.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2009 Ivan Krstic (http://blogs.law.harvard.edu/ivan)
// (c) 2005-2009 Jon Tirsen (http://www.tirsen.com)
// Contributors:
// Richard Livsey
// Rahul Bhargava

View File

@ -1,5 +1,6 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// (c) 2005-2008 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz)
// script.aculo.us dragdrop.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
//
// script.aculo.us is freely distributable under the terms of an MIT-style license.
// For details, see the script.aculo.us web site: http://script.aculo.us/
@ -311,7 +312,7 @@ var Draggable = Class.create({
tag_name=='TEXTAREA')) return;
var pointer = [Event.pointerX(event), Event.pointerY(event)];
var pos = Position.cumulativeOffset(this.element);
var pos = this.element.cumulativeOffset();
this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) });
Draggables.activate(this);
@ -454,7 +455,7 @@ var Draggable = Class.create({
},
draw: function(point) {
var pos = Position.cumulativeOffset(this.element);
var pos = this.element.cumulativeOffset();
if(this.options.ghosting) {
var r = Position.realOffset(this.element);
pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
@ -730,7 +731,7 @@ var Sortable = {
}
// keep reference
this.sortables[element.id] = options;
this.sortables[element.identify()] = options;
// for onupdate
Draggables.addObserver(new SortableObserver(element, options.onUpdate));
@ -825,7 +826,7 @@ var Sortable = {
hide().addClassName('dropmarker').setStyle({position:'absolute'});
document.getElementsByTagName("body").item(0).appendChild(Sortable._marker);
}
var offsets = Position.cumulativeOffset(dropon);
var offsets = dropon.cumulativeOffset();
Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'});
if(position=='after')

View File

@ -1,4 +1,6 @@
// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// script.aculo.us effects.js v1.8.3, Thu Oct 08 11:23:33 +0200 2009
// Copyright (c) 2005-2009 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us)
// Contributors:
// Justin Palmer (http://encytemedia.com/)
// Mark Pilgrim (http://diveintomark.org/)
@ -145,14 +147,13 @@ var Effect = {
'blind': ['BlindDown','BlindUp'],
'appear': ['Appear','Fade']
},
toggle: function(element, effect) {
toggle: function(element, effect, options) {
element = $(element);
effect = (effect || 'appear').toLowerCase();
var options = Object.extend({
effect = (effect || 'appear').toLowerCase();
return Effect[ Effect.PAIRS[ effect ][ element.visible() ? 1 : 0 ] ](element, Object.extend({
queue: { position:'end', scope:(element.id || 'global'), limit: 1 }
}, arguments[2] || { });
Effect[element.visible() ?
Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options);
}, options || {}));
}
};
@ -228,12 +229,6 @@ Effect.Queue = Effect.Queues.get('global');
Effect.Base = Class.create({
position: null,
start: function(options) {
function codeForEvent(options,eventName){
return (
(options[eventName+'Internal'] ? 'this.options.'+eventName+'Internal(this);' : '') +
(options[eventName] ? 'this.options.'+eventName+'(this);' : '')
);
}
if (options && options.transition === false) options.transition = Effect.Transitions.linear;
this.options = Object.extend(Object.extend({ },Effect.DefaultOptions), options || { });
this.currentFrame = 0;

File diff suppressed because it is too large Load Diff

View File

@ -33,7 +33,7 @@ a {
#header a:hover {
background: rgba(255,255,255,0.1);
}
#header h1 {
#header img {
padding: 0;
margin: 0;
position: absolute;
@ -54,6 +54,11 @@ a {
-webkit-border-radius: 2px;
border-radius: 2px;
}
.sg-5 a, .sg-7 a, .sg-11 a, .sg-17 a, .sg-35 {
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
border-radius: 2px;
}
.sg-5 {
height: 140px;
}
@ -77,6 +82,11 @@ a {
.sg-11 {
height: 308px;
}
.sg-11 a {
display: block;
height: 308px;
width: 308px;
}
.sg-17 {
height: 476px;
}
@ -95,7 +105,7 @@ a {
.about a:hover, .portfolio a:hover, .contact a:hover {
background: rgba(255,255,255,0.2);
}
.about a div, .portfolio a div, .contact a div {
.about a span, .portfolio a span, .contact a span {
position: absolute;
top: 10px;
right: 20px;

View File

@ -1,6 +1,5 @@
require 'test_helper'
# ControllerTest generated by Typus, use it to test the extended admin functionality.
class Admin::CategoriesControllerTest < ActionController::TestCase
# Replace this with your real tests.
@ -8,4 +7,4 @@ class Admin::CategoriesControllerTest < ActionController::TestCase
assert true
end
end
end

View File

@ -1,6 +1,5 @@
require 'test_helper'
# ControllerTest generated by Typus, use it to test the extended admin functionality.
class Admin::PhotosControllerTest < ActionController::TestCase
# Replace this with your real tests.
@ -8,4 +7,4 @@ class Admin::PhotosControllerTest < ActionController::TestCase
assert true
end
end
end

View File

@ -1,11 +0,0 @@
require 'test_helper'
# ControllerTest generated by Typus, use it to test the extended admin functionality.
class Admin::TypusUsersControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

View File

@ -1,8 +1,8 @@
require 'test_helper'
require 'performance_test_help'
require 'rails/performance_test_help'
# Profiling results for each test method are written to tmp/performance.
class BrowsingTest < ActionController::PerformanceTest
class BrowsingTest < ActionDispatch::PerformanceTest
def test_homepage
get '/'
end

View File

@ -1,33 +1,8 @@
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test database remains unchanged so your fixtures don't have to be reloaded
# between every test method. Fewer database queries means faster tests.
#
# Read Mike Clark's excellent walkthrough at
# http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
#
# Every Active Record database supports transactions except MyISAM tables
# in MySQL. Turn off transactional fixtures in this case; however, if you
# don't care one way or the other, switching from MyISAM to InnoDB tables
# is recommended.
#
# The only drawback to using transactional fixtures is when you actually
# need to test transactions. Since your test is bracketed by a transaction,
# any transactions started in your code will be automatically rolled back.
self.use_transactional_fixtures = true
# Instantiated fixtures are slow, but give you @david where otherwise you
# would need people(:david). If you don't want to migrate your existing
# test cases which use the @david style and don't mind the speed hit (each
# instantiated fixtures translates to a database query per test method),
# then set this back to true.
self.use_instantiated_fixtures = false
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
#
# Note: You'll currently still have to declare fixtures explicitly in integration tests

View File

@ -1,68 +0,0 @@
= 0.9.40 / 2010-02-??
[X] Refactor all forms to be able to use formtastic.
[X] Cleanup translation files.
[X] Removed FIXME tests.
[X] Pass attribute as symbol.
[X] Simplify configuration files.
[X] Added '/' to admin_edit_typus_user_path because was not linking to
the right path on the namespaced models.
[X] Updated generator defaults.
[X] Write CSV file to disk and then send_file.
[X] Replaced CSV separator. Now uses ';' instead of ','.
[X] Do not show selector on habtm if there are more than 500 records.
[X] Paginate habtm relationships. Was implemented in the has_many.
[X] Fixed unrelate action. Was not working properly when not using
Rails default table names.
[X] Do not humanize fields on the csv generator. We want to keep the
real field name.
[X] Recover password functionality now only needs the email to be defined.
[X] Added json export format.
[X] Added default route with conditions. (Ben Scofield)
[X] We should be able to set preferences and store them on the database.
[X] Fixed stylesheet and search to be able to use `relative_url_root`.
[X] Cleanup `display_link_to_previous` helper.
[X] Cleanup `build_typus_list` helper.
[X] Fix back_to when using `relative_url_root`.
[X] Remove toggle option. We always enable it so it's a good default.
[X] When displaying an item with multiple attachments fancybox preview
was not working properly because there where multiple items with the
same id.
[X] Move partial helpers to `app/views/admin/helpers`.
[X] Do not set ActionMailer::Base.default_url_options[:host] on the
controller.
[X] Cleanup `applications` & `resources`.
[-] Allow users to download the demo hosted at heroku.com
[-] Move html code from helpers to partials.
[ ] Add API authentication.
[ ] Fix problems on routes.rb when using namespaced models.
[ ] Show the right content on the selectors when listing records on tables.
[ ] Update fancybox to the latest version. Fix paths to make it work when
`relative_url_root` is active. (and make a donation)
[ ] Add has_many through relationships.
[ ] Test default typus forms and remove old tests.
[ ] Fixed and tested read-only fields.
[ ] Fixed and tested auto-generated fields.
[ ] Fixed and tested trees.
[ ] Fix all fixme tests.
[ ] Test _form.html.erb can be overwrited by model.
[ ] Show auto_generated, read_only on string fields. (_string.html.erb)
[ ] Pass options hash to form fields.
[ ] Fix css to display correctly "select" fields in relationships.
[ ] Make tests work again.
[ ] Remove Typus "blue" color and use something more neutral.
[ ] Ajax pagination. (?)
[ ] Generate views for custom actions on the controllers/models. This should
verify the view doesn't exist and create it.
[ ] Support for XSS.
[X] Replace "render :partial => 'template', :locals => {}", by
"render 'template', :local => 'local'".
[X] Add support for custom typus_user on the generator.
[ ] Shorten sidebar selectors. (AFS)
[ ] Add test for `typus_table_selector`.
[X] Clicking on a filter removes is. (Gaston Kleiman)
[X] Possibility to filter by date ranges. (Gaston Kleiman)
[ ] Use `inherit_views` code to `inherit_views`.
[ ] Forever loop when schema has not been migrated.
[ ] Pagination doesn't work properly when having multiple paginators on edit page
[ ] Add support for 'has_one' relationships.

View File

@ -1,20 +0,0 @@
Copyright (c) 2007-2010 Francesc Esplugas Marti
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 File

@ -1,49 +0,0 @@
= Typus: Admin interface for Rails applications
Typus is designed for a single activity:
Trusted users editing structured content.
Typus doesn't try to be all the things to all the people but it's extensible
enough to match lots of use cases.
== Key Features
- Authentication by session or http.
- Access control by users and roles (only on session authentication).
- Show, search, edit and create data on a clean interface.
- Internationalized interface with xtensible and overwritable templates.
- Boolean filtering.
- Supports ActiveRecord.
- Supports Rails 3 and is Ruby 1.9 compatible.
- Tested with SQLite, MySQL, and PostgreSQL.
- MIT License.
== Links
- {Project page}[http://labs.intraducibles.com/projects/typus]
- {Documentation}[http://typus.intraducibles.com/]
- {Plugin source code}[http://github.com/fesplugas/typus]
- {Mailing list}[http://groups.google.com/group/typus]
- {Bug reports}[http://github.com/fesplugas/typus/issues]
- {Gems}[http://gemcutter.org/gems/typus]
- {Contributors}[http://github.com/fesplugas/typus/contributors]
== Installing
Install from GitHub the latest version which it's compatible with
<tt>Rails 2.3.8</tt>.
$ script/plugin install git://github.com/fesplugas/typus.git -r 2-3-stable
Once `typus` is installed, run the generator to create required files and
migrate your database.
$ script/generate typus
$ rake db:migrate
Start the application server and go to {http://0.0.0.0:3000/admin}[http://0.0.0.0:3000/admin].
== License
Copyright &copy; 2007-2010 Francesc Esplugas, released under the MIT license.

View File

@ -1,57 +0,0 @@
require 'rubygems'
require 'rake/testtask'
require 'rake/rdoctask'
$LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require "typus/version"
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the typus plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Build the gem.'
task :build do
system "gem build typus.gemspec"
end
desc 'Build and release the gem.'
task :release => :build do
version = Typus::VERSION
system "git tag v#{version}"
system "git push origin v#{version}"
system "gem push pkg/typus-#{version}.gem"
system "git clean -fd"
system "gem push typus-#{version}"
end
desc 'Generate specdoc-style documentation from tests'
task :specs do
puts 'Started'
timer, count = Time.now, 0
File.open('SPECDOC', 'w') do |file|
Dir.glob('test/**/*_test.rb').each do |test|
test =~ /.*\/([^\/].*)_test.rb$/
file.puts "#{$1.gsub('_', ' ').capitalize} should:" if $1
File.read(test).map { |line| /test_(.*)$/.match line }.compact.each do |spec|
file.puts "- #{spec[1].gsub('_', ' ')}"
sleep 0.001; print '.'; $stdout.flush; count += 1
end
file.puts
end
end
puts <<-MSG
\nFinished in #{Time.now - timer} seconds.
#{count} specifications documented.
MSG
end

View File

@ -1,401 +0,0 @@
class Admin::MasterController < ApplicationController
skip_filter filter_chain
unloadable
inherit_views 'admin/resources'
layout 'admin'
include Typus::Authentication
include Typus::Format
include Typus::Preferences
include Typus::Reloader
filter_parameter_logging :password
before_filter :reload_config_and_roles
before_filter :require_login
before_filter :set_typus_preferences
before_filter :set_resource
before_filter :find_item,
:only => [ :show, :edit, :update, :destroy, :toggle, :position, :relate, :unrelate, :detach ]
before_filter :check_ownership_of_item,
:only => [ :edit, :update, :destroy, :toggle, :position, :relate, :unrelate ]
before_filter :check_if_user_can_perform_action_on_user,
:only => [ :edit, :update, :toggle, :destroy ]
before_filter :check_if_user_can_perform_action_on_resource
before_filter :set_order,
:only => [ :index ]
before_filter :set_fields,
:only => [ :index, :new, :edit, :create, :update, :show ]
##
# This is the main index of the model. With filters, conditions
# and more.
#
# By default application can respond_to html, csv and xml, but you
# can add your formats.
#
def index
@conditions, @joins = @resource[:class].build_conditions(params)
check_ownership_of_items if @resource[:class].typus_options_for(:only_user_items)
respond_to do |format|
format.html { generate_html }
@resource[:class].typus_export_formats.each do |f|
format.send(f) { send("generate_#{f}") }
end
end
rescue Exception => error
error_handler(error)
end
def new
check_ownership_of_referal_item
item_params = params.dup
%w( controller action resource resource_id back_to selected ).each do |param|
item_params.delete(param)
end
@item = @resource[:class].new(item_params.symbolize_keys)
end
##
# Create new items. There's an special case when we create an
# item from another item. In this case, after the item is
# created we also create the relationship between these items.
#
def create
@item = @resource[:class].new(params[@object_name])
if @resource[:class].typus_user_id?
@item.attributes = { Typus.user_fk => @current_user.id }
end
if @item.valid?
create_with_back_to and return if params[:back_to]
@item.save
flash[:success] = _("%{model} successfully created.",
:model => @resource[:human_name])
if @resource[:class].typus_options_for(:index_after_save)
redirect_to :action => 'index'
else
redirect_to :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id
end
else
render :action => 'new'
end
end
def edit
end
def show
check_ownership_of_item and return if @resource[:class].typus_options_for(:only_user_items)
respond_to do |format|
format.html
format.xml do
fields = @resource[:class].typus_fields_for(:xml).collect { |i| i.first }
render :xml => @item.to_xml(:only => fields)
end
end
end
def update
if @item.update_attributes(params[@object_name])
if @resource[:class].typus_user_id? && @current_user.is_not_root?
@item.update_attributes Typus.user_fk => @current_user.id
end
path = if @resource[:class].typus_options_for(:index_after_save)
params[:back_to] ? "#{params[:back_to]}##{@resource[:self]}" : { :action => 'index' }
else
{ :action => @resource[:class].typus_options_for(:default_action_on_item), :id => @item.id, :back_to => params[:back_to] }
end
# Reload @current_user when updating to see flash message in the
# correct locale.
if @resource[:class].eql?(Typus.user_class)
I18n.locale = @current_user.reload.preferences[:locale]
@resource[:human_name] = params[:controller].extract_human_name
end
flash[:success] = _("%{model} successfully updated.",
:model => @resource[:human_name])
redirect_to path
else
render :action => 'edit'
end
end
def destroy
@item.destroy
flash[:success] = _("%{model} successfully removed.",
:model => @resource[:human_name])
redirect_to request.referer || admin_dashboard_path
rescue Exception => error
error_handler(error, params.merge(:action => 'index', :id => nil))
end
def toggle
@item.toggle(params[:field])
@item.save!
flash[:success] = _("%{model} %{attribute} changed.",
:model => @resource[:human_name],
:attribute => params[:field].humanize.downcase)
redirect_to request.referer || admin_dashboard_path
end
##
# Change item position. This only works if acts_as_list is
# installed. We can then move items:
#
# params[:go] = 'move_to_top'
#
# Available positions are move_to_top, move_higher, move_lower,
# move_to_bottom.
#
def position
@item.send(params[:go])
flash[:success] = _("Record moved %{to}.",
:to => params[:go].gsub(/move_/, '').humanize.downcase)
redirect_to request.referer || admin_dashboard_path
end
##
# Relate a model object to another, this action is used only by the
# has_and_belongs_to_many and has_many relationships.
#
def relate
resource_class = params[:related][:model].constantize
resource_tableized = params[:related][:relation] || params[:related][:model].tableize
if @item.send(resource_tableized) << resource_class.find(params[:related][:id])
flash[:success] = _("%{model_a} related to %{model_b}.",
:model_a => resource_class.typus_human_name,
:model_b => @resource[:human_name])
else
# TODO: Show the reason why cannot be related showing model_a and model_b errors.
flash[:error] = _("%{model_a} cannot be related to %{model_b}.",
:model_a => resource_class.typus_human_name,
:model_b => @resource[:human_name])
end
redirect_to :back
end
##
# Remove relationship between models, this action never removes items!
#
def unrelate
resource_class = params[:resource].classify.constantize
resource_tableized = params[:resource].tableize
resource = resource_class.find(params[:resource_id])
if @resource[:class].
reflect_on_association(resource_class.table_name.singularize.to_sym).
try(:macro) == :has_one
attribute = resource_tableized.singularize
saved_succesfully = @item.update_attribute attribute, nil
else
attribute = resource_tableized
saved_successfully = if @item.respond_to?(attribute)
@item.send(attribute).delete(resource)
elsif @item.respond_to?("related_#{attribute}")
@item.relationships.detect {|rel|
rel.related_id == resource.id &&
rel.related_type == resource.class.name
}.destroy
end
end
if saved_succesfully
flash[:success] = _("%{model_a} unrelated from %{model_b}.",
:model_a => resource_class.typus_human_name,
:model_b => @resource[:human_name])
else
# TODO: Show the reason why cannot be unrelated showing model_a and model_b errors.
flash[:error] = _("%{model_a} cannot be unrelated to %{model_b}.",
:model_a => resource_class.typus_human_name,
:model_b => @resource[:human_name])
end
redirect_to :back
end
def detach
attachment = @resource[:class].human_attribute_name(params[:attachment])
if @item.update_attributes(params[:attachment] => nil)
flash[:success] = _("%{attachment} removed.",
:attachment => attachment)
else
flash[:notice] = _("%{attachment} can't be removed.",
:attachment => attachment)
end
redirect_to :back
end
def current_user
@current_user
end
private
def set_resource
@resource = { :self => params[:controller].extract_resource,
:human_name => params[:controller].extract_human_name,
:class => params[:controller].extract_class,
:pluralized => params[:controller].extract_class.pluralized_human_name }
@object_name = ActionController::RecordIdentifier.singular_class_name(@resource[:class])
rescue Exception => error
error_handler(error)
end
##
# Find model when performing an edit, update, destroy, relate,
# unrelate ...
#
def find_item
@item = @resource[:class].find(params[:id])
end
##
# If item is owned by another user, we only can perform a
# show action on the item. Updated item is also blocked.
#
# before_filter :check_ownership_of_item, :only => [ :edit, :update, :destroy,
# :toggle, :position,
# :relate, :unrelate ]
#
def check_ownership_of_item
# By-pass if current_user is root.
return if @current_user.is_root?
condition_typus_users = @item.respond_to?(Typus.relationship) && !@item.send(Typus.relationship).include?(@current_user)
condition_typus_user_id = @item.respond_to?(Typus.user_fk) && !@item.owned_by?(@current_user)
if condition_typus_users || condition_typus_user_id
flash[:notice] = _("You don't have permission to access this item.")
redirect_to request.referer || admin_dashboard_path
end
end
def check_ownership_of_items
# By-pass if current_user is root.
return if @current_user.is_root?
# Show only related items it @resource has a foreign_key (Typus.user_fk)
# related to the logged user.
if @resource[:class].typus_user_id?
condition = { Typus.user_fk => @current_user }
@conditions = @resource[:class].merge_conditions(@conditions, condition)
end
end
def check_ownership_of_referal_item
return unless params[:resource] && params[:resource_id]
klass = params[:resource].classify.constantize
return if !klass.typus_user_id?
item = klass.find(params[:resource_id])
raise "You're not owner of this record." unless item.owned_by?(@current_user) || @current_user.is_root?
end
def set_fields
mapping = case params[:action]
when 'index' then :list
when 'new', 'edit', 'create', 'update' then :form
else params[:action]
end
@fields = @resource[:class].typus_fields_for(mapping)
end
def set_order
params[:sort_order] ||= 'desc'
@order = params[:order_by] ? "#{@resource[:class].table_name}.#{params[:order_by]} #{params[:sort_order]}" : @resource[:class].typus_order_by
end
##
# When <tt>params[:back_to]</tt> is defined this action is used.
#
# - <tt>has_and_belongs_to_many</tt> relationships.
# - <tt>has_many</tt> relationships (polymorphic ones).
#
def create_with_back_to
if params[:resource] && params[:resource_id]
resource_class = params[:resource].classify.constantize
resource_id = params[:resource_id]
resource = resource_class.find(resource_id)
association = @resource[:class].reflect_on_association(params[:resource].to_sym).macro rescue :polymorphic
else
association = :has_many
end
case association
when :belongs_to
@item.save
when :has_and_belongs_to_many
@item.save
@item.send(params[:resource]) << resource
when :has_many
@item.save
message = _("%{model} successfully created.",
:model => @resource[:human_name])
path = "#{params[:back_to]}?#{params[:selected]}=#{@item.id}"
when :polymorphic
resource.send(@item.class.name.tableize).create(params[@object_name])
end
flash[:success] = message || _("%{model_a} successfully assigned to %{model_b}.",
:model_a => @item.class.typus_human_name,
:model_b => resource_class.typus_human_name)
redirect_to path || params[:back_to]
end
def error_handler(error, path = admin_dashboard_path)
raise error unless Rails.env.production?
flash[:error] = "#{error.message} (#{@resource[:class]})"
redirect_to path
end
include Typus::MasterControllerExtensions rescue nil
end

View File

@ -1,146 +0,0 @@
class TypusController < ApplicationController
skip_filter filter_chain
unloadable
layout :select_layout
include Typus::Authentication
include Typus::QuickEdit
include Typus::Preferences
include Typus::Reloader
filter_parameter_logging :password
before_filter :verify_typus_users_table_schema
before_filter :reload_config_and_roles
before_filter :require_login,
:except => [ :sign_up, :sign_in, :sign_out,
:recover_password, :reset_password,
:quick_edit ]
before_filter :set_typus_preferences, :only => [ :dashboard ]
before_filter :check_if_user_can_perform_action_on_resource_without_model,
:except => [ :sign_up, :sign_in, :sign_out,
:dashboard,
:recover_password, :reset_password,
:quick_edit ]
before_filter :recover_password_disabled?,
:only => [ :recover_password, :reset_password ]
def dashboard
flash[:notice] = _("There are not defined applications in config/typus/*.yml.") if Typus.applications.empty?
end
def sign_in
redirect_to admin_sign_up_path and return if Typus.user_class.count.zero?
if request.post?
if user = Typus.user_class.authenticate(params[:typus_user][:email], params[:typus_user][:password])
session[:typus_user_id] = user.id
redirect_to params[:back_to] || admin_dashboard_path
else
flash[:error] = _("The email and/or password you entered is invalid.")
redirect_to admin_sign_in_path
end
end
end
def sign_out
session[:typus_user_id] = nil
redirect_to admin_sign_in_path
end
def recover_password
if request.post?
if user = Typus.user_class.find_by_email(params[:typus_user][:email])
url = admin_reset_password_url(:token => user.token)
TypusMailer.deliver_reset_password_link(user, url)
flash[:success] = _("Password recovery link sent to your email.")
redirect_to admin_sign_in_path
else
redirect_to admin_recover_password_path
end
end
end
##
# Available if Typus::Configuration.options[:email] is set.
#
def reset_password
@typus_user = Typus.user_class.find_by_token!(params[:token])
if request.post?
@typus_user.password = params[:typus_user][:password]
@typus_user.password_confirmation = params[:typus_user][:password_confirmation]
if !params[:typus_user][:password].blank? && @typus_user.save
session[:typus_user_id] = @typus_user.id
redirect_to admin_dashboard_path
else
render :action => "reset_password"
end
end
end
def sign_up
redirect_to admin_sign_in_path and return unless Typus.user_class.count.zero?
if request.post?
user = Typus.user_class.generate(:email => params[:typus_user][:email],
:password => Typus::Configuration.options[:default_password],
:role => Typus::Configuration.options[:root])
user.status = true
if user.save
session[:typus_user_id] = user.id
flash[:notice] = _("Password set to \"%{password}\".",
:password => Typus::Configuration.options[:default_password])
redirect_to admin_dashboard_path
else
flash[:error] = _("That doesn't seem like a valid email address.")
end
else
flash[:notice] = _("Enter your email below to create the first user.")
end
end
private
def verify_typus_users_table_schema
attributes = Typus.user_class.model_fields.keys
upgrades = ActiveSupport::OrderedHash.new
upgrades[:role] = "typus_update_schema_to_01"
upgrades[:preferences] = "typus_update_schema_to_02"
upgrades.each do |key, value|
message = "Run `script/generate #{value} -f && rake db:migrate` to update database schema."
raise message if !attributes.include?(key)
end
end
def recover_password_disabled?
redirect_to admin_sign_in_path unless Typus::Configuration.options[:email]
end
def select_layout
%w( sign_up sign_in sign_out
recover_password reset_password ).include?(action_name) ? "typus" : "admin"
end
include Typus::TypusControllerExtensions rescue nil
end

View File

@ -1,464 +0,0 @@
module Admin::FormHelper
def build_form(fields, form)
options = { :form => form }
returning(String.new) do |html|
html << (error_messages_for :item, :header_tag => 'h3')
fields.each do |key, value|
if template = @resource[:class].typus_template(key)
html << typus_template_field(key, template, options)
next
end
html << case value
when :belongs_to then typus_belongs_to_field(key, options)
when :tree then typus_tree_field(key, :form => options[:form])
when :boolean, :date, :datetime, :string, :text, :time,
:file, :password, :selector
typus_template_field(key, value, options)
else
typus_template_field(key, :string, options)
end
end
end
end
# OPTIMIZE: Remove returning(String.new) and return directly the html.
def typus_belongs_to_field(attribute, options)
form = options[:form]
##
# We only can pass parameters to 'new' and 'edit', so this hack makes
# the work to replace the current action.
#
params[:action] = (params[:action] == 'create') ? 'new' : params[:action]
back_to = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id])
related = @resource[:class].reflect_on_association(attribute.to_sym).class_name.constantize
related_fk = @resource[:class].reflect_on_association(attribute.to_sym).primary_key_name
confirm = [ _("Are you sure you want to leave this page?"),
_("If you have made any changes to the fields without clicking the Save/Update entry button, your changes will be lost."),
_("Click OK to continue, or click Cancel to stay on this page.") ]
returning(String.new) do |html|
message = link_to _("Add"), { :controller => "admin/#{related.class_name.tableize}",
:action => 'new',
:back_to => back_to,
:selected => related_fk },
:confirm => confirm.join("\n\n") if @current_user.can?('create', related)
if related.respond_to?(:roots)
html << typus_tree_field(related_fk, :items => related.roots,
:attribute_virtual => related_fk,
:form => form)
else
values = related.find(:all, :order => related.typus_order_by).collect { |p| [p.to_label, p.id] }
options = { :include_blank => true }
html_options = { :disabled => attribute_disabled?(attribute) }
label_text = @resource[:class].human_attribute_name(attribute)
html << <<-HTML
<li>
#{form.label related_fk, "#{label_text} <small>#{message}</small>"}
#{form.select related_fk, values, options, html_options }
</li>
HTML
end
end
end
# OPTIMIZE: Move html code to partial.
def typus_tree_field(attribute, *args)
options = args.extract_options!
options[:items] ||= @resource[:class].roots
options[:attribute_virtual] ||= 'parent_id'
form = options[:form]
values = expand_tree_into_select_field(options[:items], options[:attribute_virtual])
label_text = @resource[:class].human_attribute_name(attribute)
<<-HTML
<li>
#{form.label label_text}
#{form.select options[:attribute_virtual], values, { :include_blank => true }}
</li>
HTML
end
# OPTIMIZE: Cleanup the case statement.
def typus_relationships
@back_to = url_for(:controller => params[:controller], :action => params[:action], :id => params[:id])
returning(String.new) do |html|
@resource[:class].typus_defaults_for(:relationships).each do |relationship|
association = @resource[:class].reflect_on_association(relationship.to_sym)
next if @current_user.cannot?('read', association.class_name.constantize)
macro = association.through_reflection ? :has_and_belongs_to_many : association.macro
case macro
when :has_and_belongs_to_many
html << typus_form_has_and_belongs_to_many(relationship)
when :has_many
if association.options[:through]
# Here we will shot the relationship. Better this than raising an error.
else
html << typus_form_has_many(relationship)
end
when :has_one
html << typus_form_has_one(relationship)
end
end
end
end
# OPTIMIZE: Move html code to partial.
def typus_form_has_many(field)
returning(String.new) do |html|
model_to_relate = @resource[:class].reflect_on_association(field.to_sym).class_name.constantize
model_to_relate_as_resource = model_to_relate.name.tableize
reflection = @resource[:class].reflect_on_association(field.to_sym)
association = reflection.macro
foreign_key = reflection.through_reflection ? reflection.primary_key_name.pluralize : reflection.primary_key_name
link_options = { :controller => "admin/#{model_to_relate_as_resource.pluralize}",
:action => 'new',
:back_to => "#{@back_to}##{field}",
:resource => @resource[:self].singularize,
:resource_id => @item.id,
foreign_key => @item.id }
condition = if @resource[:class].typus_user_id? && @current_user.is_not_root?
@item.owned_by?(@current_user)
else
true
end
# If the form_for_<model>_relationship partial exists we consider
# we want to add only items from our form, and not going to the
# new action. So we don't show the add new.
# Partial exists?
partial = "form_for_#{model_to_relate_as_resource}_relationship"
partial_path = Rails.root.join('app', 'views', 'admin', 'cars', "_#{partial}.html.erb").to_s
if condition && @current_user.can?('create', model_to_relate) && !File.exists?(partial_path)
add_new = <<-HTML
<small>#{link_to _("Add new"), link_options}</small>
HTML
end
html << <<-HTML
<a name="#{field}"></a>
<div class="box_relationships" id="#{model_to_relate_as_resource}">
<h2>
#{link_to model_to_relate.pluralized_human_name, { :controller => "admin/#{model_to_relate_as_resource}", foreign_key => @item.id }, :title => _("%{model} filtered by %{filtered_by}", :model => model_to_relate.typus_human_name.pluralize, :filtered_by => @item.to_label)}
#{add_new}
</h2>
HTML
if File.exists?(partial_path)
html << <<-HTML
#{render :partial => partial}
HTML
end
##
# It's a has_many relationship, so items that are already assigned to another
# entry are assigned to that entry.
#
items_to_relate = model_to_relate.find(:all, :conditions => ["#{foreign_key} is ?", nil])
if condition && !items_to_relate.empty?
html << <<-HTML
#{form_tag :action => 'relate', :id => @item.id}
#{hidden_field :related, :model, :value => model_to_relate}
<p>#{select :related, :id, items_to_relate.collect { |f| [f.to_label, f.id] }.sort_by { |e| e.first } } &nbsp; #{submit_tag _("Add"), :class => 'button'}</p>
</form>
HTML
end
conditions = if model_to_relate.typus_options_for(:only_user_items) && @current_user.is_not_root?
{ Typus.user_fk => @current_user }
end
options = { :order => model_to_relate.typus_order_by, :conditions => conditions }
items_count = @resource[:class].find(params[:id]).send(field).count(:conditions => conditions)
items_per_page = model_to_relate.typus_options_for(:per_page).to_i
@pager = ::Paginator.new(items_count, items_per_page) do |offset, per_page|
eager_loading = model_to_relate.reflect_on_all_associations(:belongs_to).map { |i| i.name } - [@resource[:class].name.downcase.to_sym]
options.merge!({:limit => per_page, :offset => offset, :include => eager_loading})
items = @resource[:class].find(params[:id]).send(field).find(:all, options)
end
@items = @pager.page(params[:page])
unless @items.empty?
options = { :back_to => "#{@back_to}##{field}", :resource => @resource[:self], :resource_id => @item.id }
html << build_list(model_to_relate,
model_to_relate.typus_fields_for(:relationship),
@items,
model_to_relate_as_resource,
options,
association)
html << pagination(:anchor => model_to_relate.name.tableize) unless pagination.nil?
else
message = _("There are no %{records}.",
:records => model_to_relate.typus_human_name.pluralize.downcase)
html << <<-HTML
<div id="flash" class="notice"><p>#{message}</p></div>
HTML
end
html << <<-HTML
</div>
HTML
end
end
# OPTIMIZE: Move html code to partial.
def typus_form_has_and_belongs_to_many(field)
returning(String.new) do |html|
model_to_relate = @resource[:class].reflect_on_association(field.to_sym).class_name.constantize
model_to_relate_as_resource = model_to_relate.name.tableize
reflection = @resource[:class].reflect_on_association(field.to_sym)
association = reflection.macro
through = !reflection.through_reflection.nil?
condition = if @resource[:class].typus_user_id? && !@current_user.is_root?
@item.owned_by?(@current_user)
else
true
end
if condition && @current_user.can?('create', model_to_relate)
add_new = <<-HTML
<small>#{link_to _("Add new"), :controller => field, :action => 'new', :back_to => @back_to, :resource => @resource[:self], :resource_id => @item.id}</small>
HTML
end
html << <<-HTML
<a name="#{field}"></a>
<div class="box_relationships" id="#{model_to_relate_as_resource}">
<h2>
#{link_to model_to_relate.typus_human_name.pluralize, :controller => "admin/#{model_to_relate_as_resource}"}
#{add_new unless through}
</h2>
HTML
if model_to_relate.count < 500
items_to_relate = (model_to_relate.find(:all) - @item.send(field))
if condition && !items_to_relate.empty?
html << <<-HTML
#{form_tag :action => 'relate', :id => @item.id}
#{hidden_field(:related, :relation, :value => field) if through}
#{hidden_field :related, :model, :value => model_to_relate}
<p>#{select :related, :id, items_to_relate.collect { |f| [f.to_label, f.id] }.sort_by { |e| e.first } } &nbsp; #{submit_tag _("Add"), :class => 'button'}</p>
</form>
HTML
end
end
conditions = if model_to_relate.typus_options_for(:only_user_items) && @current_user.is_not_root?
{ Typus.user_fk => @current_user }
end
options = { :order => model_to_relate.typus_order_by, :conditions => conditions }
items_count = @resource[:class].find(params[:id]).send(field).count(:conditions => conditions)
items_per_page = model_to_relate.typus_options_for(:per_page).to_i
@pager = ::Paginator.new(items_count, items_per_page) do |offset, per_page|
options.merge!({:limit => per_page, :offset => offset})
items = @resource[:class].find(params[:id]).send(field).find(:all, options)
end
@items = @pager.page(params[:page])
unless @items.empty?
html << build_list(model_to_relate,
model_to_relate.typus_fields_for(:relationship),
@items,
model_to_relate_as_resource,
{},
association)
html << pagination(:anchor => model_to_relate.name.tableize) unless pagination.nil?
else
message = _("There are no %{records}.",
:records => model_to_relate.typus_human_name.pluralize.downcase)
html << <<-HTML
<div id="flash" class="notice"><p>#{message}</p></div>
HTML
end
html << <<-HTML
</div>
HTML
end
end
# OPTIMIZE: Move html code to partial.
def typus_form_has_one(field)
returning(String.new) do |html|
model_to_relate = @resource[:class].reflect_on_association(field.to_sym).class_name.constantize
model_to_relate_as_resource = model_to_relate.name.tableize
reflection = @resource[:class].reflect_on_association(field.to_sym)
association = reflection.macro
foreign_key = reflection.through_reflection ? reflection.primary_key_name.pluralize : reflection.primary_key_name
link_options = { :controller => "admin/#{model_to_relate_as_resource.pluralize}",
:action => 'new',
:back_to => "#{@back_to}##{field}",
:resource => @resource[:self].singularize,
:resource_id => @item.id,
foreign_key => @item.id }
condition = if @resource[:class].typus_user_id? && !@current_user.is_root?
@item.owned_by?(@current_user)
else
true
end
existing_record = instance_eval("@item.#{field}")
if existing_record.nil? && condition && @current_user.can?('create', model_to_relate)
add_new = <<-HTML
<small>#{link_to _("Add new"), link_options}</small>
HTML
end
html << <<-HTML
<a name="#{field}"></a>
<div class="box_relationships" id="#{model_to_relate_as_resource}">
<h2>
#{link_to model_to_relate.typus_human_name, :controller => "admin/#{model_to_relate_as_resource}"}
#{add_new}
</h2>
HTML
items = Array.new
items << @resource[:class].find(params[:id]).send(field) unless @resource[:class].find(params[:id]).send(field).nil?
unless items.empty?
options = { :back_to => @back_to, :resource => @resource[:self], :resource_id => @item.id }
html << build_list(model_to_relate,
model_to_relate.typus_fields_for(:relationship),
items,
model_to_relate_as_resource,
options,
association)
else
message = _("There is no %{records}.",
:records => model_to_relate.typus_human_name.downcase)
html << <<-HTML
<div id="flash" class="notice"><p>#{message}</p></div>
HTML
end
html << <<-HTML
</div>
HTML
end
end
# OPTIMIZE: Cleanup the rescue ...
def typus_template_field(attribute, template, options = {})
template_name = "admin/templates/#{template}"
custom_options = { :start_year => @resource[:class].typus_options_for(:start_year),
:end_year => @resource[:class].typus_options_for(:end_year),
:minute_step => @resource[:class].typus_options_for(:minute_step),
:disabled => attribute_disabled?(attribute),
:include_blank => true }
render template_name, :resource => @resource,
:attribute => attribute,
:options => custom_options,
:html_options => {},
:form => options[:form],
:label_text => @resource[:class].human_attribute_name(attribute)
end
def attribute_disabled?(attribute)
accessible = @resource[:class].accessible_attributes
return accessible.nil? ? false : !accessible.include?(attribute)
end
def typus_preview(item, attribute)
return nil unless @item.send(attribute).exists?
attachment = attribute.split("_file_name").first
file_preview = Typus::Configuration.options[:file_preview]
file_thumbnail = Typus::Configuration.options[:file_thumbnail]
has_file_preview = item.send(attachment).styles.member?(file_preview)
has_file_thumbnail = item.send(attachment).styles.member?(file_thumbnail)
file_preview_is_image = item.send("#{attachment}_content_type") =~ /^image\/.+/
href = if has_file_preview
url = item.send(attachment).url(file_preview)
if ActionController::Base.relative_url_root
ActionController::Base.relative_url_root + url
else
url
end
else
item.send(attachment).url
end
content = if has_file_thumbnail
image_tag item.send(attachment).url(file_thumbnail)
else
_("View %{attribute}", :attribute => @item.class.human_attribute_name(attribute).downcase)
end
render "admin/helpers/preview",
:attribute => attribute,
:content => content,
:has_file_preview => has_file_preview,
:href => href,
:item => item
end
##
# Tree builder when model +acts_as_tree+
#
def expand_tree_into_select_field(items, attribute)
returning(String.new) do |html|
items.each do |item|
html << %{<option #{"selected" if @item.send(attribute) == item.id} value="#{item.id}">#{"&nbsp;" * item.ancestors.size * 2} &#8627; #{item.to_label}</option>\n}
html << expand_tree_into_select_field(item.children, attribute) unless item.children.empty?
end
end
end
include Typus::FormHelperExtensions rescue nil
end

View File

@ -1,63 +0,0 @@
module Admin::MasterHelper
include TypusHelper
include Admin::SidebarHelper
include Admin::FormHelper
include Admin::TableHelper
def display_link_to_previous
options = {}
options[:resource_from] = @resource[:human_name]
options[:resource_to] = params[:resource].classify.constantize.human_name if params[:resource]
editing = %w( edit update ).include?(params[:action])
message = case
when params[:resource] && editing
"You're updating a %{resource_from} for %{resource_to}."
when editing
"You're updating a %{resource_from}."
when params[:resource]
"You're adding a new %{resource_from} to %{resource_to}."
else
"You're adding a new %{resource_from}."
end
message = _(message,
:resource_from => options[:resource_from],
:resource_to => options[:resource_to])
render "admin/helpers/display_link_to_previous", :message => message
end
def remove_filter_link(filter = request.env['QUERY_STRING'])
return unless filter && !filter.blank?
render "admin/helpers/remove_filter_link"
end
##
# If there's a partial with a "microformat" of the data we want to
# display, this will be used, otherwise we use a default table which
# it's build from the options defined on the yaml configuration file.
#
def build_list(model, fields, items, resource = @resource[:self], link_options = {}, association = nil)
template = "app/views/admin/#{resource}/_#{resource.singularize}.html.erb"
if File.exist?(template)
render :partial => template.gsub('/_', '/'), :collection => items, :as => :item
else
build_typus_table(model, fields, items, link_options, association)
end
end
def pagination(*args)
@options = args.extract_options!
render "admin/helpers/pagination" if @items.prev || @items.next
end
end

View File

@ -1,19 +0,0 @@
module Admin
module PublicHelper
##
# Quick edit usage:
#
# <%= quick_edit(:message => "Edit this article", :path => "articles/edit/#{@article.id}") %>
#
# If user is logged in Typus, a link will appear on the top/right of
# the pages where you insert this helper.
#
def quick_edit(*args)
render "admin/helpers/quick_edit", :options => args.extract_options!
end
end
end

View File

@ -1,238 +0,0 @@
module Admin::SidebarHelper
def build_typus_list(items, *args)
return String.new if items.empty?
options = args.extract_options!
header = if options[:header]
_(options[:header].humanize)
elsif options[:attribute]
@resource[:class].human_attribute_name(options[:attribute])
end
render "admin/helpers/list",
:header => header,
:items => items,
:options => options
end
# TODO: Test "Show entry" case.
def actions
items = []
if @current_user.can?('create', @resource[:class])
items << (link_to_unless_current _("Add new"), { :action => 'new' }, :class => 'new')
end
case params[:action]
when 'edit'
items << (link_to _("Show"), :action => 'show', :id => @item.id)
end
case params[:action]
when 'show'
condition = if @resource[:class].typus_user_id? && @current_user.is_not_root?
@item.owned_by?(@current_user)
else
@current_user.can?('update', @resource[:class])
end
items << (link_to_if condition, _("Edit"), :action => 'edit', :id => @item.id)
end
@resource[:class].typus_actions_on(params[:action]).each do |action|
if @current_user.can?(action, @resource[:class])
items << (link_to _(action.humanize), params.merge(:action => action))
end
end
build_typus_list(items, :header => 'actions')
end
def export
formats = @resource[:class].typus_export_formats.map do |format|
link_to _(format.upcase), params.merge(:format => format)
end
build_typus_list(formats, :header => 'export')
end
def search
typus_search = @resource[:class].typus_defaults_for(:search)
return if typus_search.empty?
search_by = typus_search.collect { |x| @resource[:class].human_attribute_name(x) }.to_sentence
search_params = params.dup
%w( action controller search page id ).each { |p| search_params.delete(p) }
hidden_params = search_params.map { |k, v| hidden_field_tag(k, v) }
render "admin/helpers/search",
:hidden_params => hidden_params,
:search_by => search_by
end
def filters
typus_filters = @resource[:class].typus_filters
return if typus_filters.empty?
current_request = request.env['QUERY_STRING'] || []
returning(String.new) do |html|
typus_filters.each do |key, value|
case value
when :boolean then html << boolean_filter(current_request, key)
when :string then html << string_filter(current_request, key)
when :date, :datetime then html << date_filter(current_request, key)
when :belongs_to then html << relationship_filter(current_request, key)
when :has_many || :has_and_belongs_to_many then
html << relationship_filter(current_request, key, true)
when nil then
# Do nothing. This is ugly but for now it's ok.
else
html << string_filter(current_request, key)
end
end
end
end
# OPTIMIZE: Move html code to partial.
def relationship_filter(request, filter, habtm = false)
att_assoc = @resource[:class].reflect_on_association(filter.to_sym)
class_name = att_assoc.options[:class_name] || ((habtm) ? filter.classify : filter.capitalize.camelize)
model = class_name.constantize
related_fk = (habtm) ? filter : att_assoc.primary_key_name
params_without_filter = params.dup
%w( controller action page ).each { |p| params_without_filter.delete(p) }
params_without_filter.delete(related_fk)
items = []
returning(String.new) do |html|
related_items = model.find(:all, :order => model.typus_order_by)
if related_items.size > model.typus_options_for(:sidebar_selector)
related_items.each do |item|
switch = 'selected' if request.include?("#{related_fk}=#{item.id}")
items << <<-HTML
<option #{switch} value="#{url_for params.merge(related_fk => item.id, :page => nil)}">#{truncate(item.to_label, :length => 25)}</option>
HTML
end
model_pluralized = model.name.downcase.pluralize
form = <<-HTML
<!-- Embedded JS -->
<script>
function surfto_#{model_pluralized}(form) {
var myindex = form.#{model_pluralized}.selectedIndex
if (form.#{model_pluralized}.options[myindex].value != "0") {
top.location.href = form.#{model_pluralized}.options[myindex].value;
}
}
</script>
<!-- /Embedded JS -->
<form class="form" action="#"><p>
<select name="#{model_pluralized}" onChange="surfto_#{model_pluralized}(this.form)">
<option value="#{url_for params_without_filter}">#{_("Filter by")} #{_(model.typus_human_name)}</option>
#{items.join("\n")}
</select>
</p></form>
HTML
else
related_items.each do |item|
switch = request.include?("#{related_fk}=#{item.id}") ? 'on' : 'off'
items << (link_to item.to_label, params.merge(related_fk => item.id, :page => nil), :class => switch)
end
end
if form
html << build_typus_list(items, :attribute => filter, :selector => true)
html << form
else
html << build_typus_list(items, :attribute => filter)
end
end
end
def date_filter(request, filter)
if !@resource[:class].typus_field_options_for(:filter_by_date_range).include?(filter.to_sym)
items = %w( today last_few_days last_7_days last_30_days ).map do |timeline|
switch = request.include?("#{filter}=#{timeline}") ? 'on' : 'off'
options = { :page => nil }
if switch == 'on'
params.delete(filter)
else
options.merge!(filter.to_sym => timeline)
end
link_to _(timeline.humanize), params.merge(options), :class => switch
end
build_typus_list(items, :attribute => filter)
else
date_params = params.dup
%w( action controller page id ).each { |p| date_params.delete(p) }
date_params.delete(filter)
hidden_params = date_params.map { |k, v| hidden_field_tag(k, v) }
render "admin/helpers/date", :hidden_params => hidden_params, :filter => filter, :resource => @resource
end
end
def boolean_filter(request, filter)
item_params = params.dup
items = @resource[:class].typus_boolean(filter).map do |key, value|
switch = request.include?("#{filter}=#{key}") ? 'on' : 'off'
options = { :page => nil }
if switch == 'on'
item_params.delete(filter)
else
options.merge!(filter.to_sym => key)
end
link_to _(value), item_params.merge(options), :class => switch
end
build_typus_list(items, :attribute => filter)
end
def string_filter(request, filter)
item_params = params.dup
values = @resource[:class]::const_get("#{filter.to_s.upcase}")
values = values.invert if values.kind_of?(Hash)
items = values.map do |item|
link_name, link_filter = (values.first.kind_of?(Array)) ? [ item.first, item.last ] : [ item, item ]
switch = (params[filter.to_s] == link_filter) ? 'on' : 'off'
options = { :page => nil }
if switch == 'on'
item_params.delete(filter)
else
options.merge!(filter.to_sym => link_filter)
end
link_to link_name, item_params.merge(options), :class => switch
end
build_typus_list(items, :attribute => filter)
end
include Typus::SidebarHelperExtensions rescue nil
end

View File

@ -1,261 +0,0 @@
module Admin::TableHelper
# OPTIMIZE: Move html code to partial & refactor.
def build_typus_table(model, fields, items, link_options = {}, association = nil)
returning(String.new) do |html|
html << <<-HTML
<table class="typus">
HTML
html << typus_table_header(model, fields)
items.each do |item|
html << <<-HTML
<tr class="#{cycle('even', 'odd')} #{item.class.name.underscore}" id="#{item.to_dom}" name="item_#{item.id}">
HTML
fields.each do |key, value|
case value
when :boolean then html << typus_table_boolean_field(key, item)
when :datetime then html << typus_table_datetime_field(key, item, link_options)
when :date then html << typus_table_datetime_field(key, item, link_options)
when :file then html << typus_table_file_field(key, item, link_options)
when :time then html << typus_table_datetime_field(key, item, link_options)
when :belongs_to then html << typus_table_belongs_to_field(key, item)
when :tree then html << typus_table_tree_field(key, item)
when :position then html << typus_table_position_field(key, item)
when :selector then html << typus_table_selector(key, item)
when :has_and_belongs_to_many then
html << typus_table_has_and_belongs_to_many_field(key, item)
else
html << typus_table_string_field(key, item, link_options)
end
end
action = if model.typus_user_id? && @current_user.is_not_root?
# If there's a typus_user_id column on the table and logged user is not root ...
item.owned_by?(@current_user) ? item.class.typus_options_for(:default_action_on_item) : 'show'
elsif @current_user.cannot?('edit', model)
'show'
else
item.class.typus_options_for(:default_action_on_item)
end
content = link_to _(action.capitalize), :controller => "admin/#{item.class.name.tableize}", :action => action, :id => item.id
html << <<-HTML
<td width="10px">#{content}</td>
HTML
##
# This controls the action to perform. If we are on a model list we
# will remove the entry, but if we inside a model we will remove the
# relationship between the models.
#
# Only shown is the user can destroy/unrelate items.
#
trash = %Q(<div class="sprite trash">Trash</div>)
unrelate = %Q(<div class="sprite unrelate">Unrelate</div>)
case params[:action]
when 'index'
condition = if model.typus_user_id? && @current_user.is_not_root?
item.owned_by?(@current_user)
elsif (@current_user.id.eql?(item.id) && model.eql?(Typus.user_class))
false
else
@current_user.can?('destroy', model)
end
message = _("You are about to delete a %{model}.\nAre you sure you want to continue?", :model => model.human_name.downcase)
perform = link_to trash, { :action => 'destroy', :id => item.id },
:title => _("Remove"),
:confirm => _(message) if condition
when 'edit'
# If we are editing content, we can relate and unrelate always!
perform = link_to unrelate, { :action => 'unrelate', :id => params[:id], :resource => model, :resource_id => item.id },
:title => _("Unrelate"),
:confirm => _("Unrelate %{unrelate_model} from %{unrelate_model_from}?",
:unrelate_model => model.typus_human_name,
:unrelate_model_from => @resource[:human_name])
when 'show'
# If we are showing content, we only can relate and unrelate if we are
# the owners of the owner record.
# If the owner record doesn't have a foreign key (Typus.user_fk) we look
# each item to verify the ownership.
condition = if @resource[:class].typus_user_id? && @current_user.is_not_root?
@item.owned_by?(@current_user)
end
perform = link_to unrelate, { :action => 'unrelate', :id => params[:id], :resource => model, :resource_id => item.id },
:title => _("Unrelate"),
:confirm => _("Unrelate %{unrelate_model} from %{unrelate_model_from}?",
:unrelate_model => model.typus_human_name,
:unrelate_model_from => @resource[:human_name]) if condition
end
html << <<-HTML
<td width="10px">#{perform}</td>
</tr>
HTML
end
html << "</table>"
end
end
def typus_table_header(model, fields)
headers = fields.map do |key, value|
content = key.end_with?('_id') ? key : model.human_attribute_name(key)
if (model.model_fields.map(&:first).collect { |i| i.to_s }.include?(key) || model.reflect_on_all_associations(:belongs_to).map(&:name).include?(key.to_sym)) && params[:action] == 'index'
sort_order = case params[:sort_order]
when 'asc' then ['desc', '&darr;']
when 'desc' then ['asc', '&uarr;']
else
[nil, nil]
end
order_by = model.reflect_on_association(key.to_sym).primary_key_name rescue key
switch = sort_order.last if params[:order_by].eql?(order_by)
options = { :order_by => order_by, :sort_order => sort_order.first }
content = link_to "#{content} #{switch}", params.merge(options)
end
content
end
headers << "&nbsp;" if @current_user.can?('delete', model)
render "admin/helpers/table_header",
:headers => headers
end
# OPTIMIZE: Refactor (Remove rescue)
def typus_table_belongs_to_field(attribute, item)
action = item.send(attribute).class.typus_options_for(:default_action_on_item) rescue 'edit'
att_value = item.send(attribute)
content = if !att_value.nil?
if @current_user.can?(action, att_value.class.name)
link_to item.send(attribute).to_label, :controller => "admin/#{att_value.class.name.tableize}", :action => action, :id => att_value.id
else
att_value.to_label
end
end
return content_tag(:td, content)
end
def typus_table_has_and_belongs_to_many_field(attribute, item)
content = item.send(attribute).map { |i| i.to_label }.join('<br />')
return content_tag(:td, content)
end
def typus_table_string_field(attribute, item, link_options = {})
content = h(item.send(attribute))
return content_tag(:td, content, :class => attribute)
end
def typus_table_selector(attribute, item)
content = h(item.mapping(attribute))
return content_tag(:td, content, :class => attribute)
end
def typus_table_file_field(attribute, item, link_options = {})
attachment = attribute.split("_file_name").first
file_preview = Typus::Configuration.options[:file_preview]
file_thumbnail = Typus::Configuration.options[:file_thumbnail]
has_file_preview = item.send(attachment).styles.member?(file_preview)
file_preview_is_image = item.send("#{attachment}_content_type") =~ /^image\/.+/
content = if has_file_preview && file_preview_is_image
render "admin/helpers/preview",
:attribute => attribute,
:attachment => attachment,
:content => item.send(attribute),
:has_file_preview => has_file_preview,
:href => item.send(attachment).url(file_preview),
:item => item
else
link_to item.send(attribute), item.send(attachment).url
end
return content_tag(:td, content)
end
# OPTIMIZE: Move html code to partial.
def typus_table_tree_field(attribute, item)
<<-HTML
<td>#{item.parent.to_label if item.parent}</td>
HTML
end
# OPTIMIZE: Move html code to partial.
def typus_table_position_field(attribute, item)
html_position = []
[['Up', 'move_higher'], ['Down', 'move_lower']].each do |position|
options = { :controller => item.class.name.tableize,
:action => 'position',
:id => item.id,
:go => position.last }
first_or_last = (item.respond_to?(:first?) && (position.last == 'move_higher' && item.first?)) || (item.respond_to?(:last?) && (position.last == 'move_lower' && item.last?))
html_position << link_to_unless(first_or_last, _(position.first), params.merge(options)) do |name|
%(<span class="inactive">#{name}</span>)
end
end
content = html_position.join(' / ')
return content_tag(:td, content)
end
def typus_table_datetime_field(attribute, item, link_options = {} )
date_format = item.class.typus_date_format(attribute)
content = !item.send(attribute).nil? ? item.send(attribute).to_s(date_format) : item.class.typus_options_for(:nil)
return content_tag(:td, content)
end
def typus_table_boolean_field(attribute, item)
boolean_hash = item.class.typus_boolean(attribute)
status = item.send(attribute)
link_text = boolean_hash["#{status}".to_sym]
options = { :controller => "admin/#{item.class.name.tableize}",
:action => 'toggle',
:id => item.id,
:field => attribute.gsub(/\?$/,'') }
confirm = _("Change %{attribute}?",
:attribute => item.class.human_attribute_name(attribute).downcase)
content = link_to _(link_text), options, :confirm => confirm
return content_tag(:td, content)
end
include Typus::TableHelperExtensions rescue nil
end

View File

@ -1,101 +0,0 @@
module TypusHelper
def applications
apps = ActiveSupport::OrderedHash.new
Typus.applications.each do |app|
available = Typus.application(app).map do |resource|
resource if @current_user.resources.include?(resource)
end.compact
next if available.empty?
apps[app] = available.sort_by { |x| x.constantize.typus_human_name }
end
render "admin/helpers/applications", :applications => apps
end
def resources
available = Typus.resources.map do |resource|
resource if @current_user.resources.include?(resource)
end.compact
return if available.empty?
render "admin/helpers/resources", :resources => available
end
def typus_block(*args)
options = args.extract_options!
partials_path = "admin/#{options[:location]}"
resources_partials_path = 'admin/resources'
partials = ActionController::Base.view_paths.map do |view_path|
Dir["#{view_path.path}/#{partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
end.flatten
resources_partials = Dir["#{Rails.root}/app/views/#{resources_partials_path}/*"].map { |f| File.basename(f, '.html.erb') }
partial = "_#{options[:partial]}"
path = if partials.include?(partial) then partials_path
elsif resources_partials.include?(partial) then resources_partials_path
end
render "#{path}/#{options[:partial]}" if path
end
def page_title(action = params[:action])
crumbs = []
crumbs << @resource[:pluralized] if @resource
crumbs << _(action.humanize) unless %w( index ).include?(action)
return crumbs.compact.map { |x| x }.join(' &rsaquo; ')
end
def header
links = []
links << (link_to_unless_current _("Dashboard"), admin_dashboard_path)
Typus.models_on_header.each do |model|
links << (link_to_unless_current model.constantize.pluralized_human_name, :controller => "/admin/#{model.tableize}")
end
render "admin/helpers/header", :links => links
end
def login_info(user = @current_user)
admin_edit_typus_user_path = { :controller => "/admin/#{Typus::Configuration.options[:user_class_name].tableize}",
:action => 'edit',
:id => user.id }
message = _("Are you sure you want to sign out and end your session?")
user_details = if user.can?('edit', Typus::Configuration.options[:user_class_name])
link_to user.name, admin_edit_typus_user_path, :title => "#{user.email} (#{user.role})"
else
user.name
end
render "admin/helpers/login_info", :message => message, :user_details => user_details
end
def display_flash_message(message = flash)
return if message.empty?
flash_type = message.keys.first
render "admin/helpers/flash_message", :flash_type => flash_type, :message => message
end
end

View File

@ -1,12 +0,0 @@
class TypusMailer < ActionMailer::Base
self.template_root = "#{File.dirname(__FILE__)}/../views"
def reset_password_link(user, url)
subject "[#{Typus::Configuration.options[:app_name]}] #{_("Reset password")}"
body :user => user, :url => url
recipients user.email
from Typus::Configuration.options[:email]
end
end

View File

@ -1,8 +0,0 @@
class TypusUser < ActiveRecord::Base
ROLE = Typus::Configuration.roles.keys.sort
LANGUAGE = Typus.locales
enable_as_typus_user
end

View File

@ -1,5 +0,0 @@
<h2>Welcome!</h2>
<p>If you need help don't hesitate in joining the <%= link_to 'mailing list', 'http://groups.google.com/group/typus' %>.</p>
<p>Replace this sidebar dropping a file named <code>_sidebar.html.erb</code> on the <code>app/views/admin/dashboard</code> folder.</p>

View File

@ -1,39 +0,0 @@
<% applications.each do |app, models| %>
<table class="typus">
<tr>
<th colspan="2"><%= _(app) %></th>
</tr>
<% models.each do |model| %>
<%
klass = model.constantize
klass_resource = klass.name.tableize
klass_human_name = klass.pluralized_human_name
admin_items_path = { :controller => "admin/#{klass_resource}" }
new_admin_item_path = { :controller => "admin/#{klass_resource}", :action => 'new'}
%>
<tr class="<%= cycle('even', 'odd') %>">
<td>
<%= link_to klass_human_name, admin_items_path %><br />
<small><%= _(klass.typus_description) if !klass.typus_description.nil? %></small>
</td>
<td class="right">
<small><%= link_to_if @current_user.can?('create', klass), _("Add"), new_admin_item_path %></small>
</td>
</tr>
<% end %>
</table>
<% end %>

View File

@ -1,26 +0,0 @@
<%
if params[filter.to_s].is_a?(Hash)
date_from = params[filter.to_s]["from"]
date_to = params[filter.to_s]["to"]
else
date_from = ""
date_to = ""
end
date_format = Date::DATE_FORMATS[@resource[:class].typus_date_format(filter)]
%>
<h2><%= @resource[:class].human_attribute_name(filter) %></h2>
<ul>
<% form_tag url_for(:controller => params[:controller], :action => params[:action]), :method => :get do %>
<li>
<%= text_field_tag "#{filter}[from]", date_from, :size => 10, :class => :date_input, :date_format => date_format %>
-
<%= text_field_tag "#{filter}[to]", date_to, :size => 10, :class => :date_input, :date_format => date_format %>
</li>
<li>
<%= hidden_params.sort.join("\n") %>
<%= submit_tag _("Filter") %>
</li>
<% end %>
</ul>

View File

@ -1,3 +0,0 @@
<div id="flash" class="notice">
<p><%= message %> <%= link_to _("Do you want to cancel it?"), params[:back_to] %></p>
</div>

View File

@ -1,3 +0,0 @@
<div id="flash" class="<%= flash_type %>">
<p><%= message[flash_type] %></p>
</div>

View File

@ -1,13 +0,0 @@
<h1>
<% if ActionController::Routing::Routes.named_routes.routes.has_key?(:root) %>
<%= link_to Typus::Configuration.options[:app_name], root_path, :title => _("View site") %>
<% else %>
<%= Typus::Configuration.options[:app_name] %>
<% end %>
</h1>
<ul>
<% links.each do |link| -%>
<li><%= link %></li>
<% end -%>
</ul>

View File

@ -1,11 +0,0 @@
<%= content_tag('h2', header) if header %>
<% unless options[:selector] %>
<ul>
<% items.each do |item| %>
<li><%= item %></li>
<% end %>
</ul>
<% end %>

View File

@ -1,4 +0,0 @@
<ul>
<li><%= _("Logged as") %> <%= user_details %></li>
<li><%= link_to _("Sign out"), admin_sign_out_path, { :confirm => message } %></li>
</ul>

View File

@ -1,15 +0,0 @@
<div class="pagination">
<% if @items.prev? %>
<%= link_to "&larr; " + _("Previous"), params.merge(:page => @items.prev.number, :anchor => @options[:anchor]) %>
<% else %>
<span class="disabled"><%= "&larr; " + _("Previous") %></span>
<% end %>
<% if @items.next? %>
<%= link_to _("Next") + " &rarr;", params.merge(:page => @items.next.number, :anchor => @options[:anchor]) %>
<% else %>
<span class="disabled"><%= _("Next") + " &rarr;" %></span>
<% end %>
</div>

View File

@ -1,13 +0,0 @@
<%
dom = item.to_dom(:suffix => "#{attribute}_preview" )
%>
<% if has_file_preview %>
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#<%= dom %>").fancybox();
});
</script>
<% end %>
<a id="<%= dom %>" href="<%= href %>" title="<%= item.to_label %>"><%= content %></a>

View File

@ -1,3 +0,0 @@
<script type="text/javascript">
document.write('<script type="text/javascript" src="<%= admin_quick_edit_path %>?#<%= options.to_query %>" />');
</script>

View File

@ -1 +0,0 @@
<small><%= link_to _("Remove filter") %></small>

View File

@ -1,14 +0,0 @@
<table class="typus">
<tr>
<th colspan="2"><%= _("Resources") %></th>
</tr>
<% resources.each do |resource| %>
<tr class="<%= cycle('even', 'odd') %>">
<td><%= link_to _(resource.titleize.capitalize), :controller => "admin/#{resource.underscore}" %></td>
<td align="right" style="vertical-align: bottom;"></td>
</tr>
<% end %>
</table>

View File

@ -1,8 +0,0 @@
<h2><%= _("Search") %></h2>
<% form_tag url_for(:controller => params[:controller]), :method => :get do %>
<p><input id="search" name="search" type="text" value="<%= params[:search] %>"/></p>
<%= hidden_params.sort.join("\n") %>
<% end %>
<p class="tip"><%= _("Search by") %> <%= search_by.downcase %>.</p>

View File

@ -1,5 +0,0 @@
<tr>
<% headers.each do |header| %>
<th><%= header %></th>
<% end %>
</tr>

View File

@ -1,12 +0,0 @@
<% form_for @item, :url => options, :builder => ActionView::Helpers::FormBuilder, :html => { :multipart => true } do |form| %>
<fieldset class="inputs">
<ol>
<%= build_form(@fields, form) %>
</ol>
</fieldset>
<fieldset class="buttons">
<ol>
<li><%= submit_tag button , :class => 'commit' %></li>
</ol>
</fieldset>
<% end %>

View File

@ -1,25 +0,0 @@
<% content_for :sidebar do %>
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
<%= actions %>
<%= search %>
<% end %>
<%= display_link_to_previous if params[:back_to] %>
<h2><%= link_to @resource[:pluralized], :action => 'index' %> &rsaquo;
<%= _("Edit") %></h2>
<%= typus_block :location => @resource[:self], :partial => 'edit' %>
<%
options = { :action => 'update',
:id => @item.id ,
:back_to => params[:back_to],
:resource => params[:resource],
:resource_id => params[:resource_id]}
button = _("Save %{resource}", :resource => @resource[:human_name])
%>
<%= render "form", :options => options, :button => button %>
<%= typus_relationships %>

View File

@ -1,21 +0,0 @@
<% content_for :sidebar do %>
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
<%= actions %>
<%= export %>
<%= search %>
<%= filters %>
<% end %>
<h2><%= @resource[:pluralized] %> <%= remove_filter_link %></h2>
<%= typus_block :location => @resource[:self], :partial => 'index' %>
<% unless @items.count.zero? -%>
<%= build_list(@resource[:class], @fields, @items) %>
<%= pagination %>
<% else %>
<div id="flash" class="notice">
<% message = @resource[:class].count.zero? ? "There are no %{records}." : "There are no %{records} under this filter." %>
<p><%= _(message, :records => @resource[:human_name].pluralize.downcase) %></p>
</div>
<% end %>

View File

@ -1,22 +0,0 @@
<% content_for :sidebar do %>
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
<%= actions %>
<% end %>
<%= display_link_to_previous if params[:back_to] %>
<h2><%= link_to @resource[:pluralized], :action => 'index' %> &rsaquo;
<%= _("New") %></h2>
<%= typus_block :location => @resource[:self], :partial => 'new' %>
<%
options = { :action => 'create',
:back_to => params[:back_to],
:selected => params[:selected],
:resource => params[:resource],
:resource_id => params[:resource_id] }
button = _("Create %{resource}", :resource => @resource[:human_name])
%>
<%= render "form", :options => options, :button => button %>

View File

@ -1,45 +0,0 @@
<% content_for :sidebar do %>
<%= typus_block :location => @resource[:self], :partial => 'sidebar' %>
<%= actions %>
<%= search %>
<% end %>
<h2><%= link_to @resource[:pluralized], :action => 'index' %> &rsaquo;
<%= _("Show") %></h2>
<%= typus_block :location => @resource[:self], :partial => 'show' %>
<dl>
<%- @fields.each do |field| -%>
<dt><%=h @resource[:class].human_attribute_name(field.first) %></dt>
<%-
data_type = field.last
raw_data = @item.send(field.first)
data = case data_type
when :boolean
boolean_hash = @resource[:class].typus_boolean(field.first)
!raw_data.nil? ? boolean_hash["#{raw_data}".to_sym] : @resource[:class].typus_options_for(:nil)
when :belongs_to
if !raw_data.nil?
controller = raw_data.class.name.extract_resource.pluralize
action = raw_data.class.typus_options_for(:default_action_on_item)
options = { :controller => controller, :action => action, :id => raw_data }
link_to raw_data.to_label, options
else
h(raw_data)
end
when :file
typus_preview(@item, field.first)
when :text
defined?(RDiscount) ? markdown(raw_data) : simple_format(h(raw_data))
when :selector
@item.mapping(field.first)
else
h(raw_data)
end
-%>
<dd><%= !data.blank? ? data : ('&#151;') %></dd>
<%- end -%>
</dl>
<%= typus_relationships %>

View File

@ -1 +0,0 @@
<p><%= link_to 'Typus', 'http://core.typuscms.com/' %> by <%= link_to 'intraducibles.com', 'http://intraducibles.com' %>.</p>

View File

@ -1,4 +0,0 @@
<li>
<%= form.label attribute, label_text, :class => 'inline_label' %>
<%= form.check_box attribute, options %>
</li>

View File

@ -1,9 +0,0 @@
<%
custom = { :include_blank => false }
options.merge!(custom)
%>
<li>
<%= form.label attribute, label_text %>
<%= form.date_select attribute, options, html_options %>
</li>

View File

@ -1,9 +0,0 @@
<%
custom = { :include_blank => false }
options.merge!(custom)
%>
<li>
<%= form.label attribute, label_text %>
<%= form.datetime_select attribute, options, html_options %>
</li>

View File

@ -1,19 +0,0 @@
<%
if @item.send(attribute).exists?
message = _("Remove %{attribute}", :attribute => @item.class.human_attribute_name(attribute).downcase)
label_text << <<-HTML
<small>#{link_to message, { :action => 'detach',
:id => @item.id,
:attachment => attribute },
:confirm => _("Are you sure?")}</small>
HTML
end
%>
<li>
<%= form.label attribute, label_text %>
<%= form.file_field attribute, options %>
<%= typus_preview(@item, attribute) %>
</li>

View File

@ -1,4 +0,0 @@
<li>
<%= form.label attribute, label_text %>
<%= form.password_field attribute, options %>
</li>

View File

@ -1,9 +0,0 @@
<%
values = @resource[:class]::const_get("#{attribute.upcase}")
values = values.invert if values.kind_of?(Hash)
%>
<li>
<%= form.label attribute, label_text %>
<%= form.select attribute, values, options, html_options %>
</li>

View File

@ -1,22 +0,0 @@
<%
# Read only fields.
if @resource[:class].typus_field_options_for(:read_only).to_s.include?(attribute)
custom = { :readonly => 'readonly' }
label_text << " <small>#{_("Read only")}</small>"
end
# Auto generated fields.
if @resource[:class].typus_field_options_for(:auto_generated).include?(attribute)
custom = { :auto_generated => true }
label_text << " <small>#{_("Auto generated")}</small>"
end
options.merge!(custom) if custom
%>
<li>
<%= form.label attribute, label_text %>
<%= form.text_field attribute, options %>
</li>

View File

@ -1,9 +0,0 @@
<%
custom = { :rows => @resource[:class].typus_options_for(:form_rows) }
options = options.merge!(custom)
%>
<li>
<%= form.label attribute, label_text %>
<%= form.text_area attribute, options %>
</li>

View File

@ -1,9 +0,0 @@
<%
custom = { :include_blank => false }
options.merge!(custom)
%>
<li>
<%= form.label attribute, label_text %>
<%= form.time_select attribute, options, html_options %>
</li>

View File

@ -1,69 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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><%= page_title %></title>
<%= stylesheet_link_tag 'admin/reset',
'admin/screen',
'admin/jquery.fancybox-1.3.0' %>
<%= yield :stylesheets -%>
<%= javascript_include_tag 'admin/jquery-1.4.1.min',
'admin/jquery.fancybox-1.3.0.pack',
'admin/application' %>
<%= yield :javascripts -%>
</head>
<body>
<div id="header_wrapper">
<div id="header">
<div class="left">
<%= header %>
</div>
<div class="right">
<%= login_info %>
</div>
<div class="clear"></div>
</div>
</div>
<div id="wrapper">
<div id="content_wrapper">
<div id="content">
<%= display_flash_message %>
<%= yield %>
</div>
<div id="sidebar">
<%= yield :sidebar %>
</div>
<div class="clear"></div>
</div>
</div>
<div id="footer_wrapper">
<div id="footer">
<%= typus_block :location => 'shared', :partial => 'footer' %>
</div>
</div>
</body>
</html>

View File

@ -1,33 +0,0 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=500, initial-scale=0.60, minimum-scale=0.60" />
<title><%= page_title %></title>
<%= stylesheet_link_tag 'admin/reset', :media => 'screen' %>
<%= stylesheet_link_tag 'admin/screen', :media => 'screen' %>
</head>
<body>
<div id="dialog">
<h1><%= Typus::Configuration.options[:app_name] %></h1>
<%= display_flash_message %>
<%= yield %>
</div>
<div id="bottom_dialog">
<%= typus_block :location => 'shared', :partial => 'footer' %>
</div>
</body>
</html>

View File

@ -1,9 +0,0 @@
<% content_for :sidebar do %>
<%= typus_block :location => 'dashboard', :partial => 'sidebar' %>
<% end %>
<h2><%= _("Dashboard") %></h2>
<%= applications %>
<%= resources %>

View File

@ -1,16 +0,0 @@
<% form_for :typus_user, :url => { :action => :recover_password } do |form| %>
<ul>
<li>
<%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
<%= form.text_field :email, :size => 20, :class => 'text' %>
</li>
<li>
<%= submit_tag _("Recover password"), :class => 'button' %> <%= link_to _("I remember my password"), admin_sign_in_path %>
</li>
</ul>
<% end %>

View File

@ -1,25 +0,0 @@
<% form_for :typus_user, :url => { :action => :reset_password } do |form| %>
<%= hidden_field_tag :token, @typus_user.token %>
<%= error_messages_for :typus_user, :header_message => nil, :message => nil %>
<ul>
<li>
<%= form.label :password, Typus.user_class.human_attribute_name(:password) %>
<%= form.password_field :password, :size => 20, :class => 'text' %>
</li>
<li>
<%= form.label :password_confirmation, Typus.user_class.human_attribute_name(:password_confirmation) %>
<%= form.password_field :password_confirmation, :size => 20, :class => 'text' %>
</li>
<li>
<%= submit_tag _("Change password"), :class => 'button' %> <%= link_to _("I remember my password"), admin_sign_in_path %>
</li>
</ul>
<% end %>

View File

@ -1,21 +0,0 @@
<% form_for :typus_user, :url => { :action => 'sign_in' } do |form| %>
<ul>
<li>
<%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
<%= form.text_field :email, :size => 20, :class => 'text' %>
</li>
<li>
<%= form.label :password, Typus.user_class.human_attribute_name(:password) %>
<%= form.password_field :password, :size => 20, :class => 'text' %>
</li>
<li>
<%= submit_tag _("Sign in"), :class => 'button' %> <%= link_to _("Recover password"), admin_recover_password_path if Typus::Configuration.options[:email] %>
</li>
</ul>
<% end %>

View File

@ -1,16 +0,0 @@
<% form_for :typus_user, :url => { :action => :sign_up } do |form| %>
<ul>
<li>
<%= form.label :email, Typus.user_class.human_attribute_name(:email) %>
<%= form.text_field :email, :size => 20, :class => 'text' %>
</li>
<li>
<%= submit_tag _("Sign up"), :class => 'button' %>
</li>
</ul>
<% end %>

Some files were not shown because too many files have changed in this diff Show More