easy_static_pages 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: '069652e7a60c9e63bf06c522f9c118ee3bc7e427'
4
- data.tar.gz: 951f2de93cd6beabed4c69823d3e543e7c964915
3
+ metadata.gz: 934d3a56721b53c45eebcb3466baae8d4a4a321a
4
+ data.tar.gz: 2613088aa31e91a6686173351fd1ca5445f7653d
5
5
  SHA512:
6
- metadata.gz: df04ef75e737ba4d5af8ece288a6aa7af8d2e7db5d49595dc234b1635a705d724c10647bfb6e67bb2db18d900f647f8e9c096c62e8be2e218a6b73394877c430
7
- data.tar.gz: 4f74dc331fc783a9ed3a3e1e608b6b131c3a1d64fdef4251303b2136732cc2f1c232c914108ccd78319113863357574d23890380fc8afd5a2ad4862c2c51fde6
6
+ metadata.gz: 84611cd5d192a8b1d9c9fbd2148e08da1873f70954d9a1451b16493cda49a315e119a36cad4b288da11384463b3e6870fc74595ceac5b88df693c84d83ca0a23
7
+ data.tar.gz: 786e41dadf3c77b9b5b013a6f01a293e8d9a3de20f95c4e6999b0365df78b183f18cecaf2541a1675aa93d55d311129017adb90f0f25b1b2ac1b16c4924ef9ef
data/README.md CHANGED
@@ -20,6 +20,7 @@ Or install it yourself as:
20
20
  ```bash
21
21
  $ gem install easy_static_pages
22
22
  ```
23
+ ## Garantia da Qualidade [![Code Climate](https://codeclimate.com/github/gorails/easy_static_pages/badges/gpa.svg)](https://codeclimate.com/github/gorails/easy_static_pages)
23
24
 
24
25
  ## Contributing
25
26
  Contribution directions go here.
