rails_admin_robots_txt 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: edcecc04f299011da00c7f462aa4c227c764bf77
4
+ data.tar.gz: 092ecf86a52b8951666c5873c25415a148f5b99f
5
+ SHA512:
6
+ metadata.gz: d6aa1c49cc08e60b277dafb08606423308faa52f1483597be1a7dff8f48e5365f44448dd15e953217ce177d52bfbb4a5565f3078a22e45b0e3d42727315a8d39
7
+ data.tar.gz: feb9f53ab46fa1a4e9f64175342ba44fdc8507ed3672663c0a2c5035bb8de8c26cd8c16f5fd1e29294fb8370cff1d0989bb802fda7d91f91b9578c46414a838f
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.idea
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_admin_robots_txt.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Alexander Kiseliev
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # RailsAdminRobotsTxt
2
+
3
+ robots.txt file editor for RailsAdmin
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'rails_admin_robots_txt'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install rails_admin_robots_txt
20
+
21
+ ## Usage
22
+
23
+ Add 'robots_txt' or `robots_txt_for_model` action in config/initializers/rails_admin.rb
24
+
25
+ ```ruby
26
+ RailsAdmin.config do |config|
27
+
28
+ config.actions do
29
+
30
+ robots_txt
31
+ # or
32
+ robots_txt_for_model do
33
+ visible do
34
+ ['SEO'].include? bindings[:abstract_model].model_name
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+ ```
42
+
43
+ Action `robots_txt` is root action, `robots_txt_for_model` action is collection action. They do same things and so locate it wherever you want.
44
+
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it ( https://github.com/[my-github-username]/rails_admin_robots_txt/fork )
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
57
+ 4. Push to the branch (`git push origin my-new-feature`)
58
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,13 @@
1
+ #rails_admin_robots_txt_wrapper
2
+
3
+ #rails_admin_robots_txt
4
+ .controls
5
+ = form_for "robots_txt", url: robots_txt_path(model_name: @abstract_model), method: :post do |f|
6
+ p= f.submit "Сохранить robots.txt"
7
+ p= f.text_area :content, @textarea_opts
8
+ p= f.submit "Сохранить robots.txt"
9
+
10
+ = link_to "Проверить", "/robots.txt", target: :_blank, title: "Проверить сожержимое robots.txt там и сейчас"
11
+ '  
12
+ = link_to "Проверить тут", "/robots.txt", title: "Проверить сожержимое robots.txt здесь и сейчас", onclick: "$('#file_contents').load(this.href); return false;"
13
+ pre#file_contents{style='margin-bottom: 20px;'}
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rails_admin_robots_txt"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,17 @@
1
+ ru:
2
+ admin:
3
+ actions:
4
+ robots_txt:
5
+ menu: "Редактор robots.txt"
6
+ breadcrumb: "Редактор robots.txt"
7
+ error: "Ошибка"
8
+ error_no_data: "Нет данных"
9
+ success: "Успешно"
10
+ title: "Редактор robots.txt"
11
+ robots_txt_for_model:
12
+ menu: "Редактор robots.txt"
13
+ breadcrumb: "Редактор robots.txt"
14
+ error: "Ошибка"
15
+ error_no_data: "Нет данных"
16
+ success: "Успешно"
17
+ title: "Редактор robots.txt"
@@ -0,0 +1,88 @@
1
+ require "rails_admin/config/actions/base"
2
+ module RailsAdmin
3
+ module Config
4
+ module Actions
5
+ class RobotsTxt < Base
6
+ RailsAdmin::Config::Actions.register(self)
7
+
8
+ # Is the action acting on the root level (Example: /admin/contact)
9
+ register_instance_option :root? do
10
+ true
11
+ end
12
+
13
+ register_instance_option :collection? do
14
+ false
15
+ end
16
+
17
+ # Is the action on an object scope (Example: /admin/team/1/edit)
18
+ register_instance_option :member? do
19
+ false
20
+ end
21
+
22
+ register_instance_option :route_fragment do
23
+ 'robots_txt'
24
+ end
25
+
26
+ register_instance_option :controller do
27
+ Proc.new do |klass|
28
+ if request.get?
29
+ text = File.read(Rails.root.join("public", "robots.txt"))
30
+
31
+ # {value: text, cols: 80..150, cols: 5..20}
32
+ textarea_opts = {value: text}
33
+ textarea_opts[:cols] = text.lines.map(&:size).max || 80
34
+ textarea_opts[:cols] = 80 if textarea_opts[:cols] < 80
35
+ textarea_opts[:cols] = 150 if textarea_opts[:cols] > 150
36
+ textarea_opts[:rows] = text.lines.count + 1
37
+ textarea_opts[:rows] = 5 if textarea_opts[:rows] > 5
38
+ textarea_opts[:rows] = 20 if textarea_opts[:rows] > 20
39
+
40
+ render action: @action.template_name
41
+
42
+ elsif request.post?
43
+ begin
44
+ File.write(Rails.root.join("public", "robots.txt"), params[:robots_txt][:content].strip)
45
+ flash[:success] = "Все сохранилось"
46
+
47
+ rescue Exception => e
48
+ flash[:error] = "Чтото не так"
49
+ end
50
+
51
+ redirect_to robots_txt_path(model_name: @abstract_model)
52
+ end
53
+
54
+ end
55
+ end
56
+
57
+ register_instance_option :link_icon do
58
+ 'fa fa-file-text-o'
59
+ end
60
+
61
+ register_instance_option :http_methods do
62
+ [:get, :post]
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end
68
+
69
+
70
+ module RailsAdmin
71
+ module Config
72
+ module Actions
73
+ class RobotsTxtForModel < RobotsTxt
74
+ RailsAdmin::Config::Actions.register(self)
75
+
76
+ # Is the action acting on the root level (Example: /admin/contact)
77
+ register_instance_option :root? do
78
+ false
79
+ end
80
+
81
+ register_instance_option :collection? do
82
+ true
83
+ end
84
+
85
+ end
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,4 @@
1
+ module RailsAdminRobotsTxt
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminRobotsTxt
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,8 @@
1
+ require "rails_admin_robots_txt/version"
2
+
3
+ require "rails_admin_robots_txt/engine"
4
+ require "rails_admin_robots_txt/action"
5
+
6
+ module RailsAdminRobotsTxt
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_admin_robots_txt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "rails_admin_robots_txt"
8
+ spec.version = RailsAdminRobotsTxt::VERSION
9
+ spec.authors = ["Alexander Kiseliev"]
10
+ spec.email = ["i43ack@gmail.com"]
11
+
12
+ spec.summary = %q{robots.txt editor in rails_admin panel}
13
+ spec.description = %q{robots.txt editor in rails_admin panel}
14
+ spec.homepage = "https://github.com/ack43/rails_admin_robots_txt"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.8"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+
25
+ spec.add_dependency "rails_admin", '>= 0.8.1'
26
+ end
data/release.sh ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/bash
2
+ bundle update
3
+ git add --all .
4
+ git commit -am "${*:1}"
5
+ git push -u origin master
6
+ rake release
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_admin_robots_txt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Kiseliev
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-03-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.8'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rails_admin
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 0.8.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 0.8.1
55
+ description: robots.txt editor in rails_admin panel
56
+ email:
57
+ - i43ack@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - app/views/rails_admin/main/robots_txt.html.slim
68
+ - bin/console
69
+ - bin/setup
70
+ - config/locales/ru.rails_admin_robots_txt.yml
71
+ - lib/rails_admin_robots_txt.rb
72
+ - lib/rails_admin_robots_txt/action.rb
73
+ - lib/rails_admin_robots_txt/engine.rb
74
+ - lib/rails_admin_robots_txt/version.rb
75
+ - rails_admin_robots_txt.gemspec
76
+ - release.sh
77
+ homepage: https://github.com/ack43/rails_admin_robots_txt
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.5.1
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: robots.txt editor in rails_admin panel
101
+ test_files: []