simple_showcase_admin 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/simple_showcase_admin/categories_controller.rb +3 -6
- data/app/controllers/simple_showcase_admin/pages_controller.rb +52 -0
- data/app/models/simple_showcase_admin/page.rb +28 -0
- data/app/views/layouts/simple_showcase_admin/application.html.haml +14 -3
- data/app/views/simple_showcase_admin/pages/edit.html.haml +10 -0
- data/app/views/simple_showcase_admin/pages/index.html.haml +26 -0
- data/app/views/simple_showcase_admin/pages/new.html.haml +10 -0
- data/app/views/simple_showcase_admin/pages/show.html.haml +23 -0
- data/config/routes.rb +4 -0
- data/db/migrate/017_create_simple_showcase_admin_pages.rb +13 -0
- data/db/migrate/018_add_rendered_text_to_simple_showcase_admin_pages.rb +5 -0
- data/lib/simple_showcase_admin/version.rb +1 -1
- data/test/fixtures/simple_showcase_admin/pages.yml +13 -0
- data/test/unit/simple_showcase_admin/page_test.rb +9 -0
- metadata +14 -2
@@ -29,24 +29,21 @@ module SimpleShowcaseAdmin
|
|
29
29
|
def update
|
30
30
|
@category = SimpleShowcaseAdmin::Category.find(params[:id])
|
31
31
|
if @category.update_attributes(params[:category])
|
32
|
-
redirect_to category_path(@category), notice: 'Successfully updated
|
32
|
+
redirect_to category_path(@category), notice: 'Successfully updated category'
|
33
33
|
else
|
34
34
|
render :edit
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
38
|
def destroy
|
39
|
-
@
|
40
|
-
@
|
39
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:id])
|
40
|
+
@category.destroy
|
41
41
|
redirect_to categories_path
|
42
42
|
end
|
43
43
|
|
44
44
|
def sort
|
45
45
|
@category = SimpleShowcaseAdmin::Category.find(params[:id])
|
46
|
-
|
47
46
|
@category.row_order_position = params[:row_order_position]
|
48
|
-
puts "\n\n\n\n\n@category"
|
49
|
-
puts @category.inspect
|
50
47
|
@category.save!
|
51
48
|
|
52
49
|
render nothing: true
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module SimpleShowcaseAdmin
|
2
|
+
class PagesController < SimpleShowcaseAdmin::ApplicationController
|
3
|
+
def index
|
4
|
+
@pages = SimpleShowcaseAdmin::Page.rank(:row_order).page(params[:page]).per(10)
|
5
|
+
end
|
6
|
+
|
7
|
+
def new
|
8
|
+
@page = SimpleShowcaseAdmin::Page.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def edit
|
12
|
+
@page = SimpleShowcaseAdmin::Page.find(params[:id])
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
16
|
+
@page = SimpleShowcaseAdmin::Page.find(params[:id])
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
@page = SimpleShowcaseAdmin::Page.new(params[:page])
|
21
|
+
if @page.save
|
22
|
+
redirect_to [ @page], notice: 'Successfully created new page'
|
23
|
+
else
|
24
|
+
render :new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
@page = SimpleShowcaseAdmin::Page.find(params[:id])
|
30
|
+
if @page.update_attributes(params[:page])
|
31
|
+
redirect_to page_path(@page), notice: 'Successfully updated page'
|
32
|
+
else
|
33
|
+
render :edit
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def destroy
|
38
|
+
@page = SimpleShowcaseAdmin::Page.find(params[:id])
|
39
|
+
@page.destroy
|
40
|
+
redirect_to pages_path
|
41
|
+
end
|
42
|
+
|
43
|
+
def sort
|
44
|
+
@page = SimpleShowcaseAdmin::Page.find(params[:id])
|
45
|
+
|
46
|
+
@page.row_order_position = params[:row_order_position]
|
47
|
+
@page.save!
|
48
|
+
|
49
|
+
render nothing: true
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'friendly_id'
|
2
|
+
require 'redcarpet'
|
3
|
+
|
4
|
+
module SimpleShowcaseAdmin
|
5
|
+
class Page < ActiveRecord::Base
|
6
|
+
attr_accessible :text, :rendered_text, :title, :slug, :row_order_position
|
7
|
+
|
8
|
+
extend FriendlyId
|
9
|
+
friendly_id :title, use: :slugged
|
10
|
+
|
11
|
+
include RankedModel
|
12
|
+
ranks :row_order
|
13
|
+
|
14
|
+
validates_presence_of :title
|
15
|
+
|
16
|
+
before_save :render_body
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def render_body
|
21
|
+
renderer = Redcarpet::Render::HTML.new
|
22
|
+
extensions = {filter_html: false, safe_links_only: true, hard_wrap: true, autolink: true, no_intra_emphasis: true}
|
23
|
+
redcarpet = Redcarpet::Markdown.new(renderer, extensions)
|
24
|
+
self.rendered_text = redcarpet.render self.text
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
@@ -16,12 +16,23 @@
|
|
16
16
|
= link_to "Categories <b class='caret'></b>".html_safe, '#', :class => 'dropdown-toggle', "data-toggle" => "dropdown"
|
17
17
|
%ul.dropdown-menu
|
18
18
|
- if SimpleShowcaseAdmin::Category.all.count > 0
|
19
|
-
%li= link_to 'Manage Categories', [
|
19
|
+
%li= link_to 'Manage Categories', [:categories]
|
20
20
|
%li.divider
|
21
21
|
- else
|
22
|
-
%li= link_to 'Create a Category', [:new,
|
22
|
+
%li= link_to 'Create a Category', [:new, :category]
|
23
23
|
- SimpleShowcaseAdmin::Category.all.each do |c|
|
24
|
-
%li= link_to c.category, [
|
24
|
+
%li= link_to c.category, [c]
|
25
|
+
%ul.nav
|
26
|
+
%li.dropdown
|
27
|
+
= link_to "Pages <b class='caret'></b>".html_safe, '#', :class => 'dropdown-toggle', "data-toggle" => "dropdown"
|
28
|
+
%ul.dropdown-menu
|
29
|
+
- if SimpleShowcaseAdmin::Page.all.count > 0
|
30
|
+
%li= link_to 'Manage Pages', [:pages]
|
31
|
+
%li.divider
|
32
|
+
- else
|
33
|
+
%li= link_to 'Create a Page', [:new, :page]
|
34
|
+
- SimpleShowcaseAdmin::Page.all.each do |p|
|
35
|
+
%li= link_to p.title, [p]
|
25
36
|
|
26
37
|
- if SimpleShowcaseAdmin::Config.featured_image and !featured_photo_exists
|
27
38
|
%li.warning.label.label-important(rel="popover" data-content="You can select an image to be featured by editing a product and selecting 'Featured?' for one of the associated images." data-original-title="Please Select An Image To Be Featured.")
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%h1 Edit page
|
2
|
+
%br
|
3
|
+
%br
|
4
|
+
= simple_form_for(@page, :html => {:multipart => true, :class => 'form-horizontal'}, :url => page_path(@page)) do |f|
|
5
|
+
= f.error_notification
|
6
|
+
= f.input :title, input_html: { class: "span6" }
|
7
|
+
= f.input :text, input_html: { class: "span6" }
|
8
|
+
.form-actions
|
9
|
+
= f.button :submit, 'Save', :class => 'btn-primary'
|
10
|
+
= link_to 'Cancel', categories_path, class: 'btn'
|
@@ -0,0 +1,26 @@
|
|
1
|
+
%h1 Listing pages
|
2
|
+
|
3
|
+
= link_to 'New page', new_page_path, :class => 'btn-primary btn pull-right'
|
4
|
+
|
5
|
+
%br
|
6
|
+
%br
|
7
|
+
|
8
|
+
= paginate @pages
|
9
|
+
|
10
|
+
%table.table.table-bordered.table-striped#sortable{:data => {update_url: sort_pages_path}}
|
11
|
+
%thead
|
12
|
+
%tr
|
13
|
+
%th page
|
14
|
+
%th  
|
15
|
+
|
16
|
+
%tbody
|
17
|
+
- @pages.each do |page|
|
18
|
+
%tr{data: {item_id: "#{page.id}"}, class: 'item'}
|
19
|
+
%td= page.title
|
20
|
+
%td
|
21
|
+
= link_to 'View', page_path(page), :class => 'btn'
|
22
|
+
= link_to 'Edit', edit_page_path(page), :class => 'btn btn-primary'
|
23
|
+
= link_to 'Delete', page_path(page), :confirm => 'Are you sure?', :method => :delete, :class => 'btn btn-danger'
|
24
|
+
|
25
|
+
= paginate @pages
|
26
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
%h1 New Page
|
2
|
+
%br
|
3
|
+
%br
|
4
|
+
= simple_form_for([@page], :html => {:multipart => true, :class => 'form-horizontal'}) do |f|
|
5
|
+
= f.error_notification
|
6
|
+
= f.input :title, input_html: { class: "span6" }
|
7
|
+
= f.input :text, input_html: { class: "span6" }
|
8
|
+
.form-actions
|
9
|
+
= f.button :submit, 'Save', :class => 'btn-primary'
|
10
|
+
= link_to 'Cancel', pages_path, class: 'btn'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
%h1 #{@page.title.titleize} Page
|
2
|
+
|
3
|
+
%br
|
4
|
+
%br
|
5
|
+
|
6
|
+
%table.table.table-bordered.table-striped
|
7
|
+
%thead
|
8
|
+
%tr
|
9
|
+
%th page
|
10
|
+
%th Date Created
|
11
|
+
%th  
|
12
|
+
|
13
|
+
%tbody
|
14
|
+
%tr
|
15
|
+
%td= @page.title
|
16
|
+
%td=l @page.created_at
|
17
|
+
%td
|
18
|
+
= link_to 'Edit', edit_page_path(@page), :class => 'btn btn-primary'
|
19
|
+
= link_to 'Delete', page_path(@page), :confirm => 'Are you sure?', :method => :delete, :class => 'btn btn-danger'
|
20
|
+
|
21
|
+
%br
|
22
|
+
%br
|
23
|
+
|
data/config/routes.rb
CHANGED
@@ -10,6 +10,10 @@ SimpleShowcaseAdmin::Engine.routes.draw do
|
|
10
10
|
post :sort, on: :collection
|
11
11
|
end
|
12
12
|
end
|
13
|
+
resources :pages do
|
14
|
+
post :sort, on: :collection
|
15
|
+
end
|
16
|
+
|
13
17
|
resources :details
|
14
18
|
resources :sessions
|
15
19
|
resources :password_resets, path: 'password-reset', as: 'password_resets'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateSimpleShowcaseAdminPages < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :simple_showcase_admin_pages do |t|
|
4
|
+
t.text :text
|
5
|
+
t.string :title
|
6
|
+
t.string :slug
|
7
|
+
t.integer :row_order
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
add_index :simple_showcase_admin_pages, :slug
|
12
|
+
end
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_showcase_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -363,6 +363,7 @@ files:
|
|
363
363
|
- app/controllers/simple_showcase_admin/categories_controller.rb
|
364
364
|
- app/controllers/simple_showcase_admin/details_controller.rb
|
365
365
|
- app/controllers/simple_showcase_admin/items_controller.rb
|
366
|
+
- app/controllers/simple_showcase_admin/pages_controller.rb
|
366
367
|
- app/controllers/simple_showcase_admin/password_resets_controller.rb
|
367
368
|
- app/controllers/simple_showcase_admin/sessions_controller.rb
|
368
369
|
- app/helpers/simple_showcase_admin/application_helper.rb
|
@@ -370,6 +371,7 @@ files:
|
|
370
371
|
- app/mailers/simple_showcase_admin/user_mailer.rb
|
371
372
|
- app/models/simple_showcase_admin/category.rb
|
372
373
|
- app/models/simple_showcase_admin/item.rb
|
374
|
+
- app/models/simple_showcase_admin/page.rb
|
373
375
|
- app/models/simple_showcase_admin/photo.rb
|
374
376
|
- app/models/simple_showcase_admin/user.rb
|
375
377
|
- app/uploaders/image_uploader.rb
|
@@ -385,6 +387,10 @@ files:
|
|
385
387
|
- app/views/simple_showcase_admin/items/index.html.haml
|
386
388
|
- app/views/simple_showcase_admin/items/new.html.haml
|
387
389
|
- app/views/simple_showcase_admin/items/show.html.haml
|
390
|
+
- app/views/simple_showcase_admin/pages/edit.html.haml
|
391
|
+
- app/views/simple_showcase_admin/pages/index.html.haml
|
392
|
+
- app/views/simple_showcase_admin/pages/new.html.haml
|
393
|
+
- app/views/simple_showcase_admin/pages/show.html.haml
|
388
394
|
- app/views/simple_showcase_admin/password_resets/edit.html.haml
|
389
395
|
- app/views/simple_showcase_admin/password_resets/new.html.haml
|
390
396
|
- app/views/simple_showcase_admin/sessions/new.html.haml
|
@@ -408,6 +414,8 @@ files:
|
|
408
414
|
- db/migrate/014_add_landscape_to_photos.rb
|
409
415
|
- db/migrate/015_add_row_order_to_category.rb
|
410
416
|
- db/migrate/016_add_row_order_to_items.rb
|
417
|
+
- db/migrate/017_create_simple_showcase_admin_pages.rb
|
418
|
+
- db/migrate/018_add_rendered_text_to_simple_showcase_admin_pages.rb
|
411
419
|
- lib/generators/simple_showcase_admin/install_generator.rb
|
412
420
|
- lib/simple_showcase_admin/configuration.rb
|
413
421
|
- lib/simple_showcase_admin/engine.rb
|
@@ -445,9 +453,11 @@ files:
|
|
445
453
|
- test/dummy/Rakefile
|
446
454
|
- test/dummy/README.rdoc
|
447
455
|
- test/dummy/script/rails
|
456
|
+
- test/fixtures/simple_showcase_admin/pages.yml
|
448
457
|
- test/integration/navigation_test.rb
|
449
458
|
- test/simple_showcase_admin_test.rb
|
450
459
|
- test/test_helper.rb
|
460
|
+
- test/unit/simple_showcase_admin/page_test.rb
|
451
461
|
homepage:
|
452
462
|
licenses: []
|
453
463
|
post_install_message:
|
@@ -501,6 +511,8 @@ test_files:
|
|
501
511
|
- test/dummy/Rakefile
|
502
512
|
- test/dummy/README.rdoc
|
503
513
|
- test/dummy/script/rails
|
514
|
+
- test/fixtures/simple_showcase_admin/pages.yml
|
504
515
|
- test/integration/navigation_test.rb
|
505
516
|
- test/simple_showcase_admin_test.rb
|
506
517
|
- test/test_helper.rb
|
518
|
+
- test/unit/simple_showcase_admin/page_test.rb
|