simple_showcase_admin 0.0.1
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.rdoc +3 -0
- data/Rakefile +40 -0
- data/app/assets/javascripts/simple_showcase_admin/application.js +23 -0
- data/app/assets/javascripts/simple_showcase_admin/jquery.photo_featured.js +3 -0
- data/app/assets/javascripts/simple_showcase_admin/jquery.photos.js +18 -0
- data/app/assets/stylesheets/simple_showcase_admin/application.css.scss +123 -0
- data/app/controllers/simple_showcase_admin/application_controller.rb +10 -0
- data/app/controllers/simple_showcase_admin/categories_controller.rb +44 -0
- data/app/controllers/simple_showcase_admin/details_controller.rb +20 -0
- data/app/controllers/simple_showcase_admin/items_controller.rb +48 -0
- data/app/controllers/simple_showcase_admin/password_resets_controller.rb +40 -0
- data/app/controllers/simple_showcase_admin/sessions_controller.rb +25 -0
- data/app/helpers/simple_showcase_admin/application_helper.rb +12 -0
- data/app/helpers/simple_showcase_admin/items_helper.rb +15 -0
- data/app/mailers/simple_showcase_admin/user_mailer.rb +12 -0
- data/app/models/simple_showcase_admin/category.rb +20 -0
- data/app/models/simple_showcase_admin/item.rb +24 -0
- data/app/models/simple_showcase_admin/photo.rb +13 -0
- data/app/models/simple_showcase_admin/user.rb +25 -0
- data/app/uploaders/image_uploader.rb +22 -0
- data/app/views/layouts/simple_showcase_admin/application.html.haml +47 -0
- data/app/views/simple_showcase_admin/categories/edit.html.haml +9 -0
- data/app/views/simple_showcase_admin/categories/index.html.haml +26 -0
- data/app/views/simple_showcase_admin/categories/new.html.haml +9 -0
- data/app/views/simple_showcase_admin/categories/show.html.haml +49 -0
- data/app/views/simple_showcase_admin/details/edit.html.haml +11 -0
- data/app/views/simple_showcase_admin/details/show.html.haml +7 -0
- data/app/views/simple_showcase_admin/items/_photos.html.haml +12 -0
- data/app/views/simple_showcase_admin/items/edit.html.haml +26 -0
- data/app/views/simple_showcase_admin/items/index.html.haml +48 -0
- data/app/views/simple_showcase_admin/items/new.html.haml +24 -0
- data/app/views/simple_showcase_admin/items/show.html.haml +15 -0
- data/app/views/simple_showcase_admin/password_resets/edit.html.haml +9 -0
- data/app/views/simple_showcase_admin/password_resets/new.html.haml +8 -0
- data/app/views/simple_showcase_admin/sessions/new.html.haml +19 -0
- data/app/views/simple_showcase_admin/user_mailer/reset_password_email.html.haml +8 -0
- data/config/initializers/simple_form.rb +177 -0
- data/config/initializers/sorcery.rb +386 -0
- data/config/routes.rb +13 -0
- data/db/migrate/001_sorcery_core.rb +15 -0
- data/db/migrate/002_sorcery_remember_me.rb +15 -0
- data/db/migrate/003_sorcery_reset_password.rb +17 -0
- data/db/migrate/004_add_slug_to_users.rb +7 -0
- data/db/migrate/005_add_first_name_to_users.rb +6 -0
- data/db/migrate/006_create_categories.rb +9 -0
- data/db/migrate/007_create_items.rb +10 -0
- data/db/migrate/008_create_photos.rb +9 -0
- data/db/migrate/009_add_category_id_to_items.rb +6 -0
- data/db/migrate/010_add_slug_to_categories.rb +7 -0
- data/db/migrate/011_add_slug_to_items.rb +6 -0
- data/db/migrate/012_add_item_id_to_photos.rb +5 -0
- data/db/migrate/013_add_featured_to_photos.rb +5 -0
- data/db/migrate/014_add_landscape_to_photos.rb +5 -0
- data/lib/generators/simple_showcase_admin/install_generator.rb +69 -0
- data/lib/simple_showcase_admin/configuration.rb +11 -0
- data/lib/simple_showcase_admin/engine.rb +21 -0
- data/lib/simple_showcase_admin/version.rb +3 -0
- data/lib/simple_showcase_admin.rb +5 -0
- data/lib/tasks/simple_showcase_admin_tasks.rake +4 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/simple_showcase_admin_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +477 -0
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2013 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
begin
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
require 'rdoc/task'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
require 'rdoc/rdoc'
|
|
11
|
+
require 'rake/rdoctask'
|
|
12
|
+
RDoc::Task = Rake::RDocTask
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
17
|
+
rdoc.title = 'SimpleShowcaseAdmin'
|
|
18
|
+
rdoc.options << '--line-numbers'
|
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
24
|
+
load 'rails/tasks/engine.rake'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Bundler::GemHelper.install_tasks
|
|
29
|
+
|
|
30
|
+
require 'rake/testtask'
|
|
31
|
+
|
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
|
33
|
+
t.libs << 'lib'
|
|
34
|
+
t.libs << 'test'
|
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
|
36
|
+
t.verbose = false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
task :default => :test
|
|
@@ -0,0 +1,23 @@
|
|
|
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 bootstrap-dropdown
|
|
16
|
+
//= require bootstrap-alert
|
|
17
|
+
//= require bootstrap-tooltip
|
|
18
|
+
//= require bootstrap-popover
|
|
19
|
+
//= require_tree .
|
|
20
|
+
|
|
21
|
+
$(document).ready(function() {
|
|
22
|
+
$("li[rel=popover]").hover().popover({placement:'bottom'});
|
|
23
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
$(function() {
|
|
2
|
+
$('form a.add_child').click(function() {
|
|
3
|
+
var template = $('#photos_fields_template').html();
|
|
4
|
+
var regexp = new RegExp('new_photos', 'g');
|
|
5
|
+
var id = $('.destroy').last().attr('name');
|
|
6
|
+
id = id.replace(/\D/g, "");
|
|
7
|
+
var new_id = parseInt(id) + 1;
|
|
8
|
+
|
|
9
|
+
$(this).parent().before(template.replace(regexp, new_id));
|
|
10
|
+
return false;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
$('form a.remove_child').on('click', function() {
|
|
14
|
+
$(this).parents('.photo-fields').children('input[class=destroy]').attr('value', true);
|
|
15
|
+
$(this).parents('.photo-fields').hide();
|
|
16
|
+
return false;
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
@import 'compass';
|
|
2
|
+
|
|
3
|
+
@function e($raw-css) {
|
|
4
|
+
@return #{$raw-css};
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
body {
|
|
8
|
+
padding: 60px;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
h1{
|
|
12
|
+
margin-bottom: 30px;
|
|
13
|
+
width: 75%;
|
|
14
|
+
display: inline-block;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
.table {
|
|
19
|
+
clear: both;
|
|
20
|
+
border: none;
|
|
21
|
+
|
|
22
|
+
td.center {
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
tr > td:last-child{
|
|
27
|
+
text-align: right;
|
|
28
|
+
width: 162px;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.help-block{
|
|
33
|
+
text-indent: 15px;
|
|
34
|
+
color: darken(#8bb863, 20%);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.notice-badge {
|
|
38
|
+
padding: 0 6px;
|
|
39
|
+
font-size: 11px;
|
|
40
|
+
font-weight: normal;
|
|
41
|
+
white-space: nowrap;
|
|
42
|
+
color: white;
|
|
43
|
+
background-color: #BD362F;
|
|
44
|
+
-webkit-border-radius: 9px;
|
|
45
|
+
-moz-border-radius: 9px;
|
|
46
|
+
border-radius: 9px;
|
|
47
|
+
position: absolute;
|
|
48
|
+
top: 3px;
|
|
49
|
+
right: 275px;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@import 'compass_twitter_bootstrap';
|
|
53
|
+
|
|
54
|
+
.table {
|
|
55
|
+
-webkit-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
56
|
+
-moz-box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
57
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
58
|
+
|
|
59
|
+
td {
|
|
60
|
+
vertical-align: middle;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.navbar {
|
|
65
|
+
|
|
66
|
+
.brand {
|
|
67
|
+
padding: 4px 20px 4px;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.navbar-inner {
|
|
71
|
+
-webkit-border-radius: 0;
|
|
72
|
+
-moz-border-radius: 0;
|
|
73
|
+
-ms-border-radius: 0;
|
|
74
|
+
-o-border-radius: 0;
|
|
75
|
+
border-radius: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.pull-right {
|
|
79
|
+
|
|
80
|
+
> li {
|
|
81
|
+
|
|
82
|
+
> a {
|
|
83
|
+
padding: 10px 0 11px 20px;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.warning {
|
|
89
|
+
margin-top: 8px;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
textarea {
|
|
94
|
+
max-width: 769px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.item-photo {
|
|
98
|
+
max-width: 460px;
|
|
99
|
+
margin-bottom: 9px;
|
|
100
|
+
border-bottom: 1px solid #ddd;
|
|
101
|
+
|
|
102
|
+
img {
|
|
103
|
+
margin-bottom: 6px;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.remove_child {
|
|
107
|
+
float:right;
|
|
108
|
+
margin-top: -5px;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.add_child {
|
|
113
|
+
margin-top: -15px;
|
|
114
|
+
}
|
|
115
|
+
.hint {
|
|
116
|
+
padding-top: 5px;
|
|
117
|
+
color: #aaa;
|
|
118
|
+
|
|
119
|
+
.red {
|
|
120
|
+
color: #EE5F5B;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
class ApplicationController < ActionController::Base
|
|
3
|
+
protect_from_forgery
|
|
4
|
+
before_filter :require_login
|
|
5
|
+
|
|
6
|
+
def not_authenticated
|
|
7
|
+
redirect_to login_path, notice: 'Please login to access the administration area'
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
class CategoriesController < SimpleShowcaseAdmin::ApplicationController
|
|
3
|
+
def index
|
|
4
|
+
@categories = SimpleShowcaseAdmin::Category.page(params[:page]).per(10)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def new
|
|
8
|
+
@category = SimpleShowcaseAdmin::Category.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def edit
|
|
12
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:id])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def show
|
|
16
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:id])
|
|
17
|
+
@items = Item.where(category_id: @category.id).page(params[:page]).per(10)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create
|
|
21
|
+
@category = SimpleShowcaseAdmin::Category.new(params[:category])
|
|
22
|
+
if @category.save
|
|
23
|
+
redirect_to [ @category], notice: 'Successfully created new category'
|
|
24
|
+
else
|
|
25
|
+
render :new
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def update
|
|
30
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:id])
|
|
31
|
+
if @category.update_attributes(params[:category])
|
|
32
|
+
redirect_to category_path(@category), notice: 'Successfully updated catagory'
|
|
33
|
+
else
|
|
34
|
+
render :edit
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def destroy
|
|
39
|
+
@catagory = SimpleShowcaseAdmin::Category.find(params[:id])
|
|
40
|
+
@catagory.destroy
|
|
41
|
+
redirect_to categories_path
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
class DetailsController < SimpleShowcaseAdmin::ApplicationController
|
|
3
|
+
def edit
|
|
4
|
+
@user = SimpleShowcaseAdmin::User.find(params[:id])
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def update
|
|
8
|
+
@user = SimpleShowcaseAdmin::User.find(params[:id])
|
|
9
|
+
if @user.update_attributes(params[:user])
|
|
10
|
+
redirect_to detail_path(@user), :notice => "You have successfully updated your personal details"
|
|
11
|
+
else
|
|
12
|
+
render :edit
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def show
|
|
17
|
+
@user = SimpleShowcaseAdmin::User.find(params[:id])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
class ItemsController < SimpleShowcaseAdmin::ApplicationController
|
|
3
|
+
def new
|
|
4
|
+
@item = SimpleShowcaseAdmin::Item.new
|
|
5
|
+
@photos = @item.photos.new
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def edit
|
|
9
|
+
@item = SimpleShowcaseAdmin::Item.find(params[:id])
|
|
10
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:category_id])
|
|
11
|
+
@photos = @item.photos.blank? ? @item.photos.new : @item.photos
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def show
|
|
15
|
+
@item = SimpleShowcaseAdmin::Item.find(params[:id])
|
|
16
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:category_id])
|
|
17
|
+
@photos = @item.photos
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create
|
|
21
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:category_id])
|
|
22
|
+
@item = @category.items.new(params[:item])
|
|
23
|
+
if @item.save
|
|
24
|
+
redirect_to category_item_path(@category, @item), notice: "Successful created #{@item.title.downcase}"
|
|
25
|
+
else
|
|
26
|
+
@photos = @item.photos.blank? ? @item.photos.new : @item.photos
|
|
27
|
+
render :new
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def update
|
|
32
|
+
@category = SimpleShowcaseAdmin::Category.find(params[:category_id])
|
|
33
|
+
@item = SimpleShowcaseAdmin::Item.find(params[:id])
|
|
34
|
+
if @item.update_attributes!(params[:item])
|
|
35
|
+
redirect_to category_item_path(@category, @item)
|
|
36
|
+
else
|
|
37
|
+
@photos = @item.photos.blank? ? @item.photos.new : @item.photos
|
|
38
|
+
render :edit
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def destroy
|
|
43
|
+
@item = SimpleShowcaseAdmin::Item.find(params[:id])
|
|
44
|
+
@item.destroy
|
|
45
|
+
redirect_to category_path(params[:category_id]), notice: "Successfully deleted #{@item.title}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
class PasswordResetsController < SimpleShowcaseAdmin::ApplicationController
|
|
3
|
+
skip_before_filter :require_login
|
|
4
|
+
|
|
5
|
+
# request password reset.
|
|
6
|
+
# you get here when the user entered his email in the reset password form and submitted it.
|
|
7
|
+
def create
|
|
8
|
+
@user = SimpleShowcaseAdmin::User.find_by_email(params[:email])
|
|
9
|
+
|
|
10
|
+
# This line sends an email to the user with instructions on how to reset their password (a url with a random token)
|
|
11
|
+
@user.deliver_reset_password_instructions! if @user
|
|
12
|
+
|
|
13
|
+
# Tell the user instructions have been sent whether or not email was found.
|
|
14
|
+
# This is to not leak information to attackers about which emails exist in the system.
|
|
15
|
+
redirect_to(login_path, :notice => 'Instructions have been sent to your email.')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# This is the reset password form.
|
|
19
|
+
def edit
|
|
20
|
+
@user = SimpleShowcaseAdmin::User.load_from_reset_password_token(params[:id])
|
|
21
|
+
@token = params[:id]
|
|
22
|
+
not_authenticated unless @user
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# This action fires when the user has sent the reset password form.
|
|
26
|
+
def update
|
|
27
|
+
@token = params[:token]
|
|
28
|
+
@user = SimpleShowcaseAdmin::User.load_from_reset_password_token(params[:token])
|
|
29
|
+
not_authenticated unless @user
|
|
30
|
+
# the next line makes the password confirmation validation work
|
|
31
|
+
@user.password_confirmation = params[:user][:password_confirmation]
|
|
32
|
+
# the next line clears the temporary token and updates the password
|
|
33
|
+
if @user.change_password!(params[:user][:password])
|
|
34
|
+
redirect_to(root_path, :notice => 'Password was successfully updated.')
|
|
35
|
+
else
|
|
36
|
+
render :action => "edit"
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
class SessionsController < SimpleShowcaseAdmin::ApplicationController
|
|
3
|
+
skip_before_filter :require_login
|
|
4
|
+
|
|
5
|
+
def new
|
|
6
|
+
logout
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def create
|
|
10
|
+
user = login(params[:email], params[:password], params[:remember_me])
|
|
11
|
+
if user
|
|
12
|
+
redirect_back_or_to root_path, :notice => "Logged in as #{ current_user.email }"
|
|
13
|
+
else
|
|
14
|
+
redirect_to login_path, :notice => 'Email or password was invalid'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def destroy
|
|
19
|
+
logout
|
|
20
|
+
if !current_user
|
|
21
|
+
redirect_to login_path, :notice => 'Logged out!'
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module SimpleShowcaseAdmin
|
|
2
|
+
module ApplicationHelper
|
|
3
|
+
def featured_photo_exists
|
|
4
|
+
Photo.where(featured: true).count > 0
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def markdown(text)
|
|
8
|
+
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(:filter_html => true, :safe_links_only => true, :hard_wrap => true), autolink: true, no_intra_emphasis: true)
|
|
9
|
+
markdown.render(text).html_safe
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|