Skip to content

Commit

Permalink
Merge branch 'next_stable' of github.com:magiclabs/alchemy_cms into n…
Browse files Browse the repository at this point in the history
…ext_stable

Conflicts:
	lib/rails/generators/alchemy/plugin/templates/config.yml
  • Loading branch information
robinboening committed Nov 1, 2011
2 parents 9ef37be + f1d23e7 commit 235f497
Show file tree
Hide file tree
Showing 177 changed files with 2,237 additions and 1,842 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
.yardoc
.DS_Store
.svn
Expand All @@ -9,4 +10,7 @@ pkg
/spec/dummy/log/test.log
/spec/dummy/db/test.sqlite3
/spec/dummy/db/development.sqlite3
tmp
tmp
spec/dummy/index/
log
spec/dummy/uploads/
3 changes: 1 addition & 2 deletions .rspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
--color
--format documentation
--debug
--format progress
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
rvm:
- 1.8.7
- 1.9.2
branches:
only:
- next_stable
before_script:
- "mysql -e 'create database alchemy_cms_test;'"
#- "mysql -e 'create database alchemy_cms_test;'"
- "sh -c 'cd spec/dummy && RAILS_ENV=test bundle exec rake db:schema:load'"
script: "bundle exec rspec spec"
# env:
Expand Down
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ group :development, :test do
end

group :test do
gem 'mysql2', '< 0.3'
gem 'factory_girl_rails'
gem "capybara", ">= 0.4.0"
gem "launchy"
Expand Down
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ Features
Rails Version
-------------

This branch of Alchemy runs with Rails 3.0.9 and Ruby 1.8.7. __Ruby 1.9 is not__ offically supported yet, because not all Gems Alchemy depends on are Ruby 1.9 ready.
This branch of Alchemy runs with Rails 3.0.10, Ruby 1.8.7 and Ruby 1.9.2.

Installation
------------

Use the installer (recommended):

gem install alchemy_cms --pre
alchemy new my_magicpage

Start the local server:
Expand All @@ -76,6 +77,17 @@ Start the local server:

Then just switch to your browser and open `http://localhost:3000`.

Add to existing Rails project:

add gem 'alchemy_cms' to Gemfile

bundle install
rake alchemy:prepare
rake alchemy:standard_set:install (optional)
rake db:migrate
rake db:seed


Tipps
-----

Expand Down
18 changes: 11 additions & 7 deletions alchemy_cms.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ Gem::Specification.new do |s|
s.description = %q{Alchemy is an awesome Rails CMS with an extremely flexible content storing architecture.}
s.requirements << 'ImageMagick (libmagick), v6.6 or greater.'
s.license = 'GPL-3'

s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]

s.add_runtime_dependency(%q<rails>, ["~> 3.0"])
s.add_runtime_dependency(%q<authlogic>, ["~> 3.0"])
s.add_runtime_dependency(%q<awesome_nested_set>, ["~> 2.0"])
Expand All @@ -32,11 +32,15 @@ Gem::Specification.new do |s|
s.add_runtime_dependency(%q<dynamic_form>, ["~> 1.1"])
s.add_runtime_dependency(%q<jquery-rails>, ["~> 1.0"])
s.add_runtime_dependency(%q<tinymce_hammer>, ["~> 0.2"])
s.add_runtime_dependency(%q<attachment_magic>, ["~> 0.1"])

s.add_development_dependency(%q<capybara>, [">= 0.4.0"])
s.add_development_dependency(%q<rspec-rails>, [">= 2.0.0.beta"])
s.add_runtime_dependency(%q<attachment_magic>, ["~> 0.1.1"])

s.add_development_dependency(%q<rspec-rails>, [">= 2.0"])
s.add_development_dependency(%q<sqlite3>)
s.add_development_dependency(%q<ruby-debug>)

if RUBY_VERSION =~ /^1.9/
s.add_development_dependency(%q<ruby-debug19>)
else
s.add_development_dependency(%q<ruby-debug>)
end

end
3 changes: 2 additions & 1 deletion app/controllers/admin/contents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Admin::ContentsController < AlchemyController

filter_access_to :all
helper :contents

def new
@element = Element.find(params[:element_id])
Expand Down Expand Up @@ -32,7 +33,7 @@ def create

def update
content = Content.find(params[:id])
content.content.update_attributes(params[:content])
content.essence.update_attributes(params[:content])
render :update do |page|
page << "Alchemy.closeCurrentWindow();Alchemy.reloadPreview()"
end
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin/essence_pictures_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class Admin::EssencePicturesController < AlchemyController

filter_access_to :all
helper :contents

def edit
@essence_picture = EssencePicture.find(params[:id])
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/admin/trash_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ class Admin::TrashController < AlchemyController

before_filter :set_translation

helper Admin::ElementsHelper

def index
@elements = Element.trashed
@page = Page.find_by_id(params[:page_id])
@allowed_elements = Element.all_for_page(@page)
render :layout => false
rescue Exception => e
exception_handler(e)
end

def clear
Expand Down
20 changes: 13 additions & 7 deletions app/controllers/alchemy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,32 @@ class AlchemyController < ApplicationController
before_filter :set_language
before_filter :mailer_set_url_options

helper_method :current_server, :configuration, :multi_language?, :current_user, :clipboard_empty?, :trash_empty?, :get_clipboard
helper_method :current_server, :configuration, :multi_language?, :current_user, :clipboard_empty?, :trash_empty?, :get_clipboard, :is_admin?
helper :layout

def render_errors_or_redirect(object, redicrect_url, flash_notice, button = nil)

# Returns true if the current_user (The logged-in Alchemy User) has the admin role.
def is_admin?
return false if !current_user
current_user.admin?
end

