outpost-cms 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/MIT-LICENSE +20 -0
- data/README.md +295 -0
- data/Rakefile +26 -0
- data/app/assets/images/glyphicons-halflings-red.png +0 -0
- data/app/assets/javascripts/outpost/application.js +1 -0
- data/app/assets/javascripts/outpost/auto_slug_field.js.coffee +53 -0
- data/app/assets/javascripts/outpost/base.js.coffee +1 -0
- data/app/assets/javascripts/outpost/date_time_input.js.coffee +108 -0
- data/app/assets/javascripts/outpost/field_counter.js.coffee +93 -0
- data/app/assets/javascripts/outpost/field_manager.js.coffee +37 -0
- data/app/assets/javascripts/outpost/global_plugins.js.coffee +87 -0
- data/app/assets/javascripts/outpost/index_manager.js.coffee +88 -0
- data/app/assets/javascripts/outpost/notification.js.coffee +46 -0
- data/app/assets/javascripts/outpost/preview.js.coffee +60 -0
- data/app/assets/javascripts/outpost/templates/date_field.jst.eco +3 -0
- data/app/assets/javascripts/outpost/templates/loading.jst.eco +11 -0
- data/app/assets/javascripts/outpost/templates/slug_generate_button.jst.eco +1 -0
- data/app/assets/javascripts/outpost/templates/time_field.jst.eco +3 -0
- data/app/assets/javascripts/outpost/templates.js +1 -0
- data/app/assets/javascripts/outpost.js +32 -0
- data/app/assets/stylesheets/outpost/_base.css.scss +127 -0
- data/app/assets/stylesheets/outpost/_edit.css.scss +13 -0
- data/app/assets/stylesheets/outpost/_forms.css.scss +116 -0
- data/app/assets/stylesheets/outpost/_index.css.scss +68 -0
- data/app/assets/stylesheets/outpost/_utility.css.scss +16 -0
- data/app/assets/stylesheets/outpost/application.css.scss +1 -0
- data/app/assets/stylesheets/outpost/bootstrap/bootstrap.css.scss +49 -0
- data/app/assets/stylesheets/outpost/bootstrap/datepicker.css.scss +301 -0
- data/app/assets/stylesheets/outpost.css.scss +14 -0
- data/app/controllers/outpost/application_controller.rb +40 -0
- data/app/controllers/outpost/base_controller.rb +3 -0
- data/app/controllers/outpost/errors_controller.rb +9 -0
- data/app/controllers/outpost/home_controller.rb +2 -0
- data/app/controllers/outpost/resource_controller.rb +12 -0
- data/app/controllers/outpost/sessions_controller.rb +36 -0
- data/app/helpers/authorization_helper.rb +44 -0
- data/app/helpers/list_helper.rb +243 -0
- data/app/helpers/outpost_helper.rb +49 -0
- data/app/helpers/render_helper.rb +41 -0
- data/app/helpers/utility_helper.rb +136 -0
- data/app/inputs/date_time_input.rb +12 -0
- data/app/models/permission.rb +18 -0
- data/app/models/user_permission.rb +4 -0
- data/app/views/kaminari/bootstrap/_first_page.html.erb +3 -0
- data/app/views/kaminari/bootstrap/_gap.html.erb +3 -0
- data/app/views/kaminari/bootstrap/_last_page.html.erb +3 -0
- data/app/views/kaminari/bootstrap/_next_page.html.erb +3 -0
- data/app/views/kaminari/bootstrap/_page.html.erb +3 -0
- data/app/views/kaminari/bootstrap/_paginator.html.erb +17 -0
- data/app/views/kaminari/bootstrap/_prev_page.html.erb +3 -0
- data/app/views/layouts/outpost/application.html.erb +101 -0
- data/app/views/layouts/outpost/minimal.html.erb +26 -0
- data/app/views/outpost/errors/error_404.html.erb +1 -0
- data/app/views/outpost/errors/error_500.html.erb +8 -0
- data/app/views/outpost/home/dashboard.html.erb +1 -0
- data/app/views/outpost/resource/_errors.html.erb +11 -0
- data/app/views/outpost/resource/_extra_fields.html.erb +1 -0
- data/app/views/outpost/resource/_form_fields.html.erb +9 -0
- data/app/views/outpost/resource/edit.html.erb +44 -0
- data/app/views/outpost/resource/index.html.erb +22 -0
- data/app/views/outpost/resource/new.html.erb +21 -0
- data/app/views/outpost/resource/search.html.erb +1 -0
- data/app/views/outpost/resource/show.html.erb +1 -0
- data/app/views/outpost/sessions/new.html.erb +16 -0
- data/app/views/outpost/shared/_add_link.html.erb +1 -0
- data/app/views/outpost/shared/_breadcrumbs.html.erb +15 -0
- data/app/views/outpost/shared/_cancel_link.html.erb +1 -0
- data/app/views/outpost/shared/_columns.html.erb +5 -0
- data/app/views/outpost/shared/_filters.html.erb +16 -0
- data/app/views/outpost/shared/_flash_messages.html.erb +6 -0
- data/app/views/outpost/shared/_form_block.html.erb +18 -0
- data/app/views/outpost/shared/_form_nav.html.erb +12 -0
- data/app/views/outpost/shared/_headers.html.erb +16 -0
- data/app/views/outpost/shared/_index_header.html.erb +4 -0
- data/app/views/outpost/shared/_list_table.html.erb +7 -0
- data/app/views/outpost/shared/_modal.html.erb +16 -0
- data/app/views/outpost/shared/_navigation.html.erb +31 -0
- data/app/views/outpost/shared/_notice.html.erb +1 -0
- data/app/views/outpost/shared/_pagination.html.erb +2 -0
- data/app/views/outpost/shared/_preview_errors.html.erb +9 -0
- data/app/views/outpost/shared/_submit_row.html.erb +50 -0
- data/config/routes.rb +4 -0
- data/lib/action_view/helpers/form_builder.rb +71 -0
- data/lib/outpost/breadcrumbs.rb +73 -0
- data/lib/outpost/config.rb +63 -0
- data/lib/outpost/controller/actions.rb +72 -0
- data/lib/outpost/controller/authentication.rb +34 -0
- data/lib/outpost/controller/authorization.rb +28 -0
- data/lib/outpost/controller/callbacks.rb +14 -0
- data/lib/outpost/controller/custom_errors.rb +41 -0
- data/lib/outpost/controller/filtering.rb +22 -0
- data/lib/outpost/controller/helpers.rb +52 -0
- data/lib/outpost/controller/ordering.rb +46 -0
- data/lib/outpost/controller/preferences.rb +71 -0
- data/lib/outpost/controller.rb +123 -0
- data/lib/outpost/engine.rb +10 -0
- data/lib/outpost/helpers/naming.rb +22 -0
- data/lib/outpost/helpers.rb +6 -0
- data/lib/outpost/hook.rb +35 -0
- data/lib/outpost/list/base.rb +78 -0
- data/lib/outpost/list/column.rb +24 -0
- data/lib/outpost/list/filter.rb +37 -0
- data/lib/outpost/list.rb +15 -0
- data/lib/outpost/model/authentication.rb +34 -0
- data/lib/outpost/model/authorization.rb +32 -0
- data/lib/outpost/model/identifier.rb +39 -0
- data/lib/outpost/model/methods.rb +23 -0
- data/lib/outpost/model/naming.rb +63 -0
- data/lib/outpost/model/routing.rb +138 -0
- data/lib/outpost/model/serializer.rb +27 -0
- data/lib/outpost/model.rb +22 -0
- data/lib/outpost/test.rb +21 -0
- data/lib/outpost/version.rb +3 -0
- data/lib/outpost-cms.rb +2 -0
- data/lib/outpost.rb +80 -0
- data/lib/tasks/outpost_tasks.rake +7 -0
- data/spec/controllers/authentication_spec.rb +62 -0
- data/spec/controllers/sessions_controller_spec.rb +99 -0
- data/spec/factories.rb +31 -0
- data/spec/helpers/authorization_helper_spec.rb +47 -0
- data/spec/helpers/list_helper_spec.rb +74 -0
- data/spec/helpers/outpost_helper_spec.rb +5 -0
- data/spec/helpers/render_helper_spec.rb +19 -0
- data/spec/helpers/utility_helper_spec.rb +53 -0
- data/spec/internal/app/controllers/application_controller.rb +3 -0
- data/spec/internal/app/controllers/outpost/people_controller.rb +23 -0
- data/spec/internal/app/controllers/outpost/pidgeons_controller.rb +5 -0
- data/spec/internal/app/controllers/people_controller.rb +9 -0
- data/spec/internal/app/controllers/pidgeons_controller.rb +3 -0
- data/spec/internal/app/models/person.rb +10 -0
- data/spec/internal/app/models/pidgeon.rb +3 -0
- data/spec/internal/app/models/post.rb +4 -0
- data/spec/internal/app/models/user.rb +4 -0
- data/spec/internal/app/views/people/index.html.erb +7 -0
- data/spec/internal/app/views/people/show.html.erb +1 -0
- data/spec/internal/config/database.yml +3 -0
- data/spec/internal/config/initializers/configuration.rb +3 -0
- data/spec/internal/config/initializers/outpost.rb +6 -0
- data/spec/internal/config/routes.rb +16 -0
- data/spec/internal/db/combustion_test.sqlite +0 -0
- data/spec/internal/db/schema.rb +44 -0
- data/spec/internal/db/seeds.rb +14 -0
- data/spec/internal/log/test.log +59277 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/breadcrumbs_spec.rb +54 -0
- data/spec/lib/config_spec.rb +76 -0
- data/spec/lib/controller/actions_spec.rb +5 -0
- data/spec/lib/controller/authorization_spec.rb +4 -0
- data/spec/lib/controller/callbacks_spec.rb +31 -0
- data/spec/lib/controller/helpers_spec.rb +33 -0
- data/spec/lib/controller_spec.rb +25 -0
- data/spec/lib/helpers/naming_spec.rb +10 -0
- data/spec/lib/hook_spec.rb +13 -0
- data/spec/lib/list/base_spec.rb +96 -0
- data/spec/lib/list/column_spec.rb +46 -0
- data/spec/lib/list/filter_spec.rb +44 -0
- data/spec/lib/model/authentication_spec.rb +29 -0
- data/spec/lib/model/authorization_spec.rb +66 -0
- data/spec/lib/model/identifier_spec.rb +51 -0
- data/spec/lib/model/methods_spec.rb +8 -0
- data/spec/lib/model/naming_spec.rb +55 -0
- data/spec/lib/model/routing_spec.rb +166 -0
- data/spec/lib/model/serializer_spec.rb +13 -0
- data/spec/lib/outpost_spec.rb +34 -0
- data/spec/models/permission_spec.rb +10 -0
- data/spec/models/user_permission_spec.rb +4 -0
- data/spec/spec_helper.rb +22 -0
- metadata +411 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h2>Dashboard!</h2>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<% if f.object.errors[:base].present? %>
|
|
2
|
+
<div class="alert alert-error">
|
|
3
|
+
<ul class="unstyled" style="margin-bottom: 0">
|
|
4
|
+
<% f.object.errors[:base].each do |message| %>
|
|
5
|
+
<li><%= message %></li>
|
|
6
|
+
<% end %>
|
|
7
|
+
</ul>
|
|
8
|
+
</div>
|
|
9
|
+
<% else %>
|
|
10
|
+
<%= f.error_notification %>
|
|
11
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= hidden_field_tag :obj_key, f.object.obj_key %>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<% fields.each do |field| %>
|
|
2
|
+
<% association = field.gsub(/_id/, "").to_sym %>
|
|
3
|
+
<% reflection = f.object.class.reflect_on_association(association) %>
|
|
4
|
+
<% if reflection && !reflection.options[:polymorphic] %>
|
|
5
|
+
<%= f.association association %>
|
|
6
|
+
<% else %>
|
|
7
|
+
<%= f.input field %>
|
|
8
|
+
<% end %>
|
|
9
|
+
<% end %>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<% add_to_page_title "Editing: #{@record.to_title}" %>
|
|
2
|
+
|
|
3
|
+
<%= simple_form_for [:outpost, @record], html: { class: "form-horizontal" } do |f| %>
|
|
4
|
+
<%= render 'errors', f: f %>
|
|
5
|
+
<%= render 'form_fields', record: @record, f: f %>
|
|
6
|
+
<%= render 'extra_fields', f: f %>
|
|
7
|
+
<%= render "/outpost/shared/submit_row", record: @record %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% content_for :sidebar do %>
|
|
11
|
+
<ul class="story-status unstyled">
|
|
12
|
+
<li>
|
|
13
|
+
Last Updated: <strong><%= format_date @record.updated_at, time: true %></strong>
|
|
14
|
+
</li>
|
|
15
|
+
|
|
16
|
+
<li>
|
|
17
|
+
<% if @record.respond_to? :status_text %>
|
|
18
|
+
<span class="<%=status_bootstrap_map[@record.status]%>"><%= @record.status_text %></span>
|
|
19
|
+
<% end %>
|
|
20
|
+
|
|
21
|
+
<% if @record.respond_to?(:published_at) && @record.respond_to?(:published?) && @record.published? %>
|
|
22
|
+
on <strong><%= format_date @record.published_at, time: true %></strong>
|
|
23
|
+
<% end %>
|
|
24
|
+
|
|
25
|
+
<% if @record.respond_to?(:publish_alarm) && @record.publish_alarm.present? && @record.publish_alarm.fire_at.present? %>
|
|
26
|
+
Alarm - <strong><%= format_date @record.publish_alarm.fire_at, time: true %></strong>
|
|
27
|
+
<% end %>
|
|
28
|
+
</li>
|
|
29
|
+
</ul>
|
|
30
|
+
|
|
31
|
+
<hr />
|
|
32
|
+
|
|
33
|
+
<div id="fixed-sidebar" data-spy="affix" data-offset-top="140">
|
|
34
|
+
<!-- Be sure to change the data-offset-top attribute on this element if you move it vertically -->
|
|
35
|
+
<%= render "/outpost/shared/form_nav" %>
|
|
36
|
+
</div>
|
|
37
|
+
<% end %>
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
<% content_for :footer do %>
|
|
41
|
+
<script>
|
|
42
|
+
preview = new outpost.Preview({baseUrl: '<%= @record.admin_show_path %>'});
|
|
43
|
+
</script>
|
|
44
|
+
<% end %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<% add_to_page_title model.to_title.pluralize %>
|
|
2
|
+
|
|
3
|
+
<%= render "/outpost/shared/index_header", model: model %>
|
|
4
|
+
|
|
5
|
+
<%= list_table @records, model do %>
|
|
6
|
+
<thead>
|
|
7
|
+
<tr>
|
|
8
|
+
<%= render "/outpost/shared/headers", list: list %>
|
|
9
|
+
</tr>
|
|
10
|
+
</thead>
|
|
11
|
+
<tbody class="list">
|
|
12
|
+
<% @records.each do |record| %>
|
|
13
|
+
<tr class="<%= model.singular_route_key.dasherize %>">
|
|
14
|
+
<td class="column-manage">
|
|
15
|
+
<%= link_to "Edit", record.admin_edit_path, class: "btn" %>
|
|
16
|
+
</td>
|
|
17
|
+
|
|
18
|
+
<%= render "/outpost/shared/columns", list: list, record: record %>
|
|
19
|
+
</tr>
|
|
20
|
+
<% end %>
|
|
21
|
+
</tbody>
|
|
22
|
+
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% add_to_page_title "Add #{model.to_title}" %>
|
|
2
|
+
|
|
3
|
+
<%= simple_form_for [:outpost, @record], html: { class: "form-horizontal" } do |f| %>
|
|
4
|
+
<%= render 'errors', f: f %>
|
|
5
|
+
<%= render 'form_fields', record: @record, f: f %>
|
|
6
|
+
<%= render 'extra_fields', f: f %>
|
|
7
|
+
<%= render "/outpost/shared/submit_row", record: @record %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% content_for :sidebar do %>
|
|
11
|
+
<div id="fixed-sidebar" data-spy="affix" data-offset-top="30">
|
|
12
|
+
<!-- Be sure to change the data-offset-top attribute on this element if you move it vertically -->
|
|
13
|
+
<%= render "/outpost/shared/form_nav" %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<% content_for :footer do %>
|
|
18
|
+
<script>
|
|
19
|
+
preview = new outpost.Preview({baseUrl: '<%= model.admin_index_path %>'});
|
|
20
|
+
</script>
|
|
21
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render template: '/outpost/resource/index' %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<h2><%= @record.to_title %></h2>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% add_to_page_title "Login" %>
|
|
2
|
+
|
|
3
|
+
<%= form_tag outpost_sessions_path, id: "login" do %>
|
|
4
|
+
<fieldset>
|
|
5
|
+
<legend>Login</legend>
|
|
6
|
+
<%= label_tag @authentication_attribute %>
|
|
7
|
+
<%= text_field_tag @authentication_attribute, nil, autofocus: "autofocus" %>
|
|
8
|
+
|
|
9
|
+
<%= label_tag "Password" %>
|
|
10
|
+
<%= password_field_tag :password, nil, id: "password" %>
|
|
11
|
+
</fieldset>
|
|
12
|
+
|
|
13
|
+
<div class="form-actions">
|
|
14
|
+
<%= submit_tag "Submit", class: "btn" %>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= link_to content_tag(:i, "", class: "icon-plus-sign icon-white") + " Add #{model.to_title}", model.admin_new_path, class: "btn btn-success pull-right" %>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<ul class="breadcrumb">
|
|
2
|
+
<% breadcrumbs.each do |crumb| %>
|
|
3
|
+
<li>
|
|
4
|
+
<% if crumb.link.present? %>
|
|
5
|
+
<%= link_to crumb.title, crumb.link %>
|
|
6
|
+
<% else %>
|
|
7
|
+
<%= crumb.title %>
|
|
8
|
+
<% end %>
|
|
9
|
+
|
|
10
|
+
<% unless crumb == breadcrumbs.last %>
|
|
11
|
+
<span class="divider">/</span>
|
|
12
|
+
<% end %>
|
|
13
|
+
</li>
|
|
14
|
+
<% end %>
|
|
15
|
+
</ul>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<a href="<%=href%>" title="Reset this filter" class="cancel-link"><i class="icon-remove icon-red"></i></a>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<% list.columns.each do |attribute, column| %>
|
|
2
|
+
<td data-id="<%=record.id%>" class="<%=column_attribute_class(column.attribute)%> <%=column_type_class(model, column.attribute)%>" data-attribute="<%=column.attribute.parameterize%>"<% if column.quick_edit? %> data-updatable="true"<% end %>>
|
|
3
|
+
<%= render_attribute column, record %>
|
|
4
|
+
</td>
|
|
5
|
+
<% end %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<% if list.filters.present? %>
|
|
2
|
+
<div class="filters pull-left" style="margin-right:40px;">
|
|
3
|
+
<span class="filter label">Filter by:</span>
|
|
4
|
+
|
|
5
|
+
<%= form_tag model.admin_index_path, method: :get, class: "form-inline" do %>
|
|
6
|
+
<% list.filters.each do |attribute, filter| %>
|
|
7
|
+
<%= select_tag attribute,
|
|
8
|
+
options_for_select(filter.collection.call, params[:filter].present? ? params[:filter][attribute] : nil), include_blank: true,
|
|
9
|
+
data: { placeholder: filter.title }, name: "filter[#{attribute}]", class: "input-medium" %>
|
|
10
|
+
<% end %>
|
|
11
|
+
|
|
12
|
+
<%= submit_tag "Go", class: "btn" %>
|
|
13
|
+
<%= render "/outpost/shared/cancel_link", href: url_for(request.parameters.except("filter")) %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</div>
|
|
16
|
+
<% end %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<% if title.present? %>
|
|
2
|
+
<% id = "form-block-#{title.parameterize}" %>
|
|
3
|
+
<% @sections[id] = title if @sections %>
|
|
4
|
+
<fieldset class="form-block" id="<%=id%>">
|
|
5
|
+
<legend><%= title %></legend>
|
|
6
|
+
|
|
7
|
+
<div class="hidden notification">
|
|
8
|
+
<p class="muted"><i>Click header to show fields</i></p>
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
<% else %>
|
|
12
|
+
<fieldset class="form-block">
|
|
13
|
+
<% end %>
|
|
14
|
+
|
|
15
|
+
<div class="fields">
|
|
16
|
+
<%= body %>
|
|
17
|
+
</div>
|
|
18
|
+
</fieldset>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<th class="column-manage">Manage</th>
|
|
2
|
+
|
|
3
|
+
<% list.columns.each do |attribute, column| %>
|
|
4
|
+
<% is_sorting = order == column.attribute.to_s %>
|
|
5
|
+
|
|
6
|
+
<th class="<%='header-highlighted' if is_sorting%> <%='header-sortable' if column.sortable?%> <%=column_attribute_class(column.attribute)%> <%=column_type_class(model, column.attribute)%>">
|
|
7
|
+
<% if column.sortable? || is_sorting %>
|
|
8
|
+
<i class="icon <%=sort_mode_icon(is_sorting ? sort_mode : column.default_sort_mode)%>"></i>
|
|
9
|
+
|
|
10
|
+
<%= link_to_if column.sortable?, column.header, request.parameters.merge(order: column.attribute, sort_mode: switch_sort_mode(column, order, sort_mode)), class: "js-sort-link" %>
|
|
11
|
+
<%= render('/outpost/shared/cancel_link', href: url_for(request.parameters.merge(order: "", sort_mode: ""))) if (is_sorting && (order != list.default_order || sort_mode != list.default_sort_mode)) %>
|
|
12
|
+
<% else %>
|
|
13
|
+
<%= column.header %>
|
|
14
|
+
<% end %>
|
|
15
|
+
</th>
|
|
16
|
+
<% end %>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<a class="btn btn-primary" href="#<%=options[:id]%>" data-toggle="modal"><%= options[:title] %></a>
|
|
2
|
+
|
|
3
|
+
<div id="<%= options[:id] %>" class="modal hide fade" role="dialog">
|
|
4
|
+
<div class="modal-header">
|
|
5
|
+
<button type="button" class="close" data-dismiss="modal">x</button>
|
|
6
|
+
<h3><%= options[:title] %></h3>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<div class="modal-body">
|
|
10
|
+
<%= body %>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div class="modal-footer">
|
|
14
|
+
<button class="btn" data-dismiss="modal">Close</button>
|
|
15
|
+
</div>
|
|
16
|
+
</div>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<li class="dropdown">
|
|
2
|
+
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-align-justify icon-white"></i> Navigation <b class="caret"></b></a>
|
|
3
|
+
<% models = current_user.allowed_resources.sort_by(&:name) %>
|
|
4
|
+
<% per_col = 20 %>
|
|
5
|
+
<% cols = (models.size.to_f / per_col.to_f).ceil %>
|
|
6
|
+
|
|
7
|
+
<ul class="dropdown-menu cms-nav" style="width:<%= cols * 400 + cols * 10 %>px">
|
|
8
|
+
<% models.each_with_index do |model, index| %>
|
|
9
|
+
<% if index % per_col == 0 %>
|
|
10
|
+
<div class="grouper">
|
|
11
|
+
<% end %>
|
|
12
|
+
|
|
13
|
+
<li>
|
|
14
|
+
<a href="<%=model.admin_index_path%>">
|
|
15
|
+
<%= model.name.titleize.pluralize %>
|
|
16
|
+
</a>
|
|
17
|
+
|
|
18
|
+
<div class="btn-links">
|
|
19
|
+
<% if model.respond_to?(:admin_new_path) %>
|
|
20
|
+
<a class="add btn btn-mini" href="<%=model.admin_new_path%>"><i class="icon-plus-sign"></i> Add</a>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
23
|
+
</li>
|
|
24
|
+
|
|
25
|
+
<% if index % per_col == per_col - 1 or model == models.last %>
|
|
26
|
+
</div>
|
|
27
|
+
<% end %>
|
|
28
|
+
|
|
29
|
+
<% end %>
|
|
30
|
+
</ul> <!-- dropdown-menu -->
|
|
31
|
+
</li> <!-- dropdown -->
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<div class="alert alert-info"><%= message %></div>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<div class="alert alert-error">
|
|
2
|
+
This <%= record.class.to_title %> can't be previewed until the following problems are corrected:
|
|
3
|
+
|
|
4
|
+
<ul style="margin-bottom: 0;">
|
|
5
|
+
<% record.errors.full_messages.each do |message| %>
|
|
6
|
+
<li><%= message %></li>
|
|
7
|
+
<% end %>
|
|
8
|
+
</ul>
|
|
9
|
+
</div>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<!-- This block is part of a form -->
|
|
2
|
+
<div class="form-actions submit-row">
|
|
3
|
+
<div class="container">
|
|
4
|
+
<div class="btn-group dropup pull-left">
|
|
5
|
+
<%= button_tag "Save", name: "commit_action", value: "edit", class: "btn btn-primary btn-large span2" %>
|
|
6
|
+
<button class="btn btn-primary btn-large dropdown-toggle" data-toggle="dropdown">
|
|
7
|
+
<span class="caret"></span>
|
|
8
|
+
</button>
|
|
9
|
+
<ul class="dropdown-menu">
|
|
10
|
+
<li><%= button_tag "Save & Add Another".html_safe, name: "commit_action", value: "new" %></li>
|
|
11
|
+
<li><%= button_tag "Save & Return to List".html_safe, name: "commit_action", value: "index" %></li>
|
|
12
|
+
</ul>
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
<div class="pull-right">
|
|
16
|
+
<% if controller.action_methods.include? "preview" %>
|
|
17
|
+
<div class="btn-group dropup" id="preview-submit">
|
|
18
|
+
<a href="#" class="btn btn-info js-preview-btn" data-window-options="width=1200,height=1000">Preview</a>
|
|
19
|
+
<button class="btn btn-info dropdown-toggle" data-toggle="dropdown">
|
|
20
|
+
<span class="caret"></span>
|
|
21
|
+
</button>
|
|
22
|
+
<ul class="dropdown-menu">
|
|
23
|
+
<li><a href="#" class="js-preview-btn" data-window-options="width=320,height=480">Mobile Portrait (320x480)</a></li>
|
|
24
|
+
<li><a href="#" class="js-preview-btn" data-window-options="width=480,height=320">Mobile Landscape (480x320)</a></li>
|
|
25
|
+
<li><a href="#" class="js-preview-btn" data-window-options="width=768,height=1024">Tablet Portrait (768x1024)</a></li>
|
|
26
|
+
<li><a href="#" class="js-preview-btn" data-window-options="width=1024,height=768">Tablet Landscape (1024x768)</a></li>
|
|
27
|
+
<li><a href="#" class="js-preview-btn" data-window-options="width=960,height=900">Small Desktop (960x900)</a></li>
|
|
28
|
+
</ul>
|
|
29
|
+
</div>
|
|
30
|
+
<% end %>
|
|
31
|
+
|
|
32
|
+
<% if record.persisted? %>
|
|
33
|
+
<%= link_to("View Live", record.public_path, class: "btn btn-success", target: "_blank") if record.public_path.present? %>
|
|
34
|
+
<%= link_to("Delete",
|
|
35
|
+
[:outpost, record],
|
|
36
|
+
class: "btn btn-danger",
|
|
37
|
+
method: :delete,
|
|
38
|
+
data: { confirm: "Click OK to delete this #{model.to_title}.\nClick CANCEL to return to editing." }
|
|
39
|
+
) %>
|
|
40
|
+
<% end %>
|
|
41
|
+
</div> <!-- pull-right -->
|
|
42
|
+
</div> <!-- container -->
|
|
43
|
+
</div> <!-- form-actions -->
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
<% content_for :footer do %>
|
|
47
|
+
<script>
|
|
48
|
+
field_manager = new outpost.FieldManager();
|
|
49
|
+
</script>
|
|
50
|
+
<% end %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
##
|
|
2
|
+
# This just adds a method to the FormBuilder which
|
|
3
|
+
# renders a "section" and passes in a few things:
|
|
4
|
+
#
|
|
5
|
+
# * f (which is the FormBuilder itself)
|
|
6
|
+
# * record (the object that the form builder is for)
|
|
7
|
+
# * extra (a block containing extra stuff to render)
|
|
8
|
+
#
|
|
9
|
+
# The section partial has to exist.
|
|
10
|
+
#
|
|
11
|
+
module ActionView
|
|
12
|
+
module Helpers
|
|
13
|
+
class FormBuilder
|
|
14
|
+
def section(partial, options={}, &block)
|
|
15
|
+
@template.render(
|
|
16
|
+
:partial => "/outpost/shared/sections/#{partial}",
|
|
17
|
+
:locals => {
|
|
18
|
+
:f => self,
|
|
19
|
+
:record => self.object,
|
|
20
|
+
:options => options,
|
|
21
|
+
:extra => block_given? ? @template.capture(&block) : ""
|
|
22
|
+
})
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#----------------------
|
|
26
|
+
|
|
27
|
+
def render_fields(partial, options={})
|
|
28
|
+
@template.render(
|
|
29
|
+
:partial => "/outpost/shared/fields/#{partial}_fields",
|
|
30
|
+
:locals => {
|
|
31
|
+
:f => self,
|
|
32
|
+
:index => self.object.object_id,
|
|
33
|
+
:options => options
|
|
34
|
+
})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#----------------------
|
|
38
|
+
|
|
39
|
+
def link_to_add_fields(association, options={})
|
|
40
|
+
association = association.to_s
|
|
41
|
+
partial = options[:partial] || association.singularize
|
|
42
|
+
title = options[:title] || "Add Another #{association.singularize.titleize}"
|
|
43
|
+
|
|
44
|
+
new_object = self.object.send(association).klass.new
|
|
45
|
+
id = new_object.object_id
|
|
46
|
+
|
|
47
|
+
fields = self.simple_fields_for(association, new_object, child_index: id) do |nf|
|
|
48
|
+
nf.render_fields(partial)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
@template.link_to(title, "#", class: "js-add-fields",
|
|
52
|
+
data: { id: id, build_target: options[:build_target], fields: fields.gsub("\n", "") })
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
#----------------------
|
|
56
|
+
|
|
57
|
+
def has_many_fields(association)
|
|
58
|
+
partial = association.to_s.singularize
|
|
59
|
+
fields = String.new
|
|
60
|
+
|
|
61
|
+
self.object.send(association).each do |obj|
|
|
62
|
+
fields << self.simple_fields_for(association, obj) do |nf|
|
|
63
|
+
nf.render_fields(partial)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
fields.html_safe
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
##
|
|
2
|
+
# Outpost::Breadcrumbs
|
|
3
|
+
#
|
|
4
|
+
# Super-simple breadcrumbs for you and me.
|
|
5
|
+
# Include it into a controller
|
|
6
|
+
#
|
|
7
|
+
# Arguments:
|
|
8
|
+
# Pairs of strings. Title of breadcrumb, Path
|
|
9
|
+
#
|
|
10
|
+
# Usage:
|
|
11
|
+
# In the controller:
|
|
12
|
+
#
|
|
13
|
+
# class PostsController < ApplicationController
|
|
14
|
+
# def new
|
|
15
|
+
# breadcrumb "New", outpost_new_post_path
|
|
16
|
+
# @post = Post.new
|
|
17
|
+
# end
|
|
18
|
+
# end
|
|
19
|
+
#
|
|
20
|
+
# This module then makes the "breadcrumbs" helper
|
|
21
|
+
# available to you (and me), which can be used in
|
|
22
|
+
# your view:
|
|
23
|
+
#
|
|
24
|
+
# <% breadcrumbs.each do |crumb| %>
|
|
25
|
+
# <%= link_to crumb.title, crumb.link %>
|
|
26
|
+
# <% end %>
|
|
27
|
+
#
|
|
28
|
+
# You can also define multiple breadcrumbs at once.
|
|
29
|
+
# Every 2 arguments is a new breadcrumb:
|
|
30
|
+
#
|
|
31
|
+
# breadcrumb "Edit", outpost_edit_post_path(@post.id), @post.title, outpost_post_path(@post)
|
|
32
|
+
#
|
|
33
|
+
# Don't want the crumb to be linked? Just leave the
|
|
34
|
+
# second argument off, or +nil+ if you're defining
|
|
35
|
+
# multiple breadcrumbs:
|
|
36
|
+
#
|
|
37
|
+
# breadcrumb "Edit", nil, @post.title
|
|
38
|
+
#
|
|
39
|
+
module Outpost
|
|
40
|
+
class Breadcrumb
|
|
41
|
+
attr_accessor :title, :link
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
#---------------
|
|
45
|
+
|
|
46
|
+
module Breadcrumbs
|
|
47
|
+
extend ActiveSupport::Concern
|
|
48
|
+
|
|
49
|
+
included do
|
|
50
|
+
attr_reader :breadcrumbs
|
|
51
|
+
|
|
52
|
+
if self < ActionController::Base
|
|
53
|
+
helper_method :breadcrumbs
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
#--------------
|
|
58
|
+
# Use this method to add breadcrumbs.
|
|
59
|
+
# See Outpost::Breadcrumbs
|
|
60
|
+
# for usage.
|
|
61
|
+
def breadcrumb(*args)
|
|
62
|
+
@breadcrumbs ||= []
|
|
63
|
+
|
|
64
|
+
args.each_slice(2).map do |pair|
|
|
65
|
+
crumb = Outpost::Breadcrumb.new
|
|
66
|
+
crumb.title = pair[0]
|
|
67
|
+
crumb.link = pair[1]
|
|
68
|
+
|
|
69
|
+
@breadcrumbs.push crumb
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
##
|
|
2
|
+
# Outpost::Config
|
|
3
|
+
#
|
|
4
|
+
# Define configuration for Outpost
|
|
5
|
+
module Outpost
|
|
6
|
+
class Config
|
|
7
|
+
DEFAULTS = {
|
|
8
|
+
:title_attributes => [:name, :title],
|
|
9
|
+
:excluded_form_fields => ["id", "created_at", "updated_at"],
|
|
10
|
+
:excluded_list_columns => [],
|
|
11
|
+
:user_class => "User",
|
|
12
|
+
:authentication_attribute => :email,
|
|
13
|
+
:preferences => [:order, :sort_mode]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# Pass a block to this method to define the configuration
|
|
17
|
+
# If no block is passed, config will be defaults
|
|
18
|
+
def self.configure
|
|
19
|
+
yield Outpost.config if block_given?
|
|
20
|
+
Outpost.config
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# An array of models that should show up
|
|
24
|
+
attr_writer :registered_models
|
|
25
|
+
def registered_models
|
|
26
|
+
@registered_models || []
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
attr_writer :preferences
|
|
30
|
+
def preferences
|
|
31
|
+
@preferences || DEFAULTS[:preferences]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
attr_writer :user_class
|
|
35
|
+
def user_class
|
|
36
|
+
@user_class || DEFAULTS[:user_class]
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Which attribute to use to authenticate
|
|
40
|
+
attr_writer :authentication_attribute
|
|
41
|
+
def authentication_attribute
|
|
42
|
+
@authentication_attribute || DEFAULTS[:authentication_attribute]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Which attributes to look at for `to_title`
|
|
46
|
+
attr_writer :title_attributes
|
|
47
|
+
def title_attributes
|
|
48
|
+
(@title_attributes ||= DEFAULTS[:title_attributes]) | [:simple_title]
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Ignore these attributes when building a basic form
|
|
52
|
+
attr_writer :excluded_form_fields
|
|
53
|
+
def excluded_form_fields
|
|
54
|
+
(@excluded_form_fields ||= []) | DEFAULTS[:excluded_form_fields]
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# Ignore these attributes when building a basic list
|
|
58
|
+
attr_writer :excluded_list_columns
|
|
59
|
+
def excluded_list_columns
|
|
60
|
+
(@excluded_list_columns ||= []) | DEFAULTS[:excluded_list_columns]
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
end
|