metaitems 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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +1 -0
- data/lib/generators/metaitems/install_generator.rb +25 -0
- data/lib/generators/metaitems/templates/edit.html.erb +19 -0
- data/lib/generators/metaitems/templates/metaitem.rb +16 -0
- data/lib/generators/metaitems/templates/metaitems_controller.rb +31 -0
- data/lib/metaitems/engine.rb +6 -0
- data/lib/metaitems/version.rb +3 -0
- data/lib/metaitems.rb +5 -0
- data/metaitems.gemspec +25 -0
- metadata +82 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Sergey Kucher
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Metaitems
|
2
|
+
|
3
|
+
Gem for RubyOnRails that can generate metaitems to your project.
|
4
|
+
Metaitems is the functionality (model, view, controller, route) to manage
|
5
|
+
name, description, keywords and url nick for html page.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'metaitems'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install metaitems
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
TODO: Write usage instructions here
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
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 new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module Metaitems
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def add_module
|
9
|
+
template 'metaitem.rb', 'app/models/metaitem.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_view
|
13
|
+
template 'edit.html.erb', 'app/views/metaitems/edit.html.erb'
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_controller
|
17
|
+
template 'metaitem_controller.rb', 'app/controllers/metaitem_controller.rb'
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_route
|
21
|
+
route "resource :metaitem, :only => [:edit, :update]"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Изменить метаданные</h1>
|
2
|
+
|
3
|
+
<% form_options = { :url => metaitem_path, :html => {:method => :put } } %>
|
4
|
+
<%= simple_form_for @metaitem, form_options do |f| %>
|
5
|
+
<%= f.error_notification %>
|
6
|
+
|
7
|
+
<div class="form-inputs">
|
8
|
+
<%= f.input :name %>
|
9
|
+
<%= f.input :description %>
|
10
|
+
<%= f.input :keywords %>
|
11
|
+
<%= f.input :slug %>
|
12
|
+
<%= hidden_field_tag 'name', @resource.class.name %>
|
13
|
+
<%= hidden_field_tag 'id', @resource.id %>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div class="form-actions">
|
17
|
+
<%= f.button :submit, 'Сохранить метаданные' %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Metaitem < ActiveRecord::Base
|
4
|
+
attr_accessible :name, :description, :keywords, :slug
|
5
|
+
belongs_to :metaitemable, polymorphic: true
|
6
|
+
|
7
|
+
validates_length_of :name, maximum: 255
|
8
|
+
|
9
|
+
after_save :update_metaitemable
|
10
|
+
|
11
|
+
private
|
12
|
+
def update_metaitemable
|
13
|
+
metaitemable.save
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class MetaitemsController < ActionController::Base
|
4
|
+
before_filter :find_resource, :ensure_metaitem
|
5
|
+
respond_to :html
|
6
|
+
|
7
|
+
def edit
|
8
|
+
respond_with(@metaitem)
|
9
|
+
end
|
10
|
+
|
11
|
+
def update
|
12
|
+
@metaitem.attributes = params[:metaitem]
|
13
|
+
if @metaitem.save
|
14
|
+
flash[:notice] = "Metaitem was successfully updated."
|
15
|
+
else
|
16
|
+
flash[:alert] = "Metaitem has errors."
|
17
|
+
end
|
18
|
+
redirect_to url_for(find_resource)
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def find_resource
|
24
|
+
@resource = params[:name].classify.constantize.find(params[:id])
|
25
|
+
end
|
26
|
+
|
27
|
+
def ensure_metaitem
|
28
|
+
@metaitem = @resource.metaitem || @resource.build_metaitem
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/lib/metaitems.rb
ADDED
data/metaitems.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'metaitems/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "metaitems"
|
8
|
+
gem.version = Metaitems::VERSION
|
9
|
+
gem.authors = ["Sergey Kucher"]
|
10
|
+
gem.email = ["s.e.kucher@gmail.com"]
|
11
|
+
gem.description = <<eos
|
12
|
+
Gem for RubyOnRails that can generate metaitems to your project.
|
13
|
+
Metaitems is the functionality (model, view, controller, route) to manage
|
14
|
+
name, description, keywords and url nick for html page.
|
15
|
+
eos
|
16
|
+
gem.summary = 'Generates tool to manage page meta information'
|
17
|
+
gem.homepage = ""
|
18
|
+
|
19
|
+
gem.files = `git ls-files`.split($/)
|
20
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
21
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
|
24
|
+
gem.add_runtime_dependency 'rails', '3.2.12'
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metaitems
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Sergey Kucher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.12
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.2.12
|
30
|
+
description: ! "Gem for RubyOnRails that can generate metaitems to your project.\nMetaitems
|
31
|
+
is the functionality (model, view, controller, route) to manage \nname, description,
|
32
|
+
keywords and url nick for html page.\n"
|
33
|
+
email:
|
34
|
+
- s.e.kucher@gmail.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- .gitignore
|
40
|
+
- Gemfile
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- lib/generators/metaitems/install_generator.rb
|
45
|
+
- lib/generators/metaitems/templates/edit.html.erb
|
46
|
+
- lib/generators/metaitems/templates/metaitem.rb
|
47
|
+
- lib/generators/metaitems/templates/metaitems_controller.rb
|
48
|
+
- lib/metaitems.rb
|
49
|
+
- lib/metaitems/engine.rb
|
50
|
+
- lib/metaitems/version.rb
|
51
|
+
- metaitems.gemspec
|
52
|
+
homepage: ''
|
53
|
+
licenses: []
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
none: false
|
60
|
+
requirements:
|
61
|
+
- - ! '>='
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
hash: 2557103624168842348
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
hash: 2557103624168842348
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 1.8.25
|
79
|
+
signing_key:
|
80
|
+
specification_version: 3
|
81
|
+
summary: Generates tool to manage page meta information
|
82
|
+
test_files: []
|