Skip to content

Commit

Permalink
Updated javascript guide
Browse files Browse the repository at this point in the history
  • Loading branch information
gogogarrett committed Sep 22, 2011
1 parent 8af0bfc commit fda84f3
Show file tree
Hide file tree
Showing 10 changed files with 468 additions and 50 deletions.
32 changes: 32 additions & 0 deletions authentication/features/support/factories.rb.orig
@@ -0,0 +1,32 @@
require 'factory_girl'

FactoryGirl.define do
factory :user do |u|
u.sequence(:username) { |n| "person#{n}" }
u.sequence(:email) { |n| "person#{n}@cucumber.com" }
u.password "greenandjuicy"
u.password_confirmation "greenandjuicy"
end
end

FactoryGirl.define do
factory :refinery_user, :parent => :user do |u|
u.roles { [ Role[:refinery] ] }

u.after_create do |user|
Refinery::Plugins.registered.each_with_index do |plugin, index|
user.plugins.create(:name => plugin.name, :position => index)
end
end
end
end

FactoryGirl.define do
factory :refinery_translator, :parent => :user do |u|
u.roles { [ Role[:refinery], Role[:translator] ] }

u.after_create do |user|
user.plugins.create(:name => 'refinery_pages', :position => 0)
end
end
end
20 changes: 20 additions & 0 deletions core/app/views/shared/_head.html.erb.orig
@@ -0,0 +1,20 @@
<head>
<meta charset='<%= ::Refinery::Application.config.encoding %>' />
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
<title><%= browser_title(yield(:title)) %></title>
<%= raw "<meta name=\"description\" content=\"#{@meta.meta_description}\" />" if @meta.meta_description.present? -%>
<%= raw "<meta name=\"keywords\" content=\"#{@meta.meta_keywords}\">" if @meta.meta_keywords.present? -%>
<%= csrf_meta_tag if RefinerySetting.find_or_set(:authenticity_token_on_frontend, true)-%>
<%= yield :meta %>

<%= stylesheet_link_tag stylesheets_for_head(stylesheets||=%w(application formatting theme), theme ||= nil),
:cache => ("cache/application" if Rails.root.writable? and
RefinerySetting.find_or_set(:use_resource_caching, true) and
request.env['HTTP_USER_AGENT'] !~ /MSIE/ and (theme ||= nil).blank?) %>
<%= stylesheet_link_tag "home", :theme => theme if home_page? %>

<%= yield :stylesheets %>
<%= render :partial => '/shared/google_analytics' unless local_request? %>

<%= javascript_include_tag 'modernizr-min' %>
</head>
66 changes: 66 additions & 0 deletions db/seeds/pages.rb.orig
@@ -0,0 +1,66 @@
<<<<<<< HEAD
module Refinery
::Refinery::Page.reset_column_information
=======
::Page.reset_column_information
# Check whether all columns are applied yet by seo_meta.
unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k|
::Page.translation_class.instance_methods.map(&:to_sym).include?(k)
}
# Make pages model seo_meta because not all columns are accessible.
::Page.translation_class.send :is_seo_meta
end
>>>>>>> 0356e8fd5863a4f5919fbba776cb0ad0df01236e

page_position = -1

unless ::Refinery::Page.where(:menu_match => "^/$").any?
home_page = ::Refinery::Page.create!({:title => "Home",
:deletable => false,
:link_url => "/",
:menu_match => "^/$",
:position => (page_position += 1)})
home_page.parts.create({
:title => "Body",
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
:position => 0
})
home_page.parts.create({
:title => "Side Body",
:body => "<p>This is another block of content over here.</p>",
:position => 1
})

home_page_position = -1
page_not_found_page = home_page.children.create(:title => "Page not found",
:menu_match => "^/404$",
:show_in_menu => false,
:deletable => false,
:position => (home_page_position += 1))
page_not_found_page.parts.create({
:title => "Body",
:body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
:position => 0
})
else
page_position += 1
end

unless ::Refinery::Page.by_title("About").any?
about_us_page = ::Refinery::Page.create(:title => "About",
:deletable => true,
:position => (page_position += 1))
about_us_page.parts.create({
:title => "Body",
:body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
:position => 0
})
about_us_page.parts.create({
:title => "Side Body",
:body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
:position => 1
})
else
page_position += 1
end
end
@@ -0,0 +1,40 @@
h2. How to add custom JavaScript files

Refinery by default will provide you with the required javascript files you need. Sometimes you want to provide your own files and this guide will show you how to:

*Add your own files to be included on a per page basis.

endprologue.

h3. Including your own JavasScript files

If you want to include your own javascript files you just have to include this in your home.html.erb:

