lolita 3.0.3 → 3.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,24 +1,24 @@
1
- source "http://rubygems.org"
2
-
3
- # Thing how to seperate gems for Rails Enginge from those that are only for lolita
4
- gem "rails", "~>3.0"
5
- gem "will_paginate", "~> 3.0.pre2"
6
- gem "abstract"
7
-
8
- group :mongoid do
9
- gem "mongo"
10
- gem "mongoid", "~> 2.0.0.rc.7"
11
- gem "bson_ext"
12
- end
13
-
14
- #gem 'cover_me', '>= 1.0.0.rc6', :group => :test
15
- gem "jeweler", "~> 1.5.2", :group=>:development
16
- group :test,:development do
17
- gem "rspec", ">=2.2.0"
18
- gem "rspec-rails"
19
- gem "factory_girl"
20
- gem 'ffaker'
21
- # gem "rspec-cells"
22
- #gem "sqlite3-ruby"
23
- gem "ruby-debug19"
24
- end
1
+ source "http://rubygems.org"
2
+
3
+ # Thing how to seperate gems for Rails Enginge from those that are only for lolita
4
+ gem "rails", "~>3.0"
5
+ gem "will_paginate", "~> 3.0.pre2"
6
+ gem "abstract"
7
+
8
+ group :mongoid do
9
+ gem "mongo"
10
+ gem "mongoid", "~> 2.0.0.rc.7"
11
+ gem "bson_ext"
12
+ end
13
+
14
+ #gem 'cover_me', '>= 1.0.0.rc6', :group => :test
15
+ gem "jeweler", "~> 1.5.2", :group=>:development
16
+ group :test,:development do
17
+ gem "rspec", ">=2.2.0"
18
+ gem "rspec-rails"
19
+ gem "factory_girl"
20
+ gem 'ffaker'
21
+ # gem "rspec-cells"
22
+ #gem "sqlite3-ruby"
23
+ gem "ruby-debug19"
24
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.3
1
+ 3.0.4
@@ -51,16 +51,18 @@ class Lolita::RestController < ApplicationController
51
51
 
52
52
  def show_form
53
53
  build_response_for(:tabs)
54
- render :form
54
+ if request.xhr?
55
+ render :form, :layout => false
56
+ else
57
+ render :form
58
+ end
55
59
  end
56
60
 
57
61
  def save_and_redirect
58
62
  if self.resource.save
59
- unless self.resource.errors.empty?
60
- show_form
61
- else
62
- to_list
63
- end
63
+ show_form
64
+ else
65
+ show_form #to_list
64
66
  end
65
67
  end
66
68
 
@@ -1,2 +1,25 @@
1
- <%= text_area resource_name, field.name %>
1
+ <% content_for :script do %>
2
+ <%= javascript_include_tag "tinymce/jquery.tinymce" %>
3
+ <script>
4
+ function load_tinymce(){
5
+ $("textarea").tinymce({
6
+ script_url: "/javascripts/tinymce/tiny_mce.js",
7
+ theme: "advanced",
8
+ skin: "cirkuit",
9
+ mode: "textareas",
10
+ theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,formatselect,|,link,unlink,image",
11
+ theme_advanced_buttons2 : "",
12
+ theme_advanced_buttons3 : "",
13
+ theme_advanced_toolbar_location: "top",
14
+ theme_advanced_toolbar_align: "left",
15
+ // theme_advanced_statusbar_location : "bottom",
16
+ theme_advanced_resizing: true
17
+ });
18
+ }
19
+ $(function(){
20
+ load_tinymce();
21
+ })
22
+ </script>
23
+ <% end %>
2
24
 
25
+ <%= text_area resource_name, field.name %>
@@ -1,7 +1,9 @@
1
1
  <header>
2
2
  <h1>Lolita</h1>
3
- <nav>
4
- <a href="<%=send(:"edit_#{current_user.class.to_s.downcase}_password_path")%>" class="username"><%=current_user.email%></a>
5
- <a href="<%=send(:"destroy_#{current_user.class.to_s.downcase}_session_path")%>" class="button grey"><%=I18n.t("lolita.shared.log_out")%></a>
6
- </nav>
3
+ <% if lolita_current_user %>
4
+ <nav>
5
+ <a href="<%=send(:"edit_#{lolita_current_user.class.to_s.downcase}_password_path")%>" class="username"><%=lolita_current_user.email%></a>
6
+ <a href="<%=send(:"destroy_#{lolita_current_user.class.to_s.downcase}_session_path")%>" class="button grey"><%=I18n.t("lolita.shared.log_out")%></a>
7
+ </nav>
8
+ <% end %>
7
9
  </header>
