th_simple_content_management 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Njk4NGJlZjNlM2U1MDEwY2RiYWE3NWViZGU3ODVmN2NjMjhiNWI3Ng==
4
+ MTk3MGVhNjQyOGJkZjJhMWYxYjRlYjNmOTAyNTcxNTk1MWEwOGE2Ng==
5
5
  data.tar.gz: !binary |-
6
- MjgyNzU1ZThlYjkwODQ5NGY1OWM4YTM2MGMxNDNlZjdhMjczNTEzYQ==
6
+ MWZlZDkwZjhlNjMwOTA4NWFiMGQ4YTk4YmNiNDljNmUwYTRhM2UyMQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZmFmNDRkNTEwZWMwMTE4ZjljNzM1ZDcyYTAzMTQ0YjRmZWY5NTAxNjBkZWMy
10
- YTU5ZDBjMDcwN2ZmNmQzYTFlZmViMjIyN2IwYTk3ZjEyZTY3Nzk4MTM3NzU2
11
- MmQ2MDk1NzkwMGMxMTA2NjFjMzI4OGQzNTA2MGYwODFiNTA1OTE=
9
+ ODNiZWE1MDY4NWI5MDgyMDNkMWEyY2Y1MDBlNDBjMWU1NDJkMjVhNGM2YWEx
10
+ NjNhNTM4NmRiN2ViYmQ5NmFkOWZhZjk3Y2UwYjRlMTgyYWJjODM1MjFkOTJh
11
+ ZGE5OWY1NmMxMjM0NGMxMDJkZGY0MWFhZmQ3NmI1ZTg5NWQ3NjY=
12
12
  data.tar.gz: !binary |-
