From 96e4753ed670b74ccf91abd8b43dbdbba4034b8c Mon Sep 17 00:00:00 2001 From: dinedine Date: Tue, 6 Jul 2010 17:00:02 +0200 Subject: [PATCH] specify MIT license + textile filter + fix bug with new tree plugin + fix tests --- Gemfile | 3 +- LICENSE | 21 ++++++++++++++ README.textile | 26 ++++++++++++++++-- app/helpers/admin/base_helper.rb | 2 +- app/models/extensions/page/tree.rb | 6 ++-- app/models/layout.rb | 5 ++-- app/views/admin/shared/_footer.html.haml | 7 ++--- config/locales/admin_ui_fr.yml | 5 ++-- doc/TODO | 6 ++-- lib/locomotive/liquid/filters/text.rb | 16 +++++++++++ lib/locomotive/regexps.rb | 2 +- public/images/admin/nocoffee.png | Bin 0 -> 496 bytes public/stylesheets/admin/layout.css | 22 +++++++++------ spec/factories.rb | 2 +- .../locomotive/liquid/filters/text_spec.rb | 11 ++++++++ spec/models/layout_spec.rb | 4 +-- spec/models/page_spec.rb | 2 +- 17 files changed, 105 insertions(+), 35 deletions(-) create mode 100644 LICENSE create mode 100644 lib/locomotive/liquid/filters/text.rb create mode 100644 public/images/admin/nocoffee.png create mode 100644 spec/lib/locomotive/liquid/filters/text_spec.rb diff --git a/Gemfile b/Gemfile index 6917ceca1e..8444eea9ae 100644 --- a/Gemfile +++ b/Gemfile @@ -8,7 +8,7 @@ gem 'liquid' gem 'bson_ext', '>= 1.0.1' gem 'mongo_ext' gem 'mongoid', '2.0.0.beta6' -gem 'mongoid_acts_as_tree', '>= 0.1.2' +gem 'mongoid_acts_as_tree', '0.1.5' gem 'mongo_session_store', '2.0.0.pre' gem 'warden' gem 'devise', '1.1.rc1' @@ -22,6 +22,7 @@ gem 'carrierwave-rails3', :require => 'carrierwave' gem 'actionmailer-with-request', :require => 'actionmailer_with_request' gem 'heroku' gem 'httparty', '0.6.0' +gem 'RedCloth' # Development environment group :development do diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..94e7d78c23 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +== MIT License + +Copyright (c) 2010, Didier Lafforgue. + +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. \ No newline at end of file diff --git a/README.textile b/README.textile index aebb18b6f0..6bd8e39100 100644 --- a/README.textile +++ b/README.textile @@ -1,20 +1,40 @@ h1. Locomotive CMS -Locomotive is a simple but powerful CMS based on liquid templates and mongodb database. If we have to give only 4 main features to describe our application, there will be: +Locomotive is a simple but powerful CMS based on liquid templates and mongodb database. At my company ("NoCoffee":http://www.nocoffee.fr), we use it for our clients when they request a simple website. + +If we have to give only 5 main features to describe our application, there will be: * managing as many websites as you want with one application instance * nice looking UI (see http://www.locomotiveapp.org for some screenshots) * flexible content types -* inline editing +* playing smoothly with Heroku and MongoHQ +* inline editing (coming soon) h2. Strategy / Development status We already developed a fully functional prototype in Rails 2.3.2 with both active record / mongomapper and it worked quite well. We are even using it for some client websites. Now, our goal is to port our prototype to Rails 3 and migrate from mongomapper to mongoid. Besides, we put a lot of efforts to make it as robust as we can by writing better specs than we wrote for the prototype at first. +h2. Gems + +Here is a short list of main gems used in the application. + +* Rails 3 (beta 3) +* Mongoid +* Liquid +* Devise +* Carrierwave +* Haml + h2. Installation -TODO +See the "official website":http://www.locomotiveapp.org + +h2. Credits + +Many thanks to "Sacha Greif":http://www.sachagreif.com for his great work on the user interface and the LocomotiveApp website front page. + +"Rodrigo Alvarez":http://blog.codecaster.es/ for his plugin named Congo which gave us a good starting point and for his availability for (very late) tech discussions. h2. Contact diff --git a/app/helpers/admin/base_helper.rb b/app/helpers/admin/base_helper.rb index 54fa75793d..52a7435c9d 100644 --- a/app/helpers/admin/base_helper.rb +++ b/app/helpers/admin/base_helper.rb @@ -48,7 +48,7 @@ def growl_message end def nocoffee_tag - link_to content_tag(:em, 'no') + 'Coffee', 'http://www.nocoffee.fr', :id => 'nocoffee' + link_to 'noCoffee', 'http://www.nocoffee.fr', :id => 'nocoffee' end end \ No newline at end of file diff --git a/app/models/extensions/page/tree.rb b/app/models/extensions/page/tree.rb index 883cf0114e..5aade096d9 100644 --- a/app/models/extensions/page/tree.rb +++ b/app/models/extensions/page/tree.rb @@ -16,7 +16,7 @@ module Tree ## callbacks ## before_validate :reset_parent - before_save { |p| p.parent_id = nil if p.parent_id.blank? } + before_save { |p| p.send(:write_attribute, :parent_id, nil) if p.parent_id.blank? } before_save :change_parent before_create { |p| p.send(:fix_position, false) } before_create :add_to_list_bottom @@ -60,11 +60,11 @@ def change_parent def hacked_fix_position(perform_save = true) if parent.nil? - self[parent_id_field] = nil + self.write_attribute parent_id_field, nil self[path_field] = [] self[depth_field] = 0 else - self[parent_id_field] = parent._id + self.write_attribute parent_id_field, parent._id self[path_field] = parent[path_field] + [parent._id] self[depth_field] = parent[depth_field] + 1 self.save if perform_save diff --git a/app/models/layout.rb b/app/models/layout.rb index 5c5d492ea5..9a68d7e820 100644 --- a/app/models/layout.rb +++ b/app/models/layout.rb @@ -21,9 +21,8 @@ def build_parts_from_value self.value.scan(Locomotive::Regexps::CONTENT_FOR).each do |attributes| slug = attributes[0].strip.downcase - name = attributes[1].strip.gsub("\"", '') - name = nil if name.empty? - name ||= I18n.t('attributes.defaults.page_parts.name') if slug == 'layout' + name = slug.humanize + name = I18n.t('attributes.defaults.page_parts.name') if slug == 'layout' if part = self.parts.detect { |p| p.slug == slug } part.name = name if name.present? diff --git a/app/views/admin/shared/_footer.html.haml b/app/views/admin/shared/_footer.html.haml index 8cd482d358..859c6d13de 100644 --- a/app/views/admin/shared/_footer.html.haml +++ b/app/views/admin/shared/_footer.html.haml @@ -1,5 +1,2 @@ -%p.tright - = t('.developed_by') - = nocoffee_tag - = t('.powered_by') - = link_to 'Ruby on Rails', 'http://www.rubyonrails.com', :id => 'powered-by' \ No newline at end of file +%p.tcenter + = t('.who_is_behind', :development => nocoffee_tag) diff --git a/config/locales/admin_ui_fr.yml b/config/locales/admin_ui_fr.yml index 5bb16f0c5a..f411312c3a 100644 --- a/config/locales/admin_ui_fr.yml +++ b/config/locales/admin_ui_fr.yml @@ -47,8 +47,7 @@ fr: site: Site theme_assets: Fichiers Thème footer: - developed_by: Service développé par - powered_by: et propulsé par + who_is_behind: "Service développé par {{development}} et désigné par Sacha Greif" form_actions: back: Retour sans sauvegarder create: Créer @@ -301,7 +300,7 @@ fr: contents: index: - title: 'Liste "{{type}}"' + title: 'Liste des "{{type}}"' edit: éditer modèle destroy: supprimer modèle download: télécharger éléments diff --git a/doc/TODO b/doc/TODO index b50a686ca7..eba2d891e6 100644 --- a/doc/TODO +++ b/doc/TODO @@ -3,7 +3,6 @@ BOARD: - refactoring admin crud (pages + layouts + snippets) - refactor slugify method (use parameterize + create a module) -- change credits in the admin footer - change action icons according to the right action [Sacha] BACKLOG: @@ -51,4 +50,7 @@ x localize application in French x devise x carrierwave x localize devise emails - x admin \ No newline at end of file + x admin +x change credits in the admin footer +x license +x textile filter \ No newline at end of file diff --git a/lib/locomotive/liquid/filters/text.rb b/lib/locomotive/liquid/filters/text.rb new file mode 100644 index 0000000000..235509c970 --- /dev/null +++ b/lib/locomotive/liquid/filters/text.rb @@ -0,0 +1,16 @@ +module Locomotive + module Liquid + module Filters + module Text + + def textile(input) + RedCloth.new(input).to_html + end + + end + + ::Liquid::Template.register_filter(Text) + + end + end +end \ No newline at end of file diff --git a/lib/locomotive/regexps.rb b/lib/locomotive/regexps.rb index 0dd3ebfe66..80caff654d 100644 --- a/lib/locomotive/regexps.rb +++ b/lib/locomotive/regexps.rb @@ -7,7 +7,7 @@ module Regexps CONTENT_FOR = /\{\{\s*content_for_([a-zA-Z]{1}[a-zA-Z_0-9]*)(\s+.*)?\s*\}\}/ - CONTENT_FOR_LAYOUT = /\{\{\s*content_for_layout\s*\}\}/ + CONTENT_FOR_LAYOUT = /\{\{\s*content_for_layout\s*/ end end \ No newline at end of file diff --git a/public/images/admin/nocoffee.png b/public/images/admin/nocoffee.png new file mode 100644 index 0000000000000000000000000000000000000000..5612223f07a6c178706c3a57797a76077e833180 GIT binary patch literal 496 zcmVTra-7{ufD*3ys ztIqkls?L$Mvr#10M$JR{U$c8N-7O({+Q(5)2Fn0Vwu%@&+o{zOAPxg}*B04~g&4uz>k-nKBY095 zCnZ@F`^ye8OAV9&o+xq|Ap30Lu};H3I;C^R2%{YLn7D{oo79ejjNpg8y~J%x84Lu4 zcjSV581YMq4N~S^e{LqNKOy-jnO#MHYL%6|mj)VAo%DD4dF5A3sBE4u)d3Pk1mCrx zRz!!2KT?Sd{;;NIq>aIcR&lfns+vFrE59II`q9v6rt4E?M=k!hm~lYbx@)Hr6i^G{ zryhDWxbbVH%SJjBkLCMrIG5fMy website - +
\{\{ content_for_layout \}\}
} diff --git a/spec/lib/locomotive/liquid/filters/text_spec.rb b/spec/lib/locomotive/liquid/filters/text_spec.rb new file mode 100644 index 0000000000..059d6fcdda --- /dev/null +++ b/spec/lib/locomotive/liquid/filters/text_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Locomotive::Liquid::Filters::Text do + + include Locomotive::Liquid::Filters::Text + + it 'transforms a textile input into HTML' do + textile('This is *my* text.').should == "

