flatpages 0.0.2 → 1.0.0

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: 7bc92a2ba12abd862ca9f31cf82fa48d52c1707e
4
- data.tar.gz: 30464d7cd3c0a91d4e6616ba5eaae0b8d2c9d9b1
3
+ metadata.gz: 564b6cc40d42034e3ebb34c675fc0c683c9bc919
4
+ data.tar.gz: f735bfad0e3bba3ad3249ca1c1456da27f94f7b4
5
5
  SHA512:
6
- metadata.gz: 28e4b8f33d3175f42cfaff76101d1dc9771a9953a19aa89fc29c200f93121fc8752ef76fa6e9c069f50f49747e3deeb193ab9c7a132756e1dafeca47488ec8fa
7
- data.tar.gz: 69b220d2c2e343205464f941d687130377e753295ff3f1a3cc9fac895d3821218e1d8c27d05009e508e2d1ef4fab603b6dda77ab9e82ca700b94f755d7af68c7
6
+ metadata.gz: e5cab32d70fb56ba895310dc534fc2f9d4432b85efcba95e02d43d5893554caeb344d6d1a6fdbc5af3a2fd15e888feccfa68aa9fa2e3966f40da6b611a4f7869
7
+ data.tar.gz: 33d8aa97525ccce0392fef91d6fc52f0b6c3d22d78b5abc824cf126d0a828f3ded1aed2cdefbb042a4bc1c5622cb24b8bf8b259478cde73dfd89de4e5ac5f3c9
data/README.md CHANGED
@@ -1,31 +1,32 @@
1
1
  # Flatpages
2
2
 
3
- TODO: Write a gem description
3
+ Simple gem for save static pages in database
4
4
 
5
5
  ## Installation
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```ruby
10
+ gem 'ckeditor'
10
11
  gem 'flatpages'
11
12
  ```
12
13
 
13
- And then execute:
14
+ Install and configure ckeditor
15
+ Then run
14
16
 
15
- $ bundle
17
+ ```
18
+ rails generate flatpages:install .
19
+ ```
16
20
 
17
- Or install it yourself as:
21
+ And add to your routes.rb before root route
18
22
 
19
- $ gem install flatpages
23
+ ```ruby
24
+ mount Flatpages::Engine => '/'
25
+ ```
20
26
 
21
27
  ## Usage
22
28
 
23
- TODO: Write usage instructions here
24
-
25
- ## Contributing
26
-
27
- 1. Fork it ( https://github.com/[my-github-username]/flatpages/fork )
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Add some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create a new Pull Request
29
+ For make link to static page use route like this
30
+ ```
31
+ flatpages_engine.flatpage_path('contacts')
32
+ ```
@@ -3,6 +3,7 @@ class FlatpagesController < ApplicationController
3
3
  #
4
4
  # Returns text/html
5
5
  def show
6
- @page = Page.friendly.find(params[:id])
6
+ @page = Flatpage.find_by_path(params[:path])
7
+ raise ActiveRecord::RecordNotFound unless @page.present?
7
8
  end
8
9
  end
@@ -1,6 +1,4 @@
1
1
  class Flatpage < ActiveRecord::Base
2
- extend FriendlyId
3
- friendly_id :name, :use => :slugged
4
-
5
- validates_presence_of :name, :slug
2
+ validates :name, presence: true
3
+ validates :path, presence: true
6
4
  end
@@ -0,0 +1,2 @@
1
+ <h1><%= @page.name %></h1>
2
+ <%= @page.text.html_safe %>
@@ -1,3 +1,3 @@
1
1
  Flatpages::Engine.routes.draw do
2
- resources :flatpages, only: :show, path: ''
2
+ get '/:path', to: 'flatpages#show', as: 'flatpage'
3
3
  end
@@ -2,6 +2,5 @@ require 'rails'
2
2
 
3
3
  module Flatpages
4
4
  class Engine < Rails::Engine
5
- isolate_namespace Flatpages
6
5
  end
7
6
  end
@@ -1,3 +1,3 @@
1
1
  module Flatpages
2
- VERSION = "0.0.2"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,34 @@
1
+ require 'rails/generators/active_record'
2
+
3
+ module Flatpages
4
+ module Generators
5
+ class InstallGenerator < ActiveRecord::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ desc "Installs flatpages"
9
+
10
+ def self.source_root
11
+ @_source_root ||= File.expand_path("../templates", __FILE__)
12
+ end
13
+
14
+ def self.next_migration_number(path)
15
+ unless @prev_migration_nr
16
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
17
+ else
18
+ @prev_migration_nr += 1
19
+ end
20
+ @prev_migration_nr.to_s
21
+ end
22
+
23
+ def setup_directory
24
+ empty_directory "app/admin"
25
+
26
+ template 'active_admin/flatpage.rb.erb', 'app/admin/flatpage.rb'
27
+ end
28
+
29
+ def copy_migrations
30
+ migration_template "create_flatpage.rb", "db/migrate/create_flatpage.rb"
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,20 @@
1
+ ActiveAdmin.register Flatpage do
2
+ permit_params :name, :text, :path
3
+
4
+ index do
5
+ column :name
6
+ column :path
7
+
8
+ actions
9
+ end
10
+
11
+ form do |f|
12
+ f.inputs do
13
+ f.input :name
14
+ f.input :path
15
+ f.input :text, :as => :ckeditor
16
+ end
17
+
18
+ f.actions
19
+ end
20
+ end
@@ -2,10 +2,8 @@ class CreateFlatpage < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :flatpages do |t|
4
4
  t.string :name, null: false
5
- t.string :slug, null: false
5
+ t.string :path, null: false
6
6
  t.text :text
7
7
  end
8
-
9
- add_index :flatpages, :slug, unique: true
10
8
  end
11
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flatpages
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Semyon Pupkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-31 00:00:00.000000000 Z
11
+ date: 2015-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -66,12 +66,15 @@ files:
66
66
  - Rakefile
67
67
  - app/controllers/flatpages_controller.rb
68
68
  - app/models/flatpage.rb
69
+ - app/views/flatpages/show.erb
69
70
  - config/routes.rb
70
- - db/migrate/20140808055521_create_flatpage.rb
71
71
  - flatpages.gemspec
72
72
  - lib/flatpages.rb
73
73
  - lib/flatpages/engine.rb
74
74
  - lib/flatpages/version.rb
75
+ - lib/generators/flatpages/install/install_generator.rb
76
+ - lib/generators/flatpages/install/templates/active_admin/flatpage.rb.erb
77
+ - lib/generators/flatpages/install/templates/create_flatpage.rb
75
78
  homepage: ''
76
79
  licenses:
77
80
  - MIT