13
- MDFhZmM5Mjg5NzI4Y2IyZDc3ZDE0MGU0ZjMyZjM3Njc3ZDcwZDIzMzk0ZDg5
14
- N2M3YjYwMTRhODkwMTQ2NmJmNTZhMWU0YTlmZTg5MTc0NmI1MTRjZTgzMmI1
15
- NDFjYTdkY2VlYzk0ZGIxZThlYWM2ZWI3YjQxYmQzZjg5NjAyNzQ=
13
+ ZmI3MTEwZDJhNjg4ZWEyYzA3YzU0M2EwN2E2OGQ4ODU0Y2NjMDQyMTQxMWNm
14
+ ZjM5ZGZhNDU5NTlhMDI0ZWQyYjUzN2FlNDkwZjM5YWQxZGZkNGRmODM0NDJl
15
+ OTg4OGYzYzgzMzhjYzI5MGMwMjgxZTg1YjUxZGM4ZjdmOTc3YTk=
@@ -0,0 +1,8 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //
4
+ //= require bootstrap
5
+ // require holder // don't know this one
6
+ //
7
+ //= require_tree ./simple_content_management
8
+ //= require_self
@@ -0,0 +1,24 @@
1
+ //= require jquery.ui.sortable
2
+
3
+ $(function() {
4
+ if(!$("#simple_content_management_simple_menu_items_index").length)
5
+ return;
6
+ $("#simple-menu-items-draggable-nav").sortable({
7
+ update: function(e, ui) {
8
+ var id = ui.item.find("a[data-id]").data("id");
9
+ var nextPosition = ui.item.prevAll("li").length;
10
+ $.ajax({
11
+ type: "POST",
12
+ url: $(this).data("insert-at-path").replace("smi_id", id).replace("smi_position", nextPosition),
13
+ data: { _method: "PUT" },
14
+ dataType: "json",
15
+ success: function(responseData) {
16
+ console.log(responseData);
17
+ for(var i=0; i<responseData.length; i++) {
18
+ $("a[data-id="+responseData[i]["id"]+"]").data("position", responseData[i]["position"]);
19
+ }
20
+ }
21
+ });
22
+ }
23
+ }).disableSelection();
24
+ })
@@ -0,0 +1,39 @@
1
+ //= require bootstrap-tagmanager
2
+ //= require redactor-rails
3
+
4
+ $(function() {
5
+ if(!$("#simple_content_management_simple_pages_new, #simple_content_management_simple_pages_edit").length)
6
+ return;
7
+ $tagsmanager = $("[data-simple-routes-list]");
8
+ $tagsmanager.tagsManager({
9
+ prefilled: $tagsmanager.val().split(/,/g),
10
+ preventSubmitOnEnter: true,
11
+ typeahead: false,
12
+ hiddenTagListName: $tagsmanager.prop("name"),
13
+ validator: function(pathname) { return !pathname.match(/(?:^\/|\s)/); }
14
+ }).prop("name", "").val("");
15
+ var $hiddenTagsField = $(":input[name='simple_content_management_simple_page[simple_routes_list]']");
16
+
17
+ var updateRoutesList = false;
18
+ var updateTitle = false;
19
+
20
+ var $title = $("#simple_content_management_simple_page_title");
21
+
22
+ $("#simple_content_management_simple_page_name").bind({
23
+ focus: function() {
24
+ updateRoutesList = $hiddenTagsField .val() == "" && $tagsmanager.val() == "";
25
+ updateTitle = $title.val() == "";
26
+ },
27
+ "keyup keydown keypress change blur": function() {
28
+ if(updateTitle)
29
+ $title.val($(this).val());
30
+ if(updateRoutesList)
31
+ $tagsmanager.val($(this).val().toLowerCase().replace(/[^a-z0-9]+/g, "-"));
32
+ },
33
+ blur: function() {
34
+ // if(updateRoutesList)
35
+ // $tagsmanager.trigger(jQuery.Event("keypress", { which: 44 }));
36
+ updateRoutesList = updateTitle = false;
37
+ }
38
+ })
39
+ })
@@ -0,0 +1,16 @@
1
+ class SimpleContentManagement::SimpleMenuItemsController < InheritedResources::Base
2
+ defaults :resource_class => SimpleContentManagement::SimpleMenuItem
3
+ include SimpleAdminPanel::ControllerExtensions
4
+ actions :all, except: :show
5
+ custom_actions resource: [:insert_at]
6
+
7
+ def insert_at
8
+ resource.insert_at params[:position].to_i
9
+ render json: resource_class.all.map{ |smi| { id: smi.id, position: smi.position } }.to_json
10
+ end
11
+
12
+ protected
13
+ def collection
14
+ @simple_menu_items = resource_class.ordered
15
+ end
16
+ end
@@ -1,8 +1,21 @@
1
- class SimpleContentManagement::SimplePagesController < ApplicationController
2
- def show
3
- @simple_route = SimpleContentManagement::SimpleRoute.find_by_path params[:path]
4
- return render file: "#{Rails.root}/public/410", layout: false, status: 410 if @simple_route.is_deleted
5
- @simple_page = @simple_route.simple_page
6
- return render file: "#{Rails.root}/public/410", layout: false, status: 410 if @simple_page.is_deleted
1
+ class SimpleContentManagement::SimplePagesController < InheritedResources::Base
2
+ defaults :resource_class => SimpleContentManagement::SimplePage
3
+ include SimpleAdminPanel::ControllerExtensions
4
+ alias_method_chain :collection, :search_and_pagination
5
+ custom_actions resource: [:create_simple_menu_item]
6
+
7
+ def create_simple_menu_item
8
+ route = resource.simple_routes.first
9
+ simple_menu_item = SimpleContentManagement::SimpleMenuItem.create uri: "/#{route.path}.html", name: resource.name
10
+ if simple_menu_item.persisted?
11
+ flash[:notice] = "Pagina toegevoegd aan menu."
12
+ else
13
+ flash[:error] = "Kon pagina niet toevoegen aan menu: #{simple_menu_item.errors.full_messages.to_sentence}"
14
+ end
15
+ redirect_to resource_path
16
+ end
17
+
18
+ def end_of_association_chain
19
+ resource_class.active
7
20
  end
8
21
  end