@@ -0,0 +1,3 @@
1
+ # Place all the behaviors and hooks related to the matching controller here.
2
+ # All this logic will automatically be available in application.js.
3
+ # You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,59 @@
1
+ class PagesController < ApplicationController
2
+ before_action :set_page, only: [:show, :edit, :update, :destroy]
3
+ before_action :authenticate_user!, except: %i(show)
4
+ load_and_authorize_resource except: %i(show)
5
+ # GET /pages
6
+ def index
7
+ @pages = Page.all
8
+ end
9
+
10
+ # GET /pages/1
11
+ def show
12
+ end
13
+
14
+ # GET /pages/new
15
+ def new
16
+ @page = Page.new
17
+ end
18
+
19
+ # GET /pages/1/edit
20
+ def edit
21
+ end
22
+
23
+ # POST /pages
24
+ def create
25
+ @page = Page.new(page_params)
26
+
27
+ if @page.save
28
+ redirect_to @page, notice: 'Page was successfully created.'
29
+ else
30
+ render :new
31
+ end
32
+ end
33
+
34
+ # PATCH/PUT /pages/1
35
+ def update
36
+ if @page.update(page_params)
37
+ redirect_to @page, notice: 'Page was successfully updated.'
38
+ else
39
+ render :edit
40
+ end
41
+ end
42
+
43
+ # DELETE /pages/1
44
+ def destroy
45
+ @page.destroy
46
+ redirect_to pages_url, notice: 'Page was successfully destroyed.'
47
+ end
48
+
49
+ private
50
+ # Use callbacks to share common setup or constraints between actions.
51
+ def set_page
52
+ @page = Page.find_by_permalink!(params[:id])
53
+ end
54
+
55
+ # Only allow a trusted parameter "white list" through.
56
+ def page_params
57
+ params.require(:page).permit(:name, :permalink, :content)
58
+ end
59
+ end
@@ -0,0 +1,35 @@
1
+ class PageDecorator < Draper::Decorator
2
+ delegate_all
3
+
4
+ def link_to_visualizar
5
+ h.link_to h.page_path(id: self.permalink),
6
+ :class => 'tn btn-info btn-sm',
7
+ :title => "Visualizar",
8
+ :style => "color: #FFF; float: none;" do
9
+ h.content_tag :span, class: 'fa fa-search' do
10
+ end
11
+ end
12
+ end
13
+
14
+ def link_to_editar
15
+ h.link_to h.edit_page_path(id: self.permalink),
16
+ :class => 'tn btn-warning btn-sm',
17
+ :title => "Alterar",
18
+ :style => "color: #FFF; float: none;" do
19
+ h.content_tag :span, class: 'fa fa-pencil' do
20
+ end
21
+ end
22
+ end
23
+
24
+ def link_to_excluir
25
+ h.link_to h.page_path(id: self.permalink),
26
+ :method => 'delete',
27
+ :class => 'tn btn-danger btn-sm',
28
+ :title => "Excluir",
29
+ :confirm => 'Deseja realmente excluir o registro?',
30
+ :style => "color: #FFF; float: none;" do
31
+ h.content_tag :span, class: 'fa fa-trash-o' do
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,2 @@
1
+ module PagesHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,7 @@
1
+ class Page < ApplicationRecord
2
+ validates_uniqueness_of :permalink
3
+
4
+ def to_param
5
+ permalink
6
+ end
7
+ end
@@ -0,0 +1,38 @@
1
+ <%= form_with(model: page, local: true) do |form| %>
2
+ <% if page.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(page.errors.count, "error") %> prohibited this page from being saved:</h2>
5
+
6
+ <ul>
7
+ <% page.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= form.label :name %>
16
+ <%= form.text_field :name, id: :page_name %>
17
+ </div>
18
+
19
+ <div class="field">
20
+ <%= form.label :permalink %>
21
+ <%= form.text_field :permalink, id: :page_permalink %>
22
+ </div>
23
+
24
+ <div class="field">
25
+ <%= form.label :content %>
26
+ <%= form.text_area :content, class: 'summernote_description', id: :page_content %>
27
+ </div>
28
+
29
+ <div class="actions">
30
+ <%= form.submit %>
31
+ </div>
32
+ <% end %>
33
+ <script>
34
+ $(document).ready(function () {
35
+ $('.summernote_description').summernote();
36
+ $('.summernote_local').summernote();
37
+ });
38
+ </script>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Page</h1>
2
+
3
+ <%= render 'form', page: @page %>
4
+
5
+ <%= link_to 'Show', @page %> |
6
+ <%= link_to 'Back', pages_path %>
@@ -0,0 +1,55 @@
1
+ <%= provide :page_title, I18n.t('link_categories.index.header') %>
2
+ <%= provide :breadcrumb do %>
3
+ <li><%= I18n.t('activerecord.models.link_category.other') %></li>
4
+ <% end %>
5
+
6
+ <main id="main-container" style="min-height: 530px;">
7
+ <div class="content bg-gray-lighter">
8
+ <div class="row items-push">
9
+ <div class="col-sm-7">
10
+ <h1 class="page-heading">
11
+ <%= t('link_categories.index.title') %>
12
+ </h1>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ <div class="content">
17
+ <div class="block">
18
+ <div class="block-header text-right">
19
+ <h3 class="block-title">
20
+ </h3>
21
+ <span>
22
+ <%= link_to I18n.t('link_categories.new.new'), new_page_path, class: 'btn btn-sm btn-square btn-success' %>
23
+ </span>
24
+ </div>
25
+ <div class="block-content">
26
+ <table class="table table-striped">
27
+ <thead>
28
+ <tr>
29
+ <th><%= t('activerecord.attributes.page.name') %></th>
30
+ <th><%= t('activerecord.attributes.page.permalink') %></th>
31
+ <th class="text-center" style="width: 150px;"><%= t 'misc.actions' %></th>
32
+ </tr>
33
+ </thead>
34
+ <tbody id='link_categories'>
35
+
36
+ <% @pages.each do |page| %>
37
+ <tr>
38
+ <td><%= page.name %></td>
39
+ <td><%= page.permalink %></td>
40
+ <td>
41
+
42
+ <% if current_user and current_user.admin? %>
43
+ <%= page.decorate.link_to_visualizar %>
44
+ <%= page.decorate.link_to_editar %>
45
+ <%= page.decorate.link_to_excluir %>
46
+ <% end %>
47
+ </td>
48
+ </tr>
49
+ <% end %>
50
+ </tbody>
51
+ </table>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </main>
@@ -0,0 +1,25 @@
1
+
2
+ <%= provide :page_title, I18n.t('link_categories.new.header') %>
3
+ <%= provide :breadcrumb do %>
4
+ <li><%= link_to t('activerecord.models.link_category.other'), link_categories_path %></li>
5
+ <li><%=t 'link_categories.new.header' %></li>
6
+ <% end %>
7
+
8
+ <main id="main-container" style="min-height: 530px;">
9
+ <div class="content bg-gray-lighter">
10
+ <div class="row items-push">
11
+ <div class="col-sm-7">
12
+ <h1 class="page-heading">
13
+ <%= I18n.t('link_categories.new.title') %>
14
+ </h1>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ <div class="content">
19
+ <div class="block">
20
+ <div class="block-content">
21
+ <%= render 'form', page: @page %>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </main>
@@ -0,0 +1,29 @@
1
+
2
+
3
+
4
+
5
+
6
+
7
+ <div class="content content-narrow">
8
+ <div class="block">
9
+ <div class="block-header bg-gray-lighter">
10
+ <ul class="block-options">
11
+ <li>
12
+ <button type="button" data-toggle="block-option" data-action="fullscreen_toggle"><i class="si si-size-fullscreen"></i></button>
13
+ </li>
14
+ <li>
15
+ <button type="button" data-toggle="block-option" data-action="refresh_toggle" data-action-mode="demo"><i class="si si-refresh"></i></button>
16
+ </li>
17
+ </ul>
18
+ </div>
19
+ <div class="block-content block-content-full">
20
+
21
+
22
+ <%= @page.content.html_safe %>
23
+
24
+
25
+
26
+
27
+ </div>
28
+ </div>
29
+ </div>
@@ -0,0 +1,47 @@
1
+ pt-BR:
2
+ pages:
3
+ default: &default
4
+ h1: Page
5
+ header: 'Lista de Pagina'
6
+ block_header: pages
7
+ index:
8
+ <<: *default
9
+ header: 'Lista de Paginas'
10
+ block_header: Paginas de Link
11
+ show:
12
+ <<: *default
13
+ header: 'Detalhes: %{resource}'
14
+ edit:
15
+ <<: *default
16
+ header: 'Editar: %{resource}'
17
+ new:
18
+ <<: *default
19
+ header: 'Cadastrar Pagina de Link'
20
+ create:
21
+ alert: 'Page não pode ser cadastrado.'
22
+ notice: 'Page cadastrado com sucesso.'
23
+ update:
24
+ alert: 'Page não pode ser atualizado.'
25
+ notice: 'Page atualizado com sucesso.'
26
+ destroy:
27
+ alert: 'Page não pode ser excluído.'
28
+ notice: 'Page excluído com sucesso.'
29
+ new:
30
+ new: 'Nova Pagina'
31
+ title: 'Adicionar Pagina'
32
+ header: 'Nova Pagina'
33
+ index:
34
+ title: 'Lista de Paginas de Links'
35
+ edit:
36
+ title: 'Editar Link Pagina'
37
+ show:
38
+ title: 'Exibir link Pagina'
39
+ remover: 'Tem certeza que vai excluir esta Pagina?'
40
+ form:
41
+ submit: 'Salvar Link Pagina'
42
+
43
+ helpers:
44
+ submit:
45
+ page:
46
+ create: 'Cadastrar %{model}'
47
+ update: 'Atualizar %{model}'
@@ -0,0 +1,12 @@
1
+ class CreatePages < ActiveRecord::Migration[5.1]
2
+ def change
3
+ create_table :pages do |t|
4
+ t.string :name
5
+ t.string :permalink
6
+ t.text :content
7
+
8
+ t.timestamps
9
+ end
10
+ add_index :pages, :permalink
11
+ end
12
+ end
@@ -1,4 +1,17 @@
1
1
  module EasyStaticPages
