diff --git a/Gemfile b/Gemfile index 649a6c810..c47d44260 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,6 @@ gem 'rails', '3.0.3' gem 'bson_ext' gem 'carrierwave' gem 'devise' -gem 'liquid' gem 'mini_magick' gem 'mongoid', '2.0.0.rc.6' diff --git a/Gemfile.lock b/Gemfile.lock index 2b2470f6e..468e7db20 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -41,7 +41,6 @@ GEM erubis (2.6.6) abstract (>= 1.0.0) i18n (0.5.0) - liquid (2.2.2) mail (2.2.15) activesupport (>= 2.3.6) i18n (>= 0.4.0) @@ -93,7 +92,6 @@ DEPENDENCIES bson_ext carrierwave devise - liquid mini_magick mongoid (= 2.0.0.rc.6) rails (= 3.0.3) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d3246e9a9..393adec4d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,14 +36,41 @@ class ApplicationController < ActionController::Base redirect_to root_url unless current_user.admin? end - # Parse and render the pages with liquid - def render_liquid_page + # Parse and render the pages with Radius + def render_page if @page @layout = @page.layout - @page_options ||= {} - @page_content = Liquid::Template.parse( @page.content ).render(@page_options) - @layout_content = (@page.layout)? @layout.content : "{{page_content}}" - render :text => Liquid::Template.parse(@layout_content).render( 'page_content' => @page_content ) + @page_content = @page.content + @layout_content = (@page.layout)? @layout.content : "" + + + context = Radius::Context.new do |c| + c.define_tag 'content' do |tag| + @page_content + end + c.define_tag 'snippet' do |tag| + snippet = Snippet.first(:conditions => {:name => tag.attr['name']}) + if snippet + snippet.content + else + t('nothing') + end + end + c.define_tag 'language_bar' do + @site_in_use_locales.map{ |locale| + lang = I18nVariable.first(:conditions => {:key => locale})[locale] + if I18n.locale.to_s.eql?(locale) + lang + else + "#{lang}" + end + }.join(' | ') + end + end + + parser = Radius::Parser.new(context, :tag_prefix => 'r') + + render :text => parser.parse(@layout_content) else render :text => '404 Not Found' end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 8f68e216a..19c69d389 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -3,7 +3,7 @@ class PagesController < ApplicationController def index @page = Home.find_by_name('home') if @page - render_liquid_page + render_page else render :text => 'You need a home page' end @@ -15,7 +15,7 @@ class PagesController < ApplicationController case item._type when 'Page' @page = item - render_liquid_page + render_page when 'Link' redirect_to "http://#{item[:url]}" end diff --git a/app/models/i18n_liquid.rb b/app/models/i18n_liquid.rb deleted file mode 100644 index 10a911786..000000000 --- a/app/models/i18n_liquid.rb +++ /dev/null @@ -1,13 +0,0 @@ -class I18nLiquid < Liquid::Tag - - def initialize(tag_name, value, tokens) - super - @value = value.to_s - end - - def render(context) - I18nVariable.first(:conditions => {:key => @value})[I18n.locale] rescue '' - end -end - -Liquid::Template.register_tag('t', I18nLiquid) diff --git a/app/models/snippet_filter.rb b/app/models/snippet_filter.rb deleted file mode 100644 index e085e7c4c..000000000 --- a/app/models/snippet_filter.rb +++ /dev/null @@ -1,27 +0,0 @@ -module SnippetFilter - - def render_snippet(snippet_name) - - snippet = Snippet.first(:conditions => {:name => snippet_name}) - - if snippet - return Liquid::Template.parse( snippet.content ).render - else - return t('nothing') - end - - end - - def ruling_snippet(snippet_name) - case snippet_name - when 'language_bar' - site = Site.first - @site_in_use_locales = site.in_use_locales - @site_valid_locales = site.valid_locales - end - return Liquid::Template.parse( eval(File.open("#{RAILS_ROOT}/lib/snippets/#{snippet_name}.snippet").read) ).render - end - -end - -Liquid::Template.register_filter(SnippetFilter) diff --git a/lib/snippets/language_bar.snippet b/lib/snippets/language_bar.snippet deleted file mode 100644 index c4161352c..000000000 --- a/lib/snippets/language_bar.snippet +++ /dev/null @@ -1,8 +0,0 @@ -@site_in_use_locales.map{ |locale| - lang = I18nVariable.first(:conditions => {:key => locale})[locale] - if I18n.locale.to_s.eql?(locale) - lang - else - "#{lang}" - end -}.join(' | ') diff --git a/vendor/plugins/radius b/vendor/plugins/radius new file mode 160000 index 000000000..d312e3195 --- /dev/null +++ b/vendor/plugins/radius @@ -0,0 +1 @@ +Subproject commit d312e31954c3dfa5711b06267d79b9ea11c5f059