This is my text.

" + end + +end \ No newline at end of file diff --git a/spec/models/layout_spec.rb b/spec/models/layout_spec.rb index 9f25ec2158..379e21e59a 100644 --- a/spec/models/layout_spec.rb +++ b/spec/models/layout_spec.rb @@ -27,8 +27,8 @@ @layout.parts.first.name.should == 'Body' @layout.parts.first.slug.should == 'layout' - @layout.parts.last.name.should == 'Left Sidebar' - @layout.parts.last.slug.should == 'sidebar' + @layout.parts.last.name.should == 'Left sidebar' + @layout.parts.last.slug.should == 'left_sidebar' end it 'should not add parts to pages if layout does not change' do diff --git a/spec/models/page_spec.rb b/spec/models/page_spec.rb index c2c8800504..6b426a1084 100644 --- a/spec/models/page_spec.rb +++ b/spec/models/page_spec.rb @@ -293,7 +293,7 @@ before(:each) do @page = Factory.build(:page, :site => nil) @page.parts.build :slug => 'layout', :value => 'Hello world !' - @page.parts.build :slug => 'sidebar', :value => 'A sidebar...' + @page.parts.build :slug => 'left_sidebar', :value => 'A sidebar...' @page.send(:store_template) @layout = Factory.build(:layout, :site => nil) @layout.send(:store_template)