redirector_ui 1.0.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: bec40b13c6312a28e107b89e80b0615e02207764
4
+ data.tar.gz: bbd296c9e4c7b3c7494f503c84ee8b1fc333335c
5
+ SHA512:
6
+ metadata.gz: 8be6e8157ad9efece14ba09b8b0632cc18529273de47168723cbd57897f62ff8f1d6a5a68d28911dab39df3efab6a940809cc224d85cbf7a04087cf07a66b4b5
7
+ data.tar.gz: 3b7ae814f9c3becdd7e8db187d1703997727fce773597a2448769f273abe7444e71b803f3b12578afd934c5a7607baba44e703580bea31ff766423dcfcc13f8f
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Fabien Dobat
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,30 @@
1
+ # RedirectorUi
2
+ A simple Rails engine that provides an interface for [redirector](https://github.com/vigetlabs/redirector) gem.
3
+
4
+ ## Usage
5
+ ```ruby
6
+ mount RedirectorUi::Engine, at: '/redirects'
7
+ ```
8
+
9
+ ## Installation
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'redirector_ui'
14
+ ```
15
+
16
+ And then execute:
17
+ ```bash
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+ ```bash
23
+ $ gem install redirector_ui
24
+ ```
25
+
26
+ ## Contributing
27
+ Contribution directions go here.
28
+
29
+ ## License
30
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'RedirectorUi'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/redirector_ui .js
2
+ //= link_directory ../stylesheets/redirector_ui .css
@@ -0,0 +1,15 @@
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 any plugin's vendor/assets/javascripts directory 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. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require_tree .
@@ -0,0 +1,35 @@
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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
16
+
17
+ @import 'font-awesome';
18
+ @import 'bootstrap';
19
+
20
+ #redirect_ui {
21
+ .title {
22
+ margin-top: 1rem;
23
+ margin-bottom: 3rem;
24
+ }
25
+
26
+ .datagrid-filter.filter {
27
+ input:not([type=submit]), select {
28
+ @extend .form-control;
29
+ }
30
+ }
31
+
32
+ .pagination {
33
+ margin-top: 0;
34
+ }
35
+ }
@@ -0,0 +1,7 @@
1
+ require 'font-awesome-rails'
2
+
3
+ module RedirectorUi
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery with: :exception
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ module RedirectorUi
2
+ class RedirectRulesController < ApplicationController
3
+
4
+ before_action :set_redirect_rule, only: [:edit, :update, :destroy]
5
+
6
+ def index
7
+ @redirect_rules_grid = RedirectRulesGrid.new(params[:redirector_ui_redirect_rules_grid])
8
+
9
+ respond_to do |f|
10
+ f.html do
11
+ @redirect_rules_grid.scope { |scope| scope.page(params[:page]) }
12
+ end
13
+ f.csv do
14
+ send_data @redirect_rules_grid.to_csv,
15
+ type: 'text/csv',
16
+ disposition: 'inline',
17
+ filename: "redirect-rules-#{Time.now.to_s}.csv"
18
+ end
19
+ end
20
+ end
21
+
22
+ def edit
23
+ end
24
+
25
+ def update
26
+ if @redirect_rule.update(redirect_rule_params)
27
+ redirect_to redirector_ui.redirect_rules_path, notice: 'Redirect rule has been correctly updated.'
28
+ else
29
+ render :edit
30
+ end
31
+ end
32
+
33
+ def destroy
34
+ @redirect_rule.destroy
35
+ redirect_to redirector_ui.redirect_rules_path, notice: 'Redirect rule has been correctly destroyed.'
36
+ end
37
+
38
+ private
39
+
40
+ def set_redirect_rule
41
+ @redirect_rule = RedirectRule.find(params[:id])
42
+ end
43
+
44
+ def redirect_rule_params
45
+ params.require(:redirect_rule).permit(:source, :destination, :active, :source_is_regex, :source_is_case_sensitive)
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,45 @@
1
+ module RedirectorUi
2
+ class RedirectRulesGrid
3
+ include Datagrid
4
+
5
+ scope { RedirectRule }
6
+
7
+ def initialize attributes = nil, &block
8
+ self.order ||= 'created_at'
9
+ self.descending ||= 'true'
10
+ super(attributes, &block)
11
+ end
12
+
13
+ filter(:source, :string) { |value| where('source LIKE ?', "%#{value}%") }
14
+ filter(:destination, :string) { |value| where('destination LIKE ?', "%#{value}%") }
15
+ filter(:active, :xboolean)
16
+ filter(:source_is_regex, :xboolean)
17
+ filter(:source_is_case_sensitive, :xboolean)
18
+
19
+ column(:created_at) do |r|
20
+ format(r.created_at) do |value|
21
+ I18n.l r.created_at
22
+ end
23
+ end
24
+ column(:source)
25
+ column(:destination)
26
+ column(:active) do |r|
27
+ format(r.active) do |value|
28
+ value ? fa_icon('check-circle', class: 'text-success') : fa_icon('times-circle', class: 'text-danger')
29
+ end
30
+ end
31
+ column(:source_is_regex) do |r|
32
+ format(r.source_is_regex) do |value|
33
+ value ? fa_icon('check-circle', class: 'text-success') : fa_icon('times-circle', class: 'text-danger')
34
+ end
35
+ end
36
+ column(:source_is_case_sensitive) do |r|
37
+ format(r.source_is_case_sensitive) do |value|
38
+ value ? fa_icon('check-circle', class: 'text-success') : fa_icon('times-circle', class: 'text-danger')
39
+ end
40
+ end
41
+ column(:actions, header: '', html: true) do |r|
42
+ link_to(fa_icon(:pencil), redirector_ui.edit_redirect_rule_path(r), class: %w(btn btn-primary btn-sm))
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,5 @@
1
+ module RedirectorUi
2
+ module ApplicationHelper
3
+ include FontAwesome::Rails::IconHelper
4
+ end
5
+ end
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Redirector ui</title>
5
+ <%= stylesheet_link_tag 'redirector_ui/application', media: 'all' %>
6
+ <%= javascript_include_tag 'redirector_ui/application' %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <div id='redirect_ui'>
12
+ <nav class='navbar navbar-light bg-faded'>
13
+ <a class='navbar-brand' href=<%= redirector_ui.root_path %>>Redirector UI</a>
14
+ <ul class='nav navbar-nav'>
15
+ <li class='nav-item active'>
16
+ <a class='nav-link' href=<%= redirector_ui.redirect_rules_path %>>Redirect rules</a>
17
+ </li>
18
+ <li class='nav-item'>
19
+ <a class='nav-link' href='#'>Request environment rules</a>
20
+ </li>
21
+ </ul>
22
+ </nav>
23
+
24
+ <div class='container-fluid'>
25
+ <% if notice %>
26
+ <div class='alert alert-success' role='alert'><%= notice %></div>
27
+ <% end %>
28
+ <% if alert %>
29
+ <div class='alert alert-danger' role='alert'><%= alert %></div>
30
+ <% end %>
31
+
32
+ <%= yield %>
33
+ </div>
34
+ </div>
35
+
36
+ </body>
37
+ </html>
@@ -0,0 +1,60 @@
1
+ <div class='container'>
2
+ <h1 class='title'>Edit redirect rule</h1>
3
+ <div class='row'>
4
+ <%= link_to 'Back', redirector_ui.redirect_rules_path, class: 'btn btn-link' %>
5
+ </div>
6
+
7
+ <%= form_for(@redirect_rule) do |f| %>
8
+ <% if @redirect_rule.errors.any? %>
9
+ <div id='error_explanation'>
10
+ <div class='alert alert-danger' role='alert'>
11
+ <ul>
12
+ <%= @redirect_rule.errors.full_messages.to_sentence %>
13
+ </ul>
14
+ </div>
15
+ </div>
16
+ <% end %>
17
+
18
+ <div class='form-group row'>
19
+ <%= f.label :source, class: 'col-xs-3 col-form-label' %>
20
+ <div class='col-xs-9'>
21
+ <%= f.text_field :source, class: 'form-control', placeholder: '/source' %>
22
+ </div>
23
+ </div>
24
+
25
+ <div class='form-group row'>
26
+ <%= f.label :destination, class: 'col-xs-3 col-form-label' %>
27
+ <div class='col-xs-9'>
28
+ <%= f.text_field :destination, class: 'form-control', placeholder: '/destination' %>
29
+ </div>
30
+ </div>
31
+
32
+ <div class='form-group row'>
33
+ <%= f.label :active, class: 'col-xs-3 col-form-label' %>
34
+ <div class='col-xs-9'>
35
+ <%= f.check_box :active, class: 'form-control' %>
36
+ </div>
37
+ </div>
38
+
39
+ <div class='form-group row'>
40
+ <%= f.label :source_is_regex, class: 'col-xs-3 col-form-label' %>
41
+ <div class='col-xs-9'>
42
+ <%= f.check_box :source_is_regex, class: 'form-control' %>
43
+ </div>
44
+ </div>
45
+
46
+ <div class='form-group row'>
47
+ <%= f.label :source_is_case_sensitive, class: 'col-xs-3 col-form-label' %>
48
+ <div class='col-xs-9'>
49
+ <%= f.check_box :source_is_case_sensitive, class: 'form-control' %>
50
+ </div>
51
+ </div>
52
+
53
+ <div class='form-group row'>
54
+ <div class='col-xs-12'>
55
+ <%= f.submit 'Save', class: 'btn btn-primary pull-left' %>
56
+ <%= link_to 'Destroy', redirector_ui.redirect_rule_path(@redirect_rule), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger pull-right' %>
57
+ </div>
58
+ </div>
59
+ <% end %>
60
+ </div>
@@ -0,0 +1,23 @@
1
+ <div class='row'>
2
+ <div class='col-xs-12'>
3
+ <h1 class='title'>Redirect rules</h1>
4
+ </div>
5
+ </div>
6
+ <div class='row'>
7
+ <div class='col-md-9'>
8
+ <div class='col-xs-12'>
9
+ <%= paginate @redirect_rules_grid.assets, html: { class: 'pull-left' } %>
10
+ <%= link_to fa_icon(:download, text: 'Download'), url_for(format: 'csv', redirector_ui_redirect_rules_grid: params.fetch(:redirector_ui_redirect_rules_grid, {}).permit!.to_h), class: 'pull-right' %>
11
+ </div>
12
+ <%= datagrid_table @redirect_rules_grid, html: { class: 'table table-hover table-striped' } %>
13
+ <div class='row'>
14
+ <div class='col-xs-12'>
15
+ <%= paginate @redirect_rules_grid.assets, html: { class: 'pull-left' } %>
16
+ <%= link_to fa_icon(:download, text: 'Download'), url_for(format: 'csv', redirector_ui_redirect_rules_grid: params.fetch(:redirector_ui_redirect_rules_grid, {}).permit!.to_h), class: 'pull-right' %>
17
+ </div>
18
+ </div>
19
+ </div>
20
+ <div class='col-md-3'>
21
+ <%= datagrid_form_for @redirect_rules_grid, method: :get, url: url_for(only_path: false) %>
22
+ </div>
23
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ RedirectorUi::Engine.routes.draw do
2
+ resources :redirect_rules, only: [ :index, :edit, :update, :destroy ]
3
+
4
+ root to: 'redirect_rules#index'
5
+ end
@@ -0,0 +1,5 @@
1
+ module RedirectorUi
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace RedirectorUi
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module RedirectorUi
2
+ VERSION = '1.0.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require "redirector_ui/engine"
2
+
3
+ module RedirectorUi
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :redirector_ui do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: redirector_ui
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Fabien Dobat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-11-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bootstrap
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: datagrid
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: font-awesome-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jquery-rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: kaminari
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '3.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '3.1'
97
+ - !ruby/object:Gem::Dependency
98
+ name: awesome_print
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: A simple Rails engine that provides an interface for redirector gem
112
+ email:
113
+ - fabien.dobat@seniormedia.fr
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - MIT-LICENSE
119
+ - README.md
120
+ - Rakefile
121
+ - app/assets/config/redirector_ui_manifest.js
122
+ - app/assets/javascripts/redirector_ui/application.js
123
+ - app/assets/stylesheets/redirector_ui/application.scss
124
+ - app/controllers/redirector_ui/application_controller.rb
125
+ - app/controllers/redirector_ui/redirect_rules_controller.rb
126
+ - app/grids/redirector_ui/redirect_rules_grid.rb
127
+ - app/helpers/redirector_ui/application_helper.rb
128
+ - app/views/layouts/redirector_ui/application.html.erb
129
+ - app/views/redirector_ui/redirect_rules/edit.html.erb
130
+ - app/views/redirector_ui/redirect_rules/index.html.erb
131
+ - config/routes.rb
132
+ - lib/redirector_ui.rb
133
+ - lib/redirector_ui/engine.rb
134
+ - lib/redirector_ui/version.rb
135
+ - lib/tasks/redirector_ui_tasks.rake
136
+ homepage: http://homepage.com
137
+ licenses:
138
+ - MIT
139
+ metadata: {}
140
+ post_install_message:
141
+ rdoc_options: []
142
+ require_paths:
143
+ - lib
144
+ required_ruby_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - ">="
152
+ - !ruby/object:Gem::Version
153
+ version: '0'
154
+ requirements: []
155
+ rubyforge_project:
156
+ rubygems_version: 2.5.1
157
+ signing_key:
158
+ specification_version: 4
159
+ summary: Redirector gem interface
160
+ test_files: []