@@ -1,32 +1,19 @@
1
1
  <% content_for :content_class do "with-secondary" end %>
2
2
 
3
- <% content_for :script do %>
4
- <%= javascript_include_tag "tinymce/jquery.tinymce" %>
5
- <script>
6
- $(function(){
7
- $("textarea").tinymce({
8
- script_url: "/javascripts/tinymce/tiny_mce.js",
9
- theme: "advanced",
10
- skin: "cirkuit",
11
- theme_advanced_buttons1 : "bold,italic,underline,|,justifyleft,justifycenter,justifyright,|,formatselect",
12
- theme_advanced_buttons2 : "",
13
- theme_advanced_buttons3 : "",
14
- theme_advanced_toolbar_location: "top",
15
- theme_advanced_toolbar_align: "left",
16
- // theme_advanced_statusbar_location : "bottom",
17
- theme_advanced_resizing: true
18
- });
19
- })
20
- </script>
21
- <% end %>
3
+ <%#= flash %>
22
4
 
23
- <div class="secondary">
5
+ <div class="secondary"> <%#= right sidebar %>
24
6
  <div class="box">
25
7
  <div class="boxtitle black">
26
- <h1><%= t "save" %></h1>
8
+ <h1><%= t "lolita.tabs.save" %></h1>
27
9
  <div class="arrow"></div>
28
10
  </div>
29
- <button class="save-all"><%=I18n.t("lolita.tabs.save_all")%></button>
11
+ <div class="save black">
12
+ <div class="last-save">
13
+ <%= resource.updated_at.strftime("#{t("lolita.tabs.last_save")}: %m/%d/%Y %H:%M ") if resource.updated_at %>
14
+ </div>
15
+ <button class="save-all"><%=I18n.t("lolita.tabs.save")%></button>
16
+ </div>
30
17
  </div>
31
18
  </div>
32
19
 
@@ -1,9 +1,11 @@
1
- en:
2
- lolita:
3
- shared:
4
- log_out: Log out
5
- tabs:
6
- save_all: Save all
7
- list:
8
- add_new: Add new %{name}
1
+ en:
2
+ lolita:
3
+ shared:
4
+ log_out: Log out
5
+ tabs:
6
+ last_save: Last saved
7
+ save: Save
8
+ save_all: Save all
9
+ list:
10
+ add_new: Add new %{name}
9
11
  confirm: Are you sure you want to delete record?
data/lib/lolita.rb CHANGED
@@ -4,6 +4,7 @@ $:<<File.dirname(__FILE__) unless $:.include?(File.dirname(__FILE__))
4
4
 
5
5
  require 'abstract' #FIXME remove from gem
6
6
  require 'active_support/core_ext/numeric/time'
7
+ require 'active_support/concern'
7
8
  require 'active_support/callbacks'
8
9
  require 'active_support/dependencies'
9
10
  require 'lolita/errors'
@@ -46,12 +47,18 @@ module Lolita
46
47
  autoload :Tab, 'lolita/configuration/tab'
47
48
  autoload :Tabs, 'lolita/configuration/tabs'
48
49
 
50
+ Dir["#{File.dirname(__FILE__)}/lolita/configuration/tab/**/*.*"].each do |path|
51
+ base_name=File.basename(path,".rb")
52
+ autoload :"#{base_name.capitalize}Tab", "lolita/configuration/tab/#{base_name}"
53
+ end
54
+
49
55
  module FieldExtensions
50
56
  Dir["#{File.dirname(__FILE__)}/lolita/configuration/field_extensions/**/*.*"].each do |path|
51
57
  base_name=File.basename(path,".rb")
52
58
  autoload base_name.capitalize.to_sym, "lolita/configuration/field_extensions/#{base_name}"
53
59
  end
54
60
  end
61
+
55
62
 
56
63
  def self.included(base)
57
64
  base.class_eval do
@@ -81,6 +88,7 @@ module Lolita
81
88
  autoload :UserHelpers, 'lolita/controllers/user_helpers'
82
89
  autoload :UrlHelpers, 'lolita/controllers/url_helpers'
83
90
  autoload :ComponentHelpers, 'lolita/controllers/component_helpers'
91
+ autoload :ViewUserHelpers, 'lolita/controllers/view_user_helpers'
84
92
  end
85
93
 
