panel 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +42 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/panel/index.js +2 -0
- data/app/assets/stylesheets/panel/base.scss +59 -0
- data/app/assets/stylesheets/panel/content.scss +5 -0
- data/app/assets/stylesheets/panel/flash.scss +24 -0
- data/app/assets/stylesheets/panel/footer.scss +13 -0
- data/app/assets/stylesheets/panel/forms.scss +86 -0
- data/app/assets/stylesheets/panel/header.scss +19 -0
- data/app/assets/stylesheets/panel/index.css +3 -0
- data/app/assets/stylesheets/panel/navigation.scss +34 -0
- data/app/assets/stylesheets/panel/options.scss +26 -0
- data/app/assets/stylesheets/panel/page.scss +7 -0
- data/app/assets/stylesheets/panel/pager.scss +39 -0
- data/app/assets/stylesheets/panel/tables.scss +40 -0
- data/app/helpers/panel/base_helper.rb +9 -0
- data/app/views/panel/_errors.html.erb +5 -0
- data/app/views/panel/_options.html.erb +8 -0
- data/config/locales/en.yml +18 -0
- data/config/locales/es.yml +18 -0
- data/lib/generators/panel/install_generator.rb +20 -0
- data/lib/generators/panel/resource_generator.rb +33 -0
- data/lib/generators/panel/templates/install/base_controller.rb +15 -0
- data/lib/generators/panel/templates/install/index.html.erb +0 -0
- data/lib/generators/panel/templates/install/pages_controller.rb +8 -0
- data/lib/generators/panel/templates/install/panel.html.erb +55 -0
- data/lib/generators/panel/templates/resource/_form.html.erb +7 -0
- data/lib/generators/panel/templates/resource/edit.html.erb +3 -0
- data/lib/generators/panel/templates/resource/index.html.erb +20 -0
- data/lib/generators/panel/templates/resource/new.html.erb +3 -0
- data/lib/generators/panel/templates/resource/resource_controller.rb +46 -0
- data/lib/panel.rb +5 -0
- data/lib/panel/engine.rb +4 -0
- data/lib/panel/version.rb +5 -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.ru +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/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/test_helper.rb +15 -0
- metadata +198 -0
@@ -0,0 +1,8 @@
|
|
1
|
+
<div id="options">
|
2
|
+
<%= form_tag request.fullpath, method: 'get', id: 'search' do %>
|
3
|
+
<%= text_field_tag :q, params[:q], placeholder: t('actions.search') %>
|
4
|
+
<% end %>
|
5
|
+
<% if new_path %>
|
6
|
+
<%= link_to t('actions.add'), new_path, class: 'button action' %>
|
7
|
+
<% end %>
|
8
|
+
</div>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
en:
|
2
|
+
actions:
|
3
|
+
search: "Search"
|
4
|
+
confirm: "¿Are you sure you want to destroy this record?"
|
5
|
+
actions: "Actions"
|
6
|
+
add: "Add"
|
7
|
+
edit: "Open"
|
8
|
+
destroy: "Destroy"
|
9
|
+
flash:
|
10
|
+
notice:
|
11
|
+
create: "Record added successfully."
|
12
|
+
update: "Record edited successfully."
|
13
|
+
destroy: "Record destroyed successfully."
|
14
|
+
layouts:
|
15
|
+
panel:
|
16
|
+
example: "Example"
|
17
|
+
logout: "Logout"
|
18
|
+
copyright: "Panel © %{year}"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
es:
|
2
|
+
actions:
|
3
|
+
search: "Buscar"
|
4
|
+
confirm: "¿Estás seguro que deseas eliminar este registro?"
|
5
|
+
actions: "Acciones"
|
6
|
+
add: "Agregar"
|
7
|
+
edit: "Abrir"
|
8
|
+
destroy: "Eliminar"
|
9
|
+
flash:
|
10
|
+
notice:
|
11
|
+
create: "Registro agregado correctamente."
|
12
|
+
update: "Registro editado correctamente."
|
13
|
+
destroy: "Registro eliminiado correctamente."
|
14
|
+
layouts:
|
15
|
+
panel:
|
16
|
+
example: "Ejemplo"
|
17
|
+
logout: "Salir"
|
18
|
+
copyright: "Panel © %{year}"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Panel
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def add_route
|
7
|
+
insert_into_file 'config/routes.rb', after: /(.*)::Application.routes.draw do/ do |match|
|
8
|
+
"#{match}\n\n namespace :panel do\n root to: 'pages#index'\n end"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_templates
|
13
|
+
template 'install/base_controller.rb', 'app/controllers/panel/base_controller.rb'
|
14
|
+
template 'install/pages_controller.rb', 'app/controllers/panel/pages_controller.rb'
|
15
|
+
template 'install/index.html.erb', 'app/views/panel/pages/index.html.erb'
|
16
|
+
copy_file 'install/panel.html.erb', 'app/views/layouts/panel.html.erb'
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Panel
|
2
|
+
class ResourceGenerator < Rails::Generators::NamedBase
|
3
|
+
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def add_route
|
7
|
+
insert_into_file 'config/routes.rb', after: /namespace :panel(.*)/ do |match|
|
8
|
+
"#{match}\n resources :#{table_name}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_scope
|
13
|
+
insert_into_file "app/models/#{singular_name}.rb", after: /class #{singular_name.camelize}(.*)/ do
|
14
|
+
"\n\n scope :search, ->(term) { where('', term: \"%\#{term}%\") }"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_templates
|
19
|
+
@param_singular = ":#{singular_name}"
|
20
|
+
@param_plural = ":#{plural_name}"
|
21
|
+
@instance_singular = "@#{singular_name}"
|
22
|
+
@instance_plural = "@#{plural_name}"
|
23
|
+
@index_path = "panel_#{index_helper}_path"
|
24
|
+
@params_method = "#{singular_name}_params"
|
25
|
+
template 'resource/resource_controller.rb', "app/controllers/panel/#{table_name}_controller.rb"
|
26
|
+
template 'resource/_form.html.erb', "app/views/panel/#{table_name}/_form.html.erb"
|
27
|
+
template 'resource/new.html.erb', "app/views/panel/#{table_name}/new.html.erb"
|
28
|
+
template 'resource/edit.html.erb', "app/views/panel/#{table_name}/edit.html.erb"
|
29
|
+
template 'resource/index.html.erb', "app/views/panel/#{table_name}/index.html.erb"
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
@@ -0,0 +1,55 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="<%= I18n.locale %>">
|
3
|
+
<head>
|
4
|
+
<title><%= @meta_title %></title>
|
5
|
+
<meta charset="utf-8" />
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= stylesheet_link_tag 'panel', media: 'all' %>
|
8
|
+
<%= javascript_include_tag 'panel' %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="page">
|
12
|
+
<div id="navigation">
|
13
|
+
<div class="holder">
|
14
|
+
<ul id="menu">
|
15
|
+
<li><%= link_to t('.example'), '#', class: 'button' %></li>
|
16
|
+
</ul>
|
17
|
+
<div id="session">
|
18
|
+
<%= link_to t('.logout'), '#', class: 'button' %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<% if @title.present? %>
|
23
|
+
<div id="header">
|
24
|
+
<div class="holder">
|
25
|
+
<h1><%= @title %></h1>
|
26
|
+
</div>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
29
|
+
<div id="content" class="holder">
|
30
|
+
<% unless flash.empty? %>
|
31
|
+
<div id="flash">
|
32
|
+
<% [:alert, :notice].each do |type| %>
|
33
|
+
<% if flash.key? type %>
|
34
|
+
<% case flash[type] %>
|
35
|
+
<% when String %>
|
36
|
+
<p class="<%= type %>"><%= flash[type].capitalize %></p>
|
37
|
+
<% when Array %>
|
38
|
+
<% flash[type].each do |message| %>
|
39
|
+
<p class="<%= type %>"><%= message.capitalize %></p>
|
40
|
+
<% end %>
|
41
|
+
<% end %>
|
42
|
+
<% end %>
|
43
|
+
<% end %>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
46
|
+
<%= yield %>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<div id="footer">
|
50
|
+
<div class="holder">
|
51
|
+
<p id="copyright"><%= t '.copyright', year: Time.now.year %></p>
|
52
|
+
</div>
|
53
|
+
</div>
|
54
|
+
</body>
|
55
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%% @meta_title = @title = <%= class_name %>.model_name.human(count: 2) %>
|
2
|
+
<%%= options new_panel_<%= singular_name %>_path %>
|
3
|
+
<table cellpadding="0" cellspacing="0">
|
4
|
+
<tr>
|
5
|
+
<th>#</th>
|
6
|
+
<th><%%= <%= class_name %>.human_attribute_name :created_at %></th>
|
7
|
+
<th class="actions"><%%= t 'actions.actions' %></th>
|
8
|
+
</tr>
|
9
|
+
<%% <%= @instance_plural %>.each do |<%= singular_name %>| %>
|
10
|
+
<tr>
|
11
|
+
<td><%%= <%= singular_name %>.id %></td>
|
12
|
+
<td><%%= l <%= singular_name %>.created_at %></td>
|
13
|
+
<td class="actions">
|
14
|
+
<%%= link_to t('actions.edit'), [:edit, :panel, <%= singular_name %>] %>
|
15
|
+
<%%= link_to t('actions.destroy'), [:panel, <%= singular_name %>], confirm: t('actions.confirm'), method: 'delete' %>
|
16
|
+
</td>
|
17
|
+
</tr>
|
18
|
+
<%% end %>
|
19
|
+
</table>
|
20
|
+
<%%= pager <%= @instance_plural %> %>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Panel
|
2
|
+
class <%= plural_name.camelize %>Controller < BaseController
|
3
|
+
|
4
|
+
def index
|
5
|
+
<%= @instance_plural %> = <%= class_name %>.search(params[:q]).page(params[:p].present? ? params[:p].to_i : 1).per(15)
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
<%= @instance_singular %> = <%= class_name %>.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def create
|
13
|
+
<%= @instance_singular %> = <%= class_name %>.new(<%= @params_method %>)
|
14
|
+
if <%= @instance_singular %>.save
|
15
|
+
redirect_to <%= @index_path %>, notice: t('flash.notice.create')
|
16
|
+
else
|
17
|
+
render :new
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
<%= @instance_singular %> = <%= class_name %>.find(params[:id])
|
23
|
+
end
|
24
|
+
|
25
|
+
def update
|
26
|
+
<%= @instance_singular %> = <%= class_name %>.find(params[:id])
|
27
|
+
if <%= @instance_singular %>.update_attributes(<%= @params_method %>)
|
28
|
+
redirect_to <%= @index_path %>, notice: t('flash.notice.update')
|
29
|
+
else
|
30
|
+
render :edit
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def destroy
|
35
|
+
<%= class_name %>.destroy params[:id]
|
36
|
+
redirect_to <%= @index_path %>, notice: t('flash.notice.destroy')
|
37
|
+
end
|
38
|
+
|
39
|
+
protected
|
40
|
+
|
41
|
+
def <%= @params_method %>
|
42
|
+
params.require(<%= @param_singular %>).permit()
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
data/lib/panel.rb
ADDED
data/lib/panel/engine.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 "panel"
|
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
|
+
|