@@ -2,7 +2,7 @@ class SimpleContentManagement::SimpleMenuItem < ActiveRecord::Base
2
2
  validates_presence_of :name, :uri
3
3
  validates_inclusion_of :is_target_blank, in: [ true, false ]
4
4
 
5
- attr_accessible :name, :uri, :is_target_blank
5
+ attr_accessible :name, :uri, :is_target_blank, :position
6
6
 
7
7
  scope :ordered, order("position")
8
8
 
@@ -0,0 +1,10 @@
1
+ <%= simple_form_for [:admin, @simple_menu_item], url: @simple_menu_item.new_record? ? admin_simple_menu_items_path : admin_simple_menu_item_path(@simple_menu_item) do |f| %>
2
+ <%= f.input :name %>
3
+ <%= f.input :uri %>
4
+ <%= f.input :is_target_blank, as: :radio %>
5
+
6
+ <div class="form-actions">
7
+ <%= f.button :submit %>
8
+ <%= link_to "Verwijderen", resource_path, class: "btn btn-danger", method: :delete, confirm: "Weet je zeker dat je deze knop wil verwijderen?" if @simple_menu_item.persisted? %>
9
+ </div>
10
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render "form" %>
@@ -0,0 +1,16 @@
1
+ <div class="navbar">
2
+ <div class="navbar-inner">
3
+ <ul class="nav" id="simple-menu-items-draggable-nav", data-insert-at-path="<%= insert_at_resource_path(resource_class.new.tap{ |smi| def smi.id; "smi_id"; end }, position: "smi_position") %>">
4
+ <%= content_tag_for :li, @simple_menu_items do |simple_menu_item| %>
5
+ <%= link_to simple_menu_item.name, edit_resource_path(simple_menu_item), data: { id: simple_menu_item.id, position: simple_menu_item.position } %>
6
+ <% end %>
7
+ </ul>
8
+ </div>
9
+ </div>
10
+
11
+ <ul>
12
+ <li>Klik op aanmaken om een knop toe te voegen.</li>
13
+ <li>Sleep knoppen om de volgorde te veranderen.</li>
14
+ <li>Klik om een knop om deze te bewerken of te verwijderen.</li>
15
+ <li>Het is niet mogelijk "ingebouwde" knoppen, zoals veilingen, inloggen en uitloggen, te beheren.</li>
16
+ </ul>
@@ -0,0 +1 @@
1
+ <%= render "form" %>
@@ -0,0 +1,10 @@
1
+ <%= simple_form_for [:admin, @simple_page], url: @simple_page.new_record? ? admin_simple_pages_path : admin_simple_page_path(@simple_page) do |f| %>
2
+ <%= f.input :name, hint: "Wordt o.a. gebruikt als standaard label voor knoppen en links naar deze pagina." %>
3
+ <%= f.input :simple_routes_list, input_html: { data: { simple_routes_list: true } }, wrapper_html: { class: "simple-routes-list" }, hint: "Eén of meerdere URL paden." %>
4
+ <%= f.input :title, hint: "Wordt gebruikt als HTML titel." %>
5
+ <%= f.input :content_html, input_html: { cols: 120, rows: 7, class: "input-xxlarge redactor" } %>
6
+
7
+ <div class="form-actions">
8
+ <%= f.button :submit %>
9
+ </div>
10
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render "form" %>
@@ -0,0 +1,5 @@
1
+ <%= table_list_for @simple_pages, sortable: false, resource_class: SimpleContentManagement::SimplePage do |t| %>
2
+ <%= t.item :name, as: :link %>
3
+ <%= t.item :title, as: :link %>
4
+ <%= t.item as: :actions %>
5
+ <% end %>
@@ -0,0 +1 @@
1
+ <%= render "form" %>
@@ -1 +1,9 @@
1
+ <% content_for :actions do %>
2
+ <li class="pull-right"><%= link_to icon("plus") + " Voeg toe aan menu", create_simple_menu_item_resource_path(@simple_page), method: :post, class: "btn btn-mini#{" disabled" if @simple_page.has_simple_menu_item?}" %></li>
3
+ <% end %>
4
+
5
+ <% @simple_page.simple_routes.each do |simple_route| %>
6
+ <%= link_to "/#{simple_route.path}.html", "/#{simple_route.path}.html", class: "btn btn-small", target: "_blank" %>
7
+ <% end %>
8
+
1
9
  <%= @simple_page.content_html.html_safe %>