def render_errors_or_redirect(object, redirect_url, flash_notice, button = nil)
if object.errors.empty?
flash[:notice] = _(flash_notice)
render(:update) { |page| page.redirect_to(redicrect_url) }
render(:update) { |page| page.redirect_to(redirect_url) }
else
render_remote_errors(object, button)
end
end

def render_remote_errors(object, button = nil)
render :update do |page|
page << "jQuery('#errors').html('<ul>" + object.errors.sum { |a, b| "<li>" + _(b) + "</li>" } + "</ul>')"
page << "jQuery('#errors').show()"
page << "Alchemy.enableButton('#{button}')" unless button.blank?
page << "Alchemy.enableButton('#{button || 'form button.button'}')"
end
end

# Returns a host string with the domain the app is running on.
def current_server
# For local development server
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/elements_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ class ElementsController < AlchemyController

filter_access_to [:show], :attribute_check => true
layout false

# Returns the element partial as HTML or as JavaScript that tries to replace a given +container_id+ with the partial content via jQuery.
def show
@element = Element.find(params[:id])
Expand Down
46 changes: 23 additions & 23 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ class PagesController < AlchemyController
caches_action(
:show,
:layout => false,
:cache_path => Proc.new { |c| c.multi_language? ? "#{session[:language_code]}/#{c.params[:urlname]}" : "#{c.params[:urlname]}" },
:if => Proc.new { |c|
:cache_path => proc { url_for(:action => :show, :urlname => params[:urlname], :lang => multi_language? ? params[:lang] : nil) },
:if => proc do
if Alchemy::Config.get(:cache_pages)
page = Page.find_by_urlname_and_language_id_and_public(
c.params[:urlname],
params[:urlname],
session[:language_id],
true,
:select => 'page_layout, language_id, urlname'
Expand All @@ -24,7 +24,7 @@ class PagesController < AlchemyController
else
false
end
}
end
)

# Showing page from params[:urlname]
Expand Down Expand Up @@ -64,13 +64,15 @@ def get_page_from_urlname
elsif @page.blank?
render(:file => "#{Rails.root}/public/404.html", :status => 404, :layout => false)
elsif multi_language? && params[:lang].blank?
redirect_to show_page_path(:urlname => @page.urlname, :lang => session[:language_code]), :status => 301
elsif multi_language? && params[:urlname].blank? && !params[:lang].blank?
redirect_to show_page_path(:urlname => @page.urlname, :lang => params[:lang]), :status => 301
redirect_page(:lang => session[:language_code])
elsif multi_language? && params[:urlname].blank? && !params[:lang].blank? && configuration(:redirect_index)
redirect_page(:lang => params[:lang])
elsif configuration(:redirect_to_public_child) && !@page.public?
redirect_to_public_child
elsif params[:urlname].blank? && configuration(:redirect_index)
redirect_page
elsif !multi_language? && !params[:lang].blank?
redirect_to show_page_path(:urlname => @page.urlname), :status => 301
redirect_page
elsif @page.has_controller?
redirect_to(@page.controller_and_action)
else
Expand All @@ -86,14 +88,14 @@ def get_page_from_urlname

def perform_search
@rtf_search_results = EssenceRichtext.find_with_ferret(
"*" + params[:query] + "*",
"*#{params[:query]}*",
{:limit => :all},
{:conditions => "public = 1"}
{:conditions => ["public = ?", true]}
)
@text_search_results = EssenceText.find_with_ferret(
"*" + params[:query] + "*",
"*#{params[:query]}*",
{:limit => :all},
{:conditions => "public = 1"}
{:conditions => ["public = ?", true]}
)
end

Expand All @@ -119,19 +121,17 @@ def redirect_to_public_child
end
end

def redirect_page
get_additional_params
redirect_to(
send(:show_page_path, {
:lang => (multi_language? ? @page.language_code : nil),
:urlname => @page.urlname
}.merge(@additional_params)),
:status => 301
)
def redirect_page(options={})
defaults = {
:lang => (multi_language? ? @page.language_code : nil),
:urlname => @page.urlname
}
options = defaults.merge(options)
redirect_to show_page_path(options.merge(additional_params)), :status => 301
end

def get_additional_params
@additional_params = params.clone.delete_if do |key, value|
def additional_params
params.clone.delete_if do |key, value|
["action", "controller", "urlname", "lang"].include?(key)
end
end
Expand Down
33 changes: 32 additions & 1 deletion app/helpers/admin/elements_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Admin::ElementsHelper

include ::ElementsHelper

# Returns an Array for essence_text_editor select options_for_select.
def elements_by_name_for_select(name, options={})
defaults = {
Expand All @@ -24,5 +26,34 @@ def elements_by_name_for_select(name, options={})
end
return elements_for_options
end


# Renders the element editor partial
def render_editor(element)
render_element(element, :editor)
end

# This helper renderes the picture editor for the elements on the Alchemy Desktop.
# It brings full functionality for adding images to the element, deleting images from it and sorting them via drag'n'drop.
# Just place this helper inside your element editor view, pass the element as parameter and that's it.
#
# Options:
# :maximum_amount_of_images (integer), default nil. This option let you handle the amount of images your customer can add to this element.
def render_picture_editor(element, options={})
default_options = {
:last_image_deletable => true,
:maximum_amount_of_images => nil,
:refresh_sortable => true
}
options = default_options.merge(options)
picture_contents = element.all_contents_by_type("EssencePicture")
render(
:partial => "admin/elements/picture_editor",
:locals => {
:picture_contents => picture_contents,
:element => element,
:options => options
}
)
end

end
Loading

0 comments on commit 235f497

Please sign in to comment.