<shell>
<% content_for :javascripts do %>
<% javascript_include_tag('jquery.cycle.all.js', 'jquery.super_awesome.plugin.js', 'moreAwesome.js') %>
<% end %>
</shell>

This will add the javascript files that you specified to your home page.
If you want to add different files for your other pages, you can override that view and pass in the files you need.

h3. Different ways to change files
Refinery provides you with four unique ways of adding JavaScript files.

<shell>
<% content_for :before_javascript_libraries, javascript_include_tag('init.js') %>
<% content_for :javascript_libraries, jquery_include_tags(:jquery_ui => false) %>
<% content_for :after_javascript_libraries, javascript_include_tag('jquery.cycle.all.js') %>
<% content_for :javascripts do %>
<% javascript_include_tag('jquery.cycle.all.js', 'jquery.super_awesome.plugin.js', 'more.js') %>
<% end %>
</shell>

What they do:
*<tt>before_javascript_libraries</tt> will include a file before any libraries have been loaded.
*<tt>javascript_libraries</tt> provides you options of being able to specify your own javascript libraries
*<tt>after_javascript_libraries</tt> will load any files you wish to include directly below your libraries
*<tt>javascripts</tt> will load all the files you wish to include on your page

TIP. You can change the files that are loaded on a per page basis by simply overriding the corresponding views to include only what you need.

This file was deleted.

7 changes: 7 additions & 0 deletions images/features/support/factories.rb.orig
@@ -0,0 +1,7 @@
require 'factory_girl'

FactoryGirl.define do
factory :image do |i|
i.image File.new(File.expand_path('../../uploads/beach.jpeg', __FILE__))
end
end
66 changes: 66 additions & 0 deletions pages/db/seeds/pages.rb.orig
@@ -0,0 +1,66 @@
<<<<<<< HEAD
module Refinery
::Refinery::Page.reset_column_information
=======
::Page.reset_column_information
# Check whether all columns are applied yet by seo_meta.
unless !defined?(::SeoMeta) || ::SeoMeta.attributes.keys.all? { |k|
::Page.translation_class.instance_methods.map(&:to_sym).include?(k)
}
# Make pages model seo_meta because not all columns are accessible.
::Page.translation_class.send :is_seo_meta
end
>>>>>>> 0356e8fd5863a4f5919fbba776cb0ad0df01236e

page_position = -1

unless ::Refinery::Page.where(:menu_match => "^/$").any?
home_page = ::Refinery::Page.create!({:title => "Home",
:deletable => false,
:link_url => "/",
:menu_match => "^/$",
:position => (page_position += 1)})
home_page.parts.create({
:title => "Body",
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
:position => 0
})
home_page.parts.create({
:title => "Side Body",
:body => "<p>This is another block of content over here.</p>",
:position => 1
})

home_page_position = -1
page_not_found_page = home_page.children.create(:title => "Page not found",
:menu_match => "^/404$",
:show_in_menu => false,
:deletable => false,
:position => (home_page_position += 1))
page_not_found_page.parts.create({
:title => "Body",
:body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
:position => 0
})
else
page_position += 1
end

unless ::Refinery::Page.by_title("About").any?
about_us_page = ::Refinery::Page.create(:title => "About",
:deletable => true,
:position => (page_position += 1))
about_us_page.parts.create({
:title => "Body",
:body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
:position => 0
})
about_us_page.parts.create({
:title => "Side Body",
:body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
:position => 1
})
else
page_position += 1
end
end
@@ -0,0 +1,23 @@
<li class='clearfix record <%= cycle("on", "on-hover") %>'>
<span class='title'>
<%= t(refinery_setting.name, :scope => 'admin.refinery_settings.form.title', :default => refinery_setting.title) %>
<span class="preview">- <%= truncate(refinery_setting.value.to_s, :length => 40) %></span>
</span>
<span class='actions'>
<%= link_to refinery_icon_tag('application_edit.png'),
edit_admin_refinery_setting_path(refinery_setting, :dialog => true, :width => 725, :height => 525),
:title => t('edit', :scope => 'admin.refinery_settings') %>
<%= link_to refinery_icon_tag('delete.png'),
admin_refinery_setting_path(refinery_setting),
:class => 'cancel confirm-delete',
:title => t('delete', :scope => 'admin.refinery_settings'),
:confirm => t('message', :scope => 'shared.admin.delete', :title => refinery_setting.title),
:method => :delete if refinery_setting.destroyable %>

<% unless (help = t(refinery_setting.name, :scope => 'admin.refinery_settings.form.help', :default => '')).blank? %>
<%= link_to refinery_icon_tag('information.png'), '#',
:tooltip => help,
:class => 'information suppress' %>
<% end %>
</span>
</li>

0 comments on commit fda84f3

Please sign in to comment.