86
94
  @@scopes={}
@@ -122,4 +130,5 @@ if defined?(Rails)
122
130
  end
123
131
 
124
132
  puts "Lolita engine started in #{Time.at(Time.now-engine_time).strftime("%M:%S.%3N")}"
133
+
125
134
  puts "Lolita started in #{Time.at(Time.now-main_time).strftime("%M:%S.%3N")}"
@@ -60,7 +60,7 @@ module Lolita
60
60
  # Tabs should not be defined in lolita block to create onew or more Lolita::Configuration::Tab
61
61
  # See Lolita::Configuration::Tab for details of defination.
62
62
  def tab *args, &block
63
- self.tabs<<Lolita::Configuration::Tab.new(@dbi,*args,&block)
63
+ self.tabs<<Lolita::Configuration::Tab.add(@dbi,*args,&block)
64
64
  end
65
65
 
66
66
  # Call all supported instance metods to set needed variables and initialize object with them.
@@ -15,9 +15,29 @@ module Lolita
15
15
  # To define tab in ORM model, through lolita configuration do the following
16
16
  # ====Example
17
17
  # lolita do
18
- # tab
18
+ # tab(:files)
19
+ # end
19
20
  class Tab
20
21
 
22
+ class << self
23
+
24
+ def add(dbi,*args,&block)
25
+ type=args.first if args
26
+ unless type
27
+ temp_tab=self.new(dbi,*args,&block).type
28
+ type=temp_tab.type
29
+ end
30
+ unless type==:default
31
+ begin
32
+ "Lolita::Configuration::#{type.to_s.camelize}Tab".constantize.new(dbi,*args,&block)
33
+ rescue NameError
34
+ raise Lolita::TabNotFoundError, "Lolita::Configuration::#{type.to_s.camelize}Tab not found. Add it in /lolita/configuration/tab/#{type}.rb"
35
+ end
36
+ else
37
+ temp
38
+ end
39
+ end
40
+ end
21
41
  # For different types there are different builders(cells)
22
42
  @@available_types=[:content]
23
43
 
@@ -39,6 +59,7 @@ module Lolita
39
59
  validate
40
60
  end
41
61
 
62
+
42
63
  # Field setter method, accpet <i>*args</i> and <i>&block</i> to be passed.
43
64
  # For details how to pass args and block see Lolita::Configuration::Field.
44
65
  # Return field itself.
@@ -150,9 +171,7 @@ module Lolita
150
171
  private
151
172
 
152
173
  def set_default_fields
153
- if @type==:content && @fields.empty?
154
- default_fields
155
- end
174
+ default_fields if @type!=:default && @fields.empty?
156
175
  end
157
176
 
158
177
  def set_default_attributes
@@ -0,0 +1,15 @@
1
+ module Lolita
2
+ module Configuration
3
+ class ContentTab < Lolita::Configuration::Tab
4
+
5
+ def initialize(dbi,*args,&block)
6
+ @type=:content
7
+ super
8
+ set_default_fields
9
+ end
10
+
11
+ private
12
+
13
+ end
14
+ end
15
+ end
@@ -35,7 +35,7 @@ module Lolita
35
35
  end
36
36
 
37
37
  def tab *args,&block
38
- self<<Lolita::Configuration::Tab.new(@dbi,*args,&block)
38
+ self<<Lolita::Configuration::Tab.add(@dbi,*args,&block)
39
39
  end
40
40
 
41
41
  def exclude=(values)
@@ -0,0 +1,13 @@
1
+ module Lolita
2
+ module Controllers
3
+ module ViewUserHelpers
4
+ def lolita_current_user
5
+ if self.respond_to?(:"current_#{Lolita.user_classes.first.to_s.downcase}")
6
+ send(:"current_#{Lolita.user_classes.first.to_s.downcase}")
7
+ else
8
+ false
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/lolita/errors.rb CHANGED
@@ -7,4 +7,5 @@ module Lolita
7
7
  class FieldTypeError < ArgumentError; end
8
8
  class ModuleNotFound < ArgumentError; end
9
9
  class NotFound < ArgumentError; end
10
+ class TabNotFoundError < NameError; end
10
11
  end
@@ -6,4 +6,5 @@ module ActionDispatch::Routing
6
6
  :controller=>controllers[:rest],:module=>mapping.module
7
7
  end
8
8
  end
9
- end
9
+ end
10
+
data/lib/lolita/rails.rb CHANGED
@@ -1,10 +1,12 @@
1
1
  require 'lolita/rails/routes'
