go_links 0.1.0
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +45 -0
- data/Rakefile +37 -0
- data/app/assets/config/go_link_manifest.js +0 -0
- data/app/controllers/plugins/go_link/admin_controller.rb +49 -0
- data/app/helpers/plugins/go_link/main_helper.rb +29 -0
- data/app/models/plugins/go_link/go_link.rb +9 -0
- data/app/views/plugins/go_links/admin/new.html.erb +20 -0
- data/app/views/plugins/go_links/admin/settings.html.erb +22 -0
- data/config/camaleon_plugin.json +14 -0
- data/config/initializers/custom_models.rb +5 -0
- data/config/routes.rb +21 -0
- data/lib/go_links/railtie.rb +9 -0
- data/lib/go_links/version.rb +3 -0
- data/lib/go_links.rb +3 -0
- data/lib/tasks/go_links.rake +16 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3efc845b1bbf2aaba529524c160c59aede4e702e
|
4
|
+
data.tar.gz: 2877a9088018b9f8dde05f6e406e9dbb0e06814e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9897fdb550f98bc7354ebebcd9e78a122638bfec251c76a0b5e477de711aad621bd01bdd814431b0f0dafacb2c72c033fa1424ff37243dbfd8295e8816426801
|
7
|
+
data.tar.gz: f1a8cef8e24a6fb574b5e9ac4616e9647b83b7aa2346e82ae30cfbb276a2e946dfda52643bbf9bb15681ea0e56acfa011818d556431a3ad97af08aaac4407e8c
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2017 Ryan Kulp
|
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,45 @@
|
|
1
|
+
# GoLinks
|
2
|
+
Dead simple link shortening and click tracking plugin for Cameleon CMS.
|
3
|
+
|
4
|
+
Turns long URLs into branded, "/go/some-slug" destinations, which increases click-through engagements and is great for managing messy affiliate links.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'go_links'
|
11
|
+
```
|
12
|
+
|
13
|
+
Then execute:
|
14
|
+
```bash
|
15
|
+
$ bundle
|
16
|
+
```
|
17
|
+
|
18
|
+
Or install it yourself:
|
19
|
+
```bash
|
20
|
+
$ gem install go_links
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
1. Install the gem
|
26
|
+
2. `$ rake go_links:install` then `$ rake db:migrate`
|
27
|
+
3. Activate plugin from your site's `/admin/plugins/` 'Disabled' tab
|
28
|
+
4. Click 'settings' from Active tab to view and configure links
|
29
|
+
|
30
|
+
## To do
|
31
|
+
|
32
|
+
* Ability to Edit/Update a link destination
|
33
|
+
* Ability to delete a link
|
34
|
+
* Sorting by most/least in Index view
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
1. Fork it
|
39
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
40
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
41
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
42
|
+
5. Create new Pull Request
|
43
|
+
|
44
|
+
## License
|
45
|
+
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 = 'GoLink'
|
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
|
File without changes
|
@@ -0,0 +1,49 @@
|
|
1
|
+
class Plugins::GoLink::AdminController < CamaleonCms::Apps::PluginsAdminController
|
2
|
+
include Plugins::GoLink::MainHelper
|
3
|
+
before_action :set_link, only: [:show]
|
4
|
+
|
5
|
+
def new
|
6
|
+
@go_link = Plugins::GoLink::GoLink.new
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
if @link
|
11
|
+
@link.click!
|
12
|
+
redirect_to @link.destination
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@go_link = Plugins::GoLink::GoLink.new(go_link_params)
|
18
|
+
|
19
|
+
if @go_link.save
|
20
|
+
redirect_to url_for(action: :settings), notice: 'Link Saved Successfully'
|
21
|
+
else
|
22
|
+
# do something else
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# show settings form
|
27
|
+
def settings
|
28
|
+
@go_links = Plugins::GoLink::GoLink.all
|
29
|
+
end
|
30
|
+
|
31
|
+
# save values from settings form
|
32
|
+
def save_settings
|
33
|
+
@plugin.set_options(params[:options]) if params[:options].present? # save option values
|
34
|
+
@plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values
|
35
|
+
@plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values
|
36
|
+
redirect_to url_for(action: :settings), notice: 'Settings Saved Successfully'
|
37
|
+
end
|
38
|
+
# add custom methods below ....
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def set_link
|
43
|
+
@link = Plugins::GoLink::GoLink.find_by(slug: params[:slug])
|
44
|
+
end
|
45
|
+
|
46
|
+
def go_link_params
|
47
|
+
params.require(:go_link).permit(:slug, :destination)
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Plugins::GoLink::MainHelper
|
2
|
+
def self.included(klass)
|
3
|
+
# klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
|
4
|
+
end
|
5
|
+
|
6
|
+
# here all actions on going to active
|
7
|
+
# you can run sql commands like this:
|
8
|
+
# results = ActiveRecord::Base.connection.execute(query);
|
9
|
+
# plugin: plugin model
|
10
|
+
def go_link_on_active(plugin)
|
11
|
+
end
|
12
|
+
|
13
|
+
# here all actions on going to inactive
|
14
|
+
# plugin: plugin model
|
15
|
+
def go_link_on_inactive(plugin)
|
16
|
+
end
|
17
|
+
|
18
|
+
# here all actions to upgrade for a new version
|
19
|
+
# plugin: plugin model
|
20
|
+
def go_link_on_upgrade(plugin)
|
21
|
+
end
|
22
|
+
|
23
|
+
# hook listener to add settings link below the title of current plugin (if it is installed)
|
24
|
+
# args: {plugin (Hash), links (Array)}
|
25
|
+
# permit to add unlimmited of links...
|
26
|
+
def go_link_on_plugin_options(args)
|
27
|
+
args[:links] << link_to('Settings', admin_plugins_go_link_settings_path)
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="panel panel-default">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<h4>Create an Outbound Link</h4>
|
4
|
+
</div>
|
5
|
+
<div class="panel-body">
|
6
|
+
<%= form_tag(url_for(action: :create), class: 'validate') do %>
|
7
|
+
<div class="form-group">
|
8
|
+
<label>Slug</label>
|
9
|
+
<%= text_field_tag 'go_link[slug]', @go_link.slug, class: 'form-control required' %>
|
10
|
+
</div>
|
11
|
+
<div class="form-group">
|
12
|
+
<label>Destination</label>
|
13
|
+
<%= text_field_tag 'go_link[destination]', @go_link.destination, class: 'form-control required' %>
|
14
|
+
</div>
|
15
|
+
<div class="form-group text-right">
|
16
|
+
<%= submit_tag 'Save Link', class: 'btn btn-primary' %>
|
17
|
+
</div>
|
18
|
+
<% end %>
|
19
|
+
</div>
|
20
|
+
</div>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<div class="panel panel-default">
|
2
|
+
<div class="panel-heading">
|
3
|
+
<h4>Your Outbound Links</h4>
|
4
|
+
<%= link_to "add new", admin_plugins_go_link_new_path, class: 'pull-right btn btn-primary' %>
|
5
|
+
</div>
|
6
|
+
<table class="table">
|
7
|
+
<thead>
|
8
|
+
<th>Slug</th>
|
9
|
+
<th>Destination</th>
|
10
|
+
<th>Clicks</th>
|
11
|
+
</thead>
|
12
|
+
<tbody>
|
13
|
+
<% @go_links.each do |link| %>
|
14
|
+
<tr>
|
15
|
+
<td><%= link.slug %></td>
|
16
|
+
<td><%= link.destination %></td>
|
17
|
+
<td><%= link.clicks %></td>
|
18
|
+
</tr>
|
19
|
+
<% end %>
|
20
|
+
</tbody>
|
21
|
+
</table>
|
22
|
+
</div>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"title": "Go Links",
|
3
|
+
"descr": "",
|
4
|
+
"key": "go_links", // must be the name of the folder of your plugin, sample: app/views/plugins/<my_plugin> ==> 'my_plugin'
|
5
|
+
"helpers": [
|
6
|
+
"Plugins::GoLinks::MainHelper"
|
7
|
+
],
|
8
|
+
"hooks": {
|
9
|
+
"on_active": ["go_link_on_active"],
|
10
|
+
"on_inactive": ["go_link_on_inactive"],
|
11
|
+
"plugin_options": ["go_link_on_plugin_options"]
|
12
|
+
//here you can add all your hooks (read documentation)
|
13
|
+
}
|
14
|
+
}
|
data/config/routes.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
scope PluginRoutes.system_info["relative_url_root"] do
|
3
|
+
|
4
|
+
get 'go/:slug', to: 'plugins/go_link/admin#show'
|
5
|
+
|
6
|
+
#Admin Panel
|
7
|
+
scope :admin, as: 'admin', path: PluginRoutes.system_info['admin_path_name'] do
|
8
|
+
namespace 'plugins' do
|
9
|
+
namespace 'go_link' do
|
10
|
+
controller :admin do
|
11
|
+
get :new
|
12
|
+
post :create
|
13
|
+
get :index
|
14
|
+
post :save_settings
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/go_links.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
namespace :go_links do
|
2
|
+
desc "Creates table that stores slugs, destination urls, and click counts."
|
3
|
+
task :install => :environment do
|
4
|
+
puts "installing GoLinks..."
|
5
|
+
|
6
|
+
ActiveRecord::Schema.define do
|
7
|
+
create_table :plugins_go_links do |t|
|
8
|
+
t.string :slug
|
9
|
+
t.string :destination
|
10
|
+
t.integer :clicks, default: 0
|
11
|
+
t.timestamps null: false
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: go_links
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ryan Kulp
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Create vanity URLs for outbound links.
|
14
|
+
email:
|
15
|
+
- ryanckulp@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- MIT-LICENSE
|
21
|
+
- README.md
|
22
|
+
- Rakefile
|
23
|
+
- app/assets/config/go_link_manifest.js
|
24
|
+
- app/controllers/plugins/go_link/admin_controller.rb
|
25
|
+
- app/helpers/plugins/go_link/main_helper.rb
|
26
|
+
- app/models/plugins/go_link/go_link.rb
|
27
|
+
- app/views/plugins/go_links/admin/new.html.erb
|
28
|
+
- app/views/plugins/go_links/admin/settings.html.erb
|
29
|
+
- config/camaleon_plugin.json
|
30
|
+
- config/initializers/custom_models.rb
|
31
|
+
- config/routes.rb
|
32
|
+
- lib/go_links.rb
|
33
|
+
- lib/go_links/railtie.rb
|
34
|
+
- lib/go_links/version.rb
|
35
|
+
- lib/tasks/go_links.rake
|
36
|
+
homepage: http://www.ryanckulp.com
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata: {}
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options: []
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 2.2.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Cloak ugly links on your website with branded 'go' paths.
|
60
|
+
test_files: []
|