manage 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +64 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/manage/application.js +3 -0
- data/app/assets/javascripts/manage/resource.js +2 -0
- data/app/assets/stylesheets/manage/application.css +13 -0
- data/app/assets/stylesheets/manage/resource.css +4 -0
- data/app/controllers/manage/admin_users_controller.rb +3 -0
- data/app/controllers/manage/application_controller.rb +19 -0
- data/app/controllers/manage/dashboards_controller.rb +4 -0
- data/app/controllers/manage/resource_controller.rb +17 -0
- data/app/controllers/manage/responder.rb +12 -0
- data/app/controllers/manage/sessions_controller.rb +6 -0
- data/app/helpers/manage/application_helper.rb +4 -0
- data/app/helpers/manage/resource_helper.rb +7 -0
- data/app/views/layouts/manage/_main_menu.html.slim +7 -0
- data/app/views/layouts/manage/application.html.slim +27 -0
- data/app/views/layouts/manage/sign_in.html.slim +24 -0
- data/app/views/manage/admin_users/_form.html.slim +6 -0
- data/app/views/manage/resource/_form.html.slim +4 -0
- data/app/views/manage/resource/_index.html.slim +17 -0
- data/app/views/manage/resource/edit.html.slim +7 -0
- data/app/views/manage/resource/index.html.slim +6 -0
- data/app/views/manage/resource/new.html.slim +4 -0
- data/app/views/manage/resource/show.html.slim +11 -0
- data/app/views/sessions/new.html.slim +11 -0
- data/config/locales/bg.yml +25 -0
- data/config/locales/en.yml +21 -0
- data/config/routes.rb +8 -0
- data/lib/manage/engine.rb +9 -0
- data/lib/manage/version.rb +3 -0
- data/lib/manage.rb +3 -0
- data/lib/tasks/manage_tasks.rake +4 -0
- data/test/controllers/manage/resource_controller_test.rb +9 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -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/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/helpers/manage/resource_helper_test.rb +6 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/manage_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +279 -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
@@ -0,0 +1,64 @@
|
|
1
|
+
= Manage
|
2
|
+
|
3
|
+
Admin backend based on http://iain.nl/backends-in-rails-3-1
|
4
|
+
|
5
|
+
== Installing
|
6
|
+
|
7
|
+
Add the engine
|
8
|
+
|
9
|
+
to Gemfile
|
10
|
+
|
11
|
+
gem 'manage'
|
12
|
+
|
13
|
+
|
14
|
+
to routes.rb yourapp/config/routes.rb:
|
15
|
+
|
16
|
+
mount Manage::Engine, at: "/manage"
|
17
|
+
|
18
|
+
== Defining resource for administration
|
19
|
+
|
20
|
+
|
21
|
+
Add the resource to your app routes.rb yourapp/config/routes.rb:
|
22
|
+
|
23
|
+
Manage::Engine.routes.draw do
|
24
|
+
resources :cities
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
Create controller in your application yourapp/app/controllers/manage/cities_controller.rb
|
29
|
+
|
30
|
+
class Manage::CitiesController < Manage::ResourceController
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
=== View overriding
|
35
|
+
You can overrede the views in
|
36
|
+
|
37
|
+
app/views/manage/countries
|
38
|
+
|
39
|
+
* _index.html.slim
|
40
|
+
* _form.html_slim
|
41
|
+
* edit.html.slim
|
42
|
+
* new.html.slim
|
43
|
+
* show.html.slim
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
== Authorization
|
49
|
+
In your app do
|
50
|
+
|
51
|
+
rails generate devise AdminUser
|
52
|
+
|
53
|
+
delete "devise_for :admin_users" from routes.rb
|
54
|
+
|
55
|
+
|
56
|
+
Create an admin user. The users benefit from the devise password validation/generation but doesn't use the devise controllers.
|
57
|
+
|
58
|
+
|
59
|
+
AdminUser.create(email: 'admin@example.com', password: '11223344', password_confirmation: '11223344')
|
60
|
+
|
61
|
+
|
62
|
+
== License
|
63
|
+
|
64
|
+
This project rocks and uses MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Manage'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
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
|
+
*/
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Manage::ApplicationController < ActionController::Base
|
2
|
+
# before_filter :authenticate_admin_user!
|
3
|
+
before_filter :authenticate_admin
|
4
|
+
|
5
|
+
def authenticate_admin
|
6
|
+
authenticate_or_request_with_http_basic do |username, password|
|
7
|
+
@current_user = AdminUser.where(email: username).first
|
8
|
+
return request_http_basic_authentication if @current_user.blank?
|
9
|
+
return request_http_basic_authentication unless @current_user.valid_password?(password)
|
10
|
+
@current_user
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
helper_method :current_user
|
15
|
+
def current_user
|
16
|
+
@current_user
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_dependency "manage/application_controller"
|
2
|
+
|
3
|
+
class Manage::ResourceController < Manage::ApplicationController
|
4
|
+
inherit_resources
|
5
|
+
|
6
|
+
self.responder = Manage::Responder
|
7
|
+
|
8
|
+
layout 'manage/application'
|
9
|
+
|
10
|
+
has_scope :page, default: 1
|
11
|
+
|
12
|
+
respond_to :html
|
13
|
+
|
14
|
+
def permitted_params
|
15
|
+
params.permit!
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
h1 Main menu
|
2
|
+
p Override me in /views/layouts/manage/main_menu
|
3
|
+
ul
|
4
|
+
li link_to City.model_name.human(count: 2), manage.cities_path
|
5
|
+
li link_to 'users', users_path
|
6
|
+
li = link_to AdminUser.model_name.human(count:2), admin_users_path
|
7
|
+
li link_to 'terms', main_app.about_us_pages_path
|
@@ -0,0 +1,27 @@
|
|
1
|
+
html
|
2
|
+
head
|
3
|
+
title Manage
|
4
|
+
= stylesheet_link_tag "manage/application", media: "all"
|
5
|
+
= javascript_include_tag "manage/application"
|
6
|
+
= csrf_meta_tags
|
7
|
+
|
8
|
+
body class="#{controller.action_name} #{controller_path.gsub(/[-\/]/, '-')} simple" data-locale=I18n.locale
|
9
|
+
header
|
10
|
+
= current_user.email
|
11
|
+
= render '/layouts/manage/main_menu'
|
12
|
+
row
|
13
|
+
#flash
|
14
|
+
- flash.each do |key, value|
|
15
|
+
- key = 'info' if key == :notice
|
16
|
+
.alert_wrapper data-dismiss="alert"
|
17
|
+
div(class="alert alert-#{key} #{key}")
|
18
|
+
button(type="button" class="close" data-dismiss="alert") ×
|
19
|
+
- if value.is_a?(Array)
|
20
|
+
- value.each do |element|
|
21
|
+
p #{element.html_safe}
|
22
|
+
- else
|
23
|
+
p #{value.html_safe}
|
24
|
+
.clearfix
|
25
|
+
|
26
|
+
|
27
|
+
= yield
|
@@ -0,0 +1,24 @@
|
|
1
|
+
html
|
2
|
+
head
|
3
|
+
title Manage
|
4
|
+
= stylesheet_link_tag "manage/application", media: "all"
|
5
|
+
= javascript_include_tag "manage/application"
|
6
|
+
= csrf_meta_tags
|
7
|
+
|
8
|
+
body class="#{controller.action_name} #{controller_path.gsub(/[-\/]/, '-')} simple" data-locale=I18n.locale
|
9
|
+
row
|
10
|
+
#flash
|
11
|
+
- flash.each do |key, value|
|
12
|
+
- key = 'info' if key == :notice
|
13
|
+
.alert_wrapper data-dismiss="alert"
|
14
|
+
div(class="alert alert-#{key} #{key}")
|
15
|
+
button(type="button" class="close" data-dismiss="alert") ×
|
16
|
+
- if value.is_a?(Array)
|
17
|
+
- value.each do |element|
|
18
|
+
p #{element.html_safe}
|
19
|
+
- else
|
20
|
+
p #{value.html_safe}
|
21
|
+
.clearfix
|
22
|
+
|
23
|
+
|
24
|
+
= yield
|
@@ -0,0 +1,17 @@
|
|
1
|
+
table
|
2
|
+
thead
|
3
|
+
tr
|
4
|
+
- attributes.each do |attr|
|
5
|
+
th= resource_class.human_attribute_name(attr)
|
6
|
+
th
|
7
|
+
tbody
|
8
|
+
- collection.each do |resource|
|
9
|
+
tr[resource]
|
10
|
+
- attributes.each do |attr|
|
11
|
+
td= resource.public_send(attr).to_s.truncate(20)
|
12
|
+
td
|
13
|
+
= link_to t('manage.actions.show'), [resource]
|
14
|
+
|
|
15
|
+
= link_to t('manage.actions.edit'), [:edit, resource]
|
16
|
+
|
|
17
|
+
= link_to t('manage.actions.destroy'), [resource], method: :delete, data: { confirm: t('manage.confirmations.Are you sure')}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
nav
|
2
|
+
= link_to t('manage.actions.index', model: resource_class.model_name.human(count: 2)), resource.class
|
3
|
+
= link_to t('manage.actions.edit'), resource.class
|
4
|
+
|
5
|
+
article
|
6
|
+
dl
|
7
|
+
- resource_class.attribute_names.each do |attr|
|
8
|
+
dt= resource_class.human_attribute_name(attr)
|
9
|
+
dd= resource.public_send(attr)
|
10
|
+
|
11
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
h2 = t('.sign_in')
|
2
|
+
|
3
|
+
= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f|
|
4
|
+
.form-inputs
|
5
|
+
= f.input :email, :required => false, :autofocus => true
|
6
|
+
= f.input :password, :required => false
|
7
|
+
= f.input :remember_me, :as => :boolean if devise_mapping.rememberable?
|
8
|
+
.form-actions
|
9
|
+
= f.button :submit, t('devise.users.registrations.login')
|
10
|
+
|
11
|
+
= render "devise/users/shared/links"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
bg:
|
2
|
+
manage:
|
3
|
+
actions:
|
4
|
+
show: Покажи
|
5
|
+
new: Създай %{model}
|
6
|
+
edit: Редакция
|
7
|
+
destroy: Изтрии
|
8
|
+
index: Списък с %{model}
|
9
|
+
edit:
|
10
|
+
title: Редактирай %{model}
|
11
|
+
new:
|
12
|
+
title: Създаване на %{model}
|
13
|
+
confirmations:
|
14
|
+
Are you sure: Шуре ли сте?
|
15
|
+
flash:
|
16
|
+
actions:
|
17
|
+
create:
|
18
|
+
notice: 'Създадохме %{resource_name}'
|
19
|
+
alert: 'Не успешно създаване на %{resource_name}'
|
20
|
+
update:
|
21
|
+
notice: 'Обновихме %{resource_name}.'
|
22
|
+
alert: 'Не успешно обновяване на %{resource_name}'
|
23
|
+
destroy:
|
24
|
+
notice: 'Изтрихме %{resource_name}'
|
25
|
+
alert: 'Неуспешно изтриване на %{resource_name}'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
en:
|
2
|
+
manage:
|
3
|
+
actions:
|
4
|
+
show: Show
|
5
|
+
edit: Edit
|
6
|
+
destroy: Delete
|
7
|
+
edit:
|
8
|
+
title: Edit %{model}
|
9
|
+
confirmations:
|
10
|
+
Are you sure: Are you sure?
|
11
|
+
flash:
|
12
|
+
actions:
|
13
|
+
create:
|
14
|
+
notice: '%{resource_name} was successfully created.'
|
15
|
+
alert: '%{resource_name} could not be created.'
|
16
|
+
update:
|
17
|
+
notice: '%{resource_name} was successfully updated.'
|
18
|
+
alert: '%{resource_name} could not be updated.'
|
19
|
+
destroy:
|
20
|
+
notice: '%{resource_name} was successfully destroyed.'
|
21
|
+
alert: '%{resource_name} could not be destroyed.'
|
data/config/routes.rb
ADDED
data/lib/manage.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
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
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
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
|
+
*/
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
|
6
|
+
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/test/dummy/bin/rake
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
require 'rails/all'
|
4
|
+
|
5
|
+
Bundler.require(*Rails.groups)
|
6
|
+
require "manage"
|
7
|
+
|
8
|
+
module Dummy
|
9
|
+
class Application < Rails::Application
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
15
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
16
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
17
|
+
|
18
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
|
+
# config.i18n.default_locale = :de
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# SQLite version 3.x
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
6
|
+
development:
|
7
|
+
adapter: sqlite3
|
8
|
+
database: db/development.sqlite3
|
9
|
+
pool: 5
|
10
|
+
timeout: 5000
|
11
|
+
|
12
|
+
# Warning: The database defined as "test" will be erased and
|
13
|
+
# re-generated from your development database when you run "rake".
|
14
|
+
# Do not set this db to the same as development or production.
|
15
|
+
test:
|
16
|
+
adapter: sqlite3
|
17
|
+
database: db/test.sqlite3
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
20
|
+
|
21
|
+
production:
|
22
|
+
adapter: sqlite3
|
23
|
+
database: db/production.sqlite3
|
24
|
+
pool: 5
|
25
|
+
timeout: 5000
|