typus 3.1.0.rc11 → 3.1.0.rc12
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -16
- data/.gitmodules +3 -6
- data/README.md +50 -16
- data/Rakefile +19 -26
- data/app/helpers/admin/resources/data_types/belongs_to_helper.rb +15 -18
- data/app/helpers/admin/resources/data_types/position_helper.rb +9 -11
- data/app/helpers/admin/resources/form_helper.rb +13 -13
- data/app/helpers/admin/resources/relationships_helper.rb +4 -1
- data/app/helpers/admin/resources/table_helper.rb +11 -14
- data/app/helpers/admin/resources_helper.rb +12 -3
- data/app/themes/default/assets/javascripts/typus/jquery.application.js +0 -6
- data/app/themes/default/assets/stylesheets/typus/pagination.css +1 -2
- data/app/themes/default/views/admin/base/user_guide.html.erb +25 -27
- data/app/themes/default/views/admin/dashboard/_applications.html.erb +2 -10
- data/app/themes/default/views/admin/dashboard/_sidebar.html.erb +9 -2
- data/app/themes/default/views/admin/dashboard/styles.html.erb +10 -15
- data/app/themes/default/views/admin/resources/_form.html.erb +4 -2
- data/app/themes/default/views/admin/resources/_form_javascripts.html.erb +0 -0
- data/app/themes/default/views/admin/templates/README.md +5 -0
- data/app/themes/default/views/admin/templates/_dragonfly.html.erb +1 -0
- data/app/themes/default/views/admin/templates/_has_one.html.erb +1 -1
- data/app/themes/default/views/admin/templates/_position.html.erb +5 -0
- data/app/themes/default/views/admin/templates/_profile_sidebar.html.erb +2 -1
- data/app/themes/default/views/admin/templates/_selector.html.erb +4 -1
- data/app/themes/default/views/admin/templates/_text_with_ckeditor.html.erb +0 -4
- data/app/themes/default/views/helpers/admin/resources/_filters.html.erb +1 -3
- data/app/themes/default/views/helpers/admin/resources/_sidebar.html.erb +6 -9
- data/app/themes/default/views/helpers/admin/resources/_table.html.erb +11 -13
- data/lib/generators/templates/config/initializers/typus_resources.rb +1 -1
- data/lib/generators/templates/config/typus/README +1 -1
- data/lib/typus.rb +15 -26
- data/lib/typus/authentication/base.rb +4 -0
- data/lib/typus/authentication/http_basic.rb +2 -2
- data/lib/typus/authentication/session.rb +3 -5
- data/lib/typus/configuration.rb +14 -12
- data/lib/typus/controller/filters.rb +22 -0
- data/lib/typus/i18n.rb +17 -0
- data/lib/typus/orm/active_record/user/class_methods.rb +1 -1
- data/lib/typus/orm/base.rb +2 -2
- data/lib/typus/resources.rb +1 -1
- data/lib/typus/version.rb +1 -1
- metadata +21 -26
- data/.yardopts +0 -6
- data/Gemfile +0 -60
- data/doc/yard/handlers/configurable_attr_handler.rb +0 -38
- data/doc/yard/setup.rb +0 -9
- data/doc/yard/templates/default/fulldoc/html/css/common.css +0 -109
- data/doc/yard/templates/default/layout/html/layout.erb +0 -126
- data/doc/yard/templates/default/module/html/configuration_summary.erb +0 -31
- data/doc/yard/templates/default/module/setup.rb +0 -17
@@ -8,20 +8,12 @@
|
|
8
8
|
</tr>
|
9
9
|
</thead>
|
10
10
|
|
11
|
-
<% admin_user.application(app).each do |
|
12
|
-
|
13
|
-
<%
|
14
|
-
klass = model.typus_constantize
|
15
|
-
klass_human_name = klass.model_name.human.pluralize
|
16
|
-
admin_items_path = { :controller => "/admin/#{klass.to_resource}" }
|
17
|
-
%>
|
18
|
-
|
11
|
+
<% admin_user.application(app).map { |i| i.typus_constantize }.each do |klass| %>
|
19
12
|
<tr class="<%= cycle("even", "odd") %>">
|
20
13
|
<td>
|
21
|
-
<%= link_to
|
14
|
+
<%= link_to klass.model_name.human.pluralize, :controller => "/admin/#{klass.to_resource}" %>
|
22
15
|
</td>
|
23
16
|
</tr>
|
24
|
-
|
25
17
|
<% end %>
|
26
18
|
|
27
19
|
</table>
|
@@ -1,5 +1,12 @@
|
|
1
1
|
<h2>Welcome!</h2>
|
2
2
|
|
3
|
-
|
3
|
+
<%
|
4
|
+
mailing_list = link_to('mailing list', 'http://groups.google.com/group/typus')
|
5
|
+
user_guide = link_to('user guide', admin_user_guide_path)
|
6
|
+
%>
|
4
7
|
|
5
|
-
<p>
|
8
|
+
<p>If you need help don't hesitate in joining the <%= mailing_list %> or use
|
9
|
+
the provided <%= user_guide %>.</p>
|
10
|
+
|
11
|
+
<p>Replace this sidebar dropping a file named <code>_sidebar.html.erb</code>
|
12
|
+
on the <code>app/views/admin/dashboard</code> folder.</p>
|
@@ -30,27 +30,22 @@
|
|
30
30
|
|
31
31
|
<h2>Header (h2) <small>Small <a href="#">link</a></small></h2>
|
32
32
|
|
33
|
-
<p>
|
34
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
33
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
35
34
|
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
36
35
|
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
37
36
|
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
|
38
37
|
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
|
39
|
-
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
|
40
|
-
</p>
|
38
|
+
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
41
39
|
|
42
40
|
<blockquote>
|
43
|
-
<p>
|
44
|
-
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
41
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
|
45
42
|
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
|
46
43
|
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
|
47
|
-
consequat
|
48
|
-
|
49
|
-
<p>
|
50
|
-
|
51
|
-
|
52
|
-
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
53
|
-
</p>
|
44
|
+
consequat.</p>
|
45
|
+
|
46
|
+
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum
|
47
|
+
dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
|
48
|
+
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
54
49
|
</blockquote>
|
55
50
|
|
56
51
|
<pre>
|
@@ -138,8 +133,8 @@ consequat.
|
|
138
133
|
|
139
134
|
<div class="filters">
|
140
135
|
<ul>
|
141
|
-
|
142
|
-
|
136
|
+
<li>Filter</li>
|
137
|
+
<li>Filter</li>
|
143
138
|
</ul>
|
144
139
|
</div>
|
145
140
|
|
@@ -1,6 +1,8 @@
|
|
1
|
+
<%= render "form_javascripts" %>
|
2
|
+
|
1
3
|
<%= form_for @item, :url => options, :html => { :class => "resource", :multipart => true } do |form| %>
|
2
4
|
|
3
|
-
<%=
|
5
|
+
<%= render "helpers/admin/resources/errors" %>
|
4
6
|
|
5
7
|
<fieldset class="inputs">
|
6
8
|
<ol>
|
@@ -10,7 +12,7 @@
|
|
10
12
|
|
11
13
|
<fieldset class="buttons">
|
12
14
|
<ol>
|
13
|
-
<%
|
15
|
+
<% build_save_options.each do |key, value| %>
|
14
16
|
<li><%= submit_tag Typus::I18n.t(value), :name => key, :onclick => "setConfirmUnload(false);", :disable_with => Typus::I18n.t(value) %></li>
|
15
17
|
<% end %>
|
16
18
|
</ol>
|
File without changes
|
@@ -1,3 +1,4 @@
|
|
1
1
|
<h2>Profile</h2>
|
2
2
|
|
3
|
-
<p>Replace this sidebar dropping a file named <code>_profile_sidebar.html.erb</code>
|
3
|
+
<p>Replace this sidebar dropping a file named <code>_profile_sidebar.html.erb</code>
|
4
|
+
on <code>app/views/admin/templates</code> folder.</p>
|
@@ -1,4 +1,7 @@
|
|
1
1
|
<%
|
2
|
+
custom = { :include_blank => true }
|
3
|
+
options.merge!(custom)
|
4
|
+
|
2
5
|
if @resource.typus_field_options_for(:read_only).include?(attribute.to_sym)
|
3
6
|
html_options.merge!(:disabled => 'disabled')
|
4
7
|
message = Typus::I18n.t("Read only")
|
@@ -7,5 +10,5 @@
|
|
7
10
|
|
8
11
|
<li id="<%= attribute %>">
|
9
12
|
<%= form.label attribute, "#{label_text} <small>#{message}</small>".html_safe %>
|
10
|
-
<%= form.select attribute, @resource.send(attribute), options
|
13
|
+
<%= form.select attribute, @resource.send(attribute), options, html_options %>
|
11
14
|
</li>
|
@@ -7,10 +7,6 @@
|
|
7
7
|
options = options.merge!(custom)
|
8
8
|
%>
|
9
9
|
|
10
|
-
<input type="hidden"
|
11
|
-
id="pageListJSON"
|
12
|
-
value="[<%= Page.all.map { |p| "['#{p.to_label}', '/pages/#{p.respond?(:permalink) p.permalink : p.id}']" }.join(", ") %>]">
|
13
|
-
|
14
10
|
<li id="<%= attribute %>">
|
15
11
|
<%= form.label attribute, label_text %>
|
16
12
|
<%= form.text_area attribute, options %>
|
@@ -10,9 +10,7 @@
|
|
10
10
|
<%= hidden_field_tag key, value %>
|
11
11
|
<% end %>
|
12
12
|
|
13
|
-
<li><%= submit_tag Typus::I18n.t("Filter"),
|
14
|
-
:name => nil,
|
15
|
-
:disable_with => Typus::I18n.t("Sending data ...") %></li>
|
13
|
+
<li><%= submit_tag Typus::I18n.t("Filter"), :name => nil, :disable_with => Typus::I18n.t("Sending data ...") %></li>
|
16
14
|
</ul>
|
17
15
|
</div>
|
18
16
|
|
@@ -1,18 +1,15 @@
|
|
1
|
-
<% resources.each do |
|
1
|
+
<% resources.each do |resource, actions| %>
|
2
2
|
|
3
|
-
<%
|
4
|
-
klass = key.typus_constantize
|
5
|
-
resource = "/admin/#{klass.to_resource}"
|
6
|
-
%>
|
3
|
+
<% klass = resource.typus_constantize %>
|
7
4
|
|
8
|
-
<%= link_to :controller =>
|
5
|
+
<%= link_to :controller => "/admin/#{klass.to_resource}" do %>
|
9
6
|
<h3><%= klass.model_name.human.pluralize %></h3>
|
10
7
|
<% end %>
|
11
8
|
|
12
|
-
<% if @resource.model_name.eql?(
|
9
|
+
<% if @resource.model_name.eql?(resource) %>
|
13
10
|
<ul>
|
14
|
-
<%
|
15
|
-
<li><%=
|
11
|
+
<% actions.each do |action| %>
|
12
|
+
<li><%= link_to action[:message], action[:url] %></li>
|
16
13
|
<% end %>
|
17
14
|
</ul>
|
18
15
|
<% end %>
|
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
<% content_for :table_headers do %>
|
3
2
|
<thead>
|
4
3
|
<tr>
|
5
4
|
<% if controller.respond_to?(:bulk) %>
|
@@ -10,6 +9,11 @@
|
|
10
9
|
<% end %>
|
11
10
|
</tr>
|
12
11
|
</thead>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<table>
|
15
|
+
|
16
|
+
<%= yield :table_headers %>
|
13
17
|
|
14
18
|
<% items.each do |item| %>
|
15
19
|
<tr class="<%= cycle('even', 'odd') %>" id="<%= dom_id(item) %>">
|
@@ -23,7 +27,10 @@
|
|
23
27
|
<%= field %>
|
24
28
|
<% if index.zero? %>
|
25
29
|
<div class="actions">
|
26
|
-
|
30
|
+
<% table_actions(model, item, association_name).each_with_index do |action, index| %>
|
31
|
+
<%= "/" unless index.zero? %>
|
32
|
+
<%= link_to action[:message], action[:url], action[:options] %>
|
33
|
+
<% end %>
|
27
34
|
</div>
|
28
35
|
<% end %>
|
29
36
|
</td>
|
@@ -31,15 +38,6 @@
|
|
31
38
|
</tr>
|
32
39
|
<% end %>
|
33
40
|
|
34
|
-
|
35
|
-
<tr>
|
36
|
-
<% if controller.respond_to?(:bulk) %>
|
37
|
-
<th><%= check_box_tag "action-toggle", "", false, :class => "action-toggle" %></th>
|
38
|
-
<% end %>
|
39
|
-
<% headers.each do |header| %>
|
40
|
-
<th><%= header %></th>
|
41
|
-
<% end %>
|
42
|
-
</tr>
|
43
|
-
</thead>
|
41
|
+
<%= yield :table_headers %>
|
44
42
|
|
45
43
|
</table>
|
data/lib/typus.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
|
3
1
|
require "support/active_record"
|
4
2
|
require "support/hash"
|
5
3
|
require "support/object"
|
@@ -72,10 +70,19 @@ module Typus
|
|
72
70
|
##
|
73
71
|
# Pagination options passed to Kaminari helper.
|
74
72
|
#
|
73
|
+
# :previous_label => "← " + Typus::I18n.t("Previous")
|
74
|
+
# :next_label => Typus::I18n.t("Next") + " →"
|
75
|
+
#
|
76
|
+
# Note that `Kaminari` only accepts the following configuration options:
|
77
|
+
#
|
78
|
+
# - default_per_page (25 by default)
|
79
|
+
# - window (4 by default)
|
80
|
+
# - outer_window (0 by default)
|
81
|
+
# - left (0 by default)
|
82
|
+
# - right (0 by default)
|
83
|
+
#
|
75
84
|
mattr_accessor :pagination
|
76
|
-
@@pagination = { :window => 0
|
77
|
-
:previous_label => "← " + Typus::I18n.t("Previous"),
|
78
|
-
:next_label => Typus::I18n.t("Next") + " →" }
|
85
|
+
@@pagination = { :window => 0 }
|
79
86
|
|
80
87
|
##
|
81
88
|
# Define a password.
|
@@ -147,14 +154,11 @@ module Typus
|
|
147
154
|
|
148
155
|
# Lists models from the configuration file.
|
149
156
|
def models
|
150
|
-
|
151
|
-
config.map { |i| i.first }.sort
|
152
|
-
else
|
153
|
-
[]
|
154
|
-
end
|
157
|
+
Typus::Configuration.config.map { |i| i.first }.sort
|
155
158
|
end
|
156
159
|
|
157
|
-
# Lists resources, which are tableless models.
|
160
|
+
# Lists resources, which are tableless models. This is done by looking at
|
161
|
+
# the roles, which handle the permissions for this kind of data.
|
158
162
|
def resources
|
159
163
|
if roles = Typus::Configuration.roles
|
160
164
|
roles.keys.map do |key|
|
@@ -171,21 +175,6 @@ module Typus
|
|
171
175
|
Dir.chdir(model_dir) { Dir["**/*.rb"] }
|
172
176
|
end
|
173
177
|
|
174
|
-
def locales
|
175
|
-
{ "Català" => "ca",
|
176
|
-
"German" => "de",
|
177
|
-
"Greek" => "el",
|
178
|
-
"English" => "en",
|
179
|
-
"Español" => "es",
|
180
|
-
"Français" => "fr",
|
181
|
-
"Magyar" => "hu",
|
182
|
-
"Italiano" => "It",
|
183
|
-
"Portuguese" => "pt-PT",
|
184
|
-
"Brazilian Portuguese" => "pt-BR",
|
185
|
-
"Russian" => "ru",
|
186
|
-
"中文" => "zh-CN" }
|
187
|
-
end
|
188
|
-
|
189
178
|
def application_models
|
190
179
|
detect_application_models.map do |model|
|
191
180
|
class_name = model.sub(/\.rb$/,"").camelize
|
@@ -8,8 +8,8 @@ module Typus
|
|
8
8
|
|
9
9
|
def authenticate
|
10
10
|
@admin_user = FakeUser.new
|
11
|
-
authenticate_or_request_with_http_basic(Typus.admin_title) do |
|
12
|
-
|
11
|
+
authenticate_or_request_with_http_basic(Typus.admin_title) do |username, password|
|
12
|
+
username == Typus.username && password == Typus.password
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -59,7 +59,9 @@ module Typus
|
|
59
59
|
# Admin can update himself except setting the status to false!. Other
|
60
60
|
# users can update their profile as the attributes (role & status)
|
61
61
|
# are protected.
|
62
|
-
|
62
|
+
status_as_boolean = params[@object_name][:status] == "1" ? true : false
|
63
|
+
|
64
|
+
status_changed = !(@item.status == status_as_boolean)
|
63
65
|
role_changed = !(@item.role == params[@object_name][:role])
|
64
66
|
|
65
67
|
root_changed_his_status_or_role = current_user_is_root && (status_changed || role_changed)
|
@@ -78,10 +80,6 @@ module Typus
|
|
78
80
|
not_allowed if admin_user.cannot?(params[:action], resource, { :special => true })
|
79
81
|
end
|
80
82
|
|
81
|
-
def not_allowed
|
82
|
-
render :text => "Not allowed!", :status => :unprocessable_entity
|
83
|
-
end
|
84
|
-
|
85
83
|
#--
|
86
84
|
# If item is owned by another user, we only can perform a show action on
|
87
85
|
# the item. Updated item is also blocked.
|
data/lib/typus/configuration.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
module Typus
|
2
2
|
module Configuration
|
3
3
|
|
4
|
-
# Read configuration from <tt>config/typus
|
4
|
+
# Read configuration from <tt>config/typus/*.yml</tt>.
|
5
5
|
def self.config!
|
6
|
-
|
7
|
-
plugins = Dir[File.join("vendor", "plugins", "*", "config", "typus", "*.yml").to_s]
|
8
|
-
files = (application + plugins).reject { |f| f.include?("_roles.yml") }
|
6
|
+
files = Dir[File.join(Typus.config_folder, "*.yml").to_s].reject { |f| f.match(/_roles.yml/) }
|
9
7
|
|
10
8
|
@@config = {}
|
11
9
|
|
@@ -14,17 +12,18 @@ module Typus
|
|
14
12
|
@@config.merge!(data)
|
15
13
|
end
|
16
14
|
end
|
17
|
-
|
18
|
-
@@config
|
19
15
|
end
|
20
16
|
|
21
17
|
mattr_accessor :config
|
18
|
+
@@config = {}
|
19
|
+
|
20
|
+
def self.register_config(config)
|
21
|
+
@@config.merge!(config)
|
22
|
+
end
|
22
23
|
|
23
|
-
# Read roles from files <tt>config/typus
|
24
|
+
# Read roles from files <tt>config/typus/*_roles.yml</tt>.
|
24
25
|
def self.roles!
|
25
|
-
|
26
|
-
plugins = Dir[File.join("vendor", "plugins", "*", "config", "typus", "*_roles.yml").to_s]
|
27
|
-
files = (application + plugins).sort
|
26
|
+
files = Dir[File.join(Typus.config_folder, "*_roles.yml").to_s].sort
|
28
27
|
|
29
28
|
@@roles = {}
|
30
29
|
|
@@ -35,11 +34,14 @@ module Typus
|
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
38
|
-
|
39
|
-
@@roles
|
40
37
|
end
|
41
38
|
|
42
39
|
mattr_accessor :roles
|
40
|
+
@@roles = {}
|
41
|
+
|
42
|
+
def self.register_roles(roles)
|
43
|
+
@@roles.merge!(roles)
|
44
|
+
end
|
43
45
|
|
44
46
|
def self.models_constantized!
|
45
47
|
@@models_constantized = config.map { |i| i.first }.inject({}) { |result, model| result[model] = model.constantize; result }
|