data/config/routes.rb CHANGED
@@ -1,3 +1,10 @@
1
- SimpleContentManagement::Engine.routes.draw do
2
- get "*path", to: "simple_content_management/simple_pages#show", constraints: SimpleContentManagement::SimplePagesConstraint.instance
1
+ Rails.application.routes.draw do
2
+ namespace :simple_content_management, path: "admin" do
3
+ resources :simple_pages do
4
+ post :create_simple_menu_item, on: :member
5
+ end
6
+ resources :simple_menu_items do
7
+ put :insert_at, on: :member
8
+ end
9
+ end
3
10
  end
@@ -1,3 +1,3 @@
1
1
  module SimpleContentManagement
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: th_simple_content_management
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Hinloopen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-07 00:00:00.000000000 Z
11
+ date: 2013-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,62 @@ dependencies:
38
38
  - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: redactor-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: inherited_resources
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: th_simple_admin_panel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: th_simple_data_presentation
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
41
97
  description: A rails engine containing CMS features.
42
98
  email:
43
99
  - toby@kutcomputers.nl
@@ -45,12 +101,22 @@ executables: []
45
101
  extensions: []
46
102
  extra_rdoc_files: []
47
103
  files:
48
- - app/assets/javascripts/simple_content_management/application.js
49
- - app/assets/stylesheets/simple_content_management/application.css
104
+ - app/assets/javascripts/simple_content_management/simple_menu_items.js
105
+ - app/assets/javascripts/simple_content_management/simple_pages.js
106
+ - app/assets/javascripts/simple_content_management.js
107
+ - app/controllers/simple_content_management/simple_menu_items_controller.rb
50
108
  - app/controllers/simple_content_management/simple_pages_controller.rb
51
109
  - app/models/simple_content_management/simple_menu_item.rb
52
110
  - app/models/simple_content_management/simple_page.rb
53
111
  - app/models/simple_content_management/simple_route.rb
112
+ - app/views/simple_content_management/simple_menu_items/_form.html.erb
113
+ - app/views/simple_content_management/simple_menu_items/edit.html.erb
114
+ - app/views/simple_content_management/simple_menu_items/index.html.erb
115
+ - app/views/simple_content_management/simple_menu_items/new.html.erb
116
+ - app/views/simple_content_management/simple_pages/_form.html.erb
117
+ - app/views/simple_content_management/simple_pages/edit.html.erb
118
+ - app/views/simple_content_management/simple_pages/index.html.erb
119
+ - app/views/simple_content_management/simple_pages/new.html.erb
54
120
  - app/views/simple_content_management/simple_pages/show.html.erb
55
121
  - config/locales/simple_content_management/nl/models/simple_menu_item.yml
56
122
  - config/locales/simple_content_management/nl/models/simple_page.yml
@@ -1,15 +0,0 @@
1
- // This is a manifest file that'll be compiled into application.js, which will include all the files
2
- // listed below.
3
- //
4
- // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
- // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
- //
7
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
- // the compiled file.
9
- //
10
- // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
- // GO AFTER THE REQUIRES BELOW.
12
- //
13
- //= require jquery
14
- //= require jquery_ujs
15
- //= require_tree .
@@ -1,13 +0,0 @@
1
- /*
2
- * This is a manifest file that'll be compiled into application.css, which will include all the files
3
- * listed below.
4
- *
5
- * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
- * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
- *
8
- * You're free to add application-wide styles to this file and they'll appear at the top of the
9
- * compiled file, but it's generally better to create a new file per style scope.
10
- *
11
- *= require_self
12
- *= require_tree .
13
- */