2
2
  class Engine < ::Rails::Engine
3
+ initializer :append_migrations do |app|
4
+ # This prevents migrations from being loaded twice from the inside of the
5
+ # gem itself (dummy test app)
6
+ if app.root.to_s !~ /#{root}/
7
+ config.paths['db/migrate'].expanded.each do |migration_path|
8
+ app.config.paths['db/migrate'] << migration_path
9
+ end
10
+ end
11
+ end
3
12
  end
4
13
  end
14
+
15
+
16
+
17
+
@@ -1,3 +1,3 @@
1
1
  module EasyStaticPages
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easy_static_pages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Associacao Goiana Ruby on Rails
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-03 00:00:00.000000000 Z
11
+ date: 2017-10-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: https://github.com/gorails/easy_static_pages
14
14
  email:
@@ -21,7 +21,20 @@ files:
21
21
  - README.md
22
22
  - Rakefile
23
23
  - app/assets/config/easy_static_pages_manifest.js
24
+ - app/assets/javascripts/pages.coffee
25
+ - app/controllers/pages_controller.rb
26
+ - app/decorators/page_decorator.rb
27
+ - app/helpers/pages_helper.rb
28
+ - app/models/application_record.rb
29
+ - app/models/page.rb
30
+ - app/views/pages/_form.html.erb
31
+ - app/views/pages/edit.html.erb
32
+ - app/views/pages/index.html.erb
33
+ - app/views/pages/new.html.erb
34
+ - app/views/pages/show.html.erb
35
+ - config/locales/pt-BR/views/pages.yml
24
36
  - config/routes.rb
37
+ - db/migrate/20171003021528_create_pages.rb
25
38
  - lib/easy_static_pages.rb
26
39
  - lib/easy_static_pages/engine.rb
27
40
  - lib/easy_static_pages/version.rb