2
2
 
3
3
  ActiveSupport.on_load(:action_controller) {
4
+ include Lolita::Controllers::ViewUserHelpers
4
5
  include Lolita::Controllers::UrlHelpers
5
6
  include Lolita::Controllers::ComponentHelpers
6
7
  }
7
8
  ActiveSupport.on_load(:action_view) {
9
+ include Lolita::Controllers::ViewUserHelpers
8
10
  include Lolita::Controllers::UrlHelpers
9
11
  include Lolita::Controllers::ComponentHelpers
10
12
  }
data/lolita.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lolita}
8
- s.version = "3.0.3"
8
+ s.version = "3.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["ITHouse", "Arturs Meisters"]
@@ -86,11 +86,13 @@ Gem::Specification.new do |s|
86
86
  "lib/lolita/configuration/list.rb",
87
87
  "lib/lolita/configuration/page.rb",
88
88
  "lib/lolita/configuration/tab.rb",
89
+ "lib/lolita/configuration/tab/content.rb",
89
90
  "lib/lolita/configuration/tabs.rb",
90
91
  "lib/lolita/controllers/component_helpers.rb",
91
92
  "lib/lolita/controllers/internal_helpers.rb",
92
93
  "lib/lolita/controllers/url_helpers.rb",
93
94
  "lib/lolita/controllers/user_helpers.rb",
95
+ "lib/lolita/controllers/view_user_helpers.rb",
94
96
  "lib/lolita/dbi/base.rb",
95
97
  "lib/lolita/errors.rb",
96
98
  "lib/lolita/hooks/base.rb",
@@ -1,37 +1,38 @@
1
- $(function(){
2
- // Send ajax request with all forms data for given tabs block.
3
- function save_tab(tabs){
4
- var data=""
5
- tabs.find("form").each(function(){
6
- data=data+$(this).serialize()
7
- })
8
- alert(data)
9
- $.ajax({
10
- url:tabs.attr("data-tabs-url"),
11
- dataType:"html",
12
- type:tabs.attr("data-method"),
13
- data:data,
14
- success:function(data){
15
- $("#right-side").html(data)
16
- }
17
- })
18
- }
19
- // Submit all forms through Ajax when Save All button clicked.
20
- $("button.save-all").live('click',function(){
21
- //var tab=$(this).parents("div[data-tabs-url]")
22
- var tab = $("#content").children("div[data-tabs-url]")
23
- save_tab(tab)
24
- })
25
- // All tabs are closable when clicked on tab title.
26
- $(".tab .tab-title").live('click',function(){
27
- var tab_title=$(this)
28
- var closed=tab_title.data("closed") || (tab_title.attr("data-closed")=="false" ? false : true)
29
- if(closed){
30
- tab_title.parents(".tab").find(".tab-content").show("fast")
31
- }else{
32
- tab_title.parents(".tab").find(".tab-content").hide("fast")
33
- }
34
- tab_title.data("closed",!closed)
35
- })
36
- })
37
-
1
+ $(function(){
2
+ // Send ajax request with all forms data for given tabs block.
3
+ function save_tab(tabs){
4
+ var data=""
5
+ tabs.find("form").each(function(){
6
+ data=data+$(this).serialize()
7
+ })
8
+ //alert(data)
9
+ $.ajax({
10
+ url:tabs.attr("data-tabs-url"),
11
+ dataType:"html",
12
+ type:tabs.attr("data-method"),
13
+ data:data,
14
+ success:function(data){
15
+ $("#content").html(data);
16
+ load_tinymce();
17
+ }
18
+ })
19
+ }
20
+ // Submit all forms through Ajax when Save All button clicked.
21
+ $("button.save-all").live('click',function(){
22
+ //var tab=$(this).parents("div[data-tabs-url]")
23
+ var tab = $("#content").children("div[data-tabs-url]")
24
+ save_tab(tab)
25
+ })
26
+ // All tabs are closable when clicked on tab title.
27
+ $(".tab .tab-title").live('click',function(){
28
+ var tab_title=$(this)
29
+ var closed=tab_title.data("closed") || (tab_title.attr("data-closed")=="false" ? false : true)
30
+ if(closed){
31
+ tab_title.parents(".tab").find(".tab-content").show("fast")
32
+ }else{
33
+ tab_title.parents(".tab").find(".tab-content").hide("fast")
34
+ }
35
+ tab_title.data("closed",!closed)
36
+ })
37
+ })
38
+