urb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +5 -0
  4. data/CHANGELOG.rdoc +5 -0
  5. data/Gemfile +15 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README.rdoc +91 -0
  8. data/Rakefile +10 -0
  9. data/VERSION +1 -0
  10. data/app/assets/javascripts/urb.js.erb +55 -0
  11. data/app/helpers/urb_helper.rb +7 -0
  12. data/app/views/urb/_include.html.erb +1 -0
  13. data/demo/Gemfile +13 -0
  14. data/demo/README.rdoc +28 -0
  15. data/demo/Rakefile +6 -0
  16. data/demo/app/assets/images/.keep +0 -0
  17. data/demo/app/assets/javascripts/application.js +16 -0
  18. data/demo/app/assets/stylesheets/application.css +13 -0
  19. data/demo/app/controllers/application_controller.rb +5 -0
  20. data/demo/app/controllers/concerns/.keep +0 -0
  21. data/demo/app/controllers/home_controller.rb +2 -0
  22. data/demo/app/helpers/application_helper.rb +2 -0
  23. data/demo/app/mailers/.keep +0 -0
  24. data/demo/app/models/.keep +0 -0
  25. data/demo/app/models/concerns/.keep +0 -0
  26. data/demo/app/views/home/index.html.erb +31 -0
  27. data/demo/app/views/layouts/application.html.erb +13 -0
  28. data/demo/bin/bundle +3 -0
  29. data/demo/bin/rails +4 -0
  30. data/demo/bin/rake +4 -0
  31. data/demo/config/application.rb +27 -0
  32. data/demo/config/boot.rb +4 -0
  33. data/demo/config/database.yml +30 -0
  34. data/demo/config/environment.rb +5 -0
  35. data/demo/config/environments/development.rb +29 -0
  36. data/demo/config/environments/production.rb +80 -0
  37. data/demo/config/environments/test.rb +36 -0
  38. data/demo/config/initializers/backtrace_silencers.rb +7 -0
  39. data/demo/config/initializers/filter_parameter_logging.rb +4 -0
  40. data/demo/config/initializers/inflections.rb +16 -0
  41. data/demo/config/initializers/mime_types.rb +5 -0
  42. data/demo/config/initializers/secret_token.rb +12 -0
  43. data/demo/config/initializers/session_store.rb +3 -0
  44. data/demo/config/initializers/u.rb +7 -0
  45. data/demo/config/initializers/wrap_parameters.rb +14 -0
  46. data/demo/config/locales/en.yml +23 -0
  47. data/demo/config/routes.rb +56 -0
  48. data/demo/config.ru +4 -0
  49. data/demo/db/migrate/20140402161002_create_urls.rb +9 -0
  50. data/demo/db/schema.rb +23 -0
  51. data/demo/db/seeds.rb +7 -0
  52. data/demo/lib/assets/.keep +0 -0
  53. data/demo/lib/tasks/.keep +0 -0
  54. data/demo/log/.keep +0 -0
  55. data/demo/public/404.html +58 -0
  56. data/demo/public/422.html +58 -0
  57. data/demo/public/500.html +57 -0
  58. data/demo/public/favicon.ico +0 -0
  59. data/demo/public/robots.txt +5 -0
  60. data/demo/test/controllers/.keep +0 -0
  61. data/demo/test/fixtures/.keep +0 -0
  62. data/demo/test/helpers/.keep +0 -0
  63. data/demo/test/integration/.keep +0 -0
  64. data/demo/test/mailers/.keep +0 -0
  65. data/demo/test/models/.keep +0 -0
  66. data/demo/test/test_helper.rb +15 -0
  67. data/demo/vendor/assets/javascripts/.keep +0 -0
  68. data/demo/vendor/assets/stylesheets/.keep +0 -0
  69. data/lib/urb/engine.rb +9 -0
  70. data/lib/urb/middleware.rb +31 -0
  71. data/lib/urb/version.rb +7 -0
  72. data/lib/urb.rb +48 -0
  73. data/script/console +7 -0
  74. data/test/test_helper/coverage.rb +8 -0
  75. data/test/test_helper.rb +7 -0
  76. data/test/unit/test_urb.rb +114 -0
  77. data/test/unit/urb/test_middleware.rb +70 -0
  78. data/urb.gemspec +21 -0
  79. metadata +166 -0
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YzJiYWI3MDljMDJkMzIwMzk0ZWYxY2I1NzQxNTk2MWU4MWU2MWQwYQ==
5
+ data.tar.gz: !binary |-
6
+ ZmRiMDA1MTlmNGFmODU2YTlmY2UyNWMxNjRmMGEzNTgyZGM5ZjQzMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ODc0Zjc0ZjY0OTU3OTBjODU2N2NmNWEzNTA3NTcxNGY5MmJlMWY1MTYxMjRj
10
+ OTA1YjI5MjdmOGFhNTJkMTFiNjMyYmUwMWIyNzZmMzA2ZjI1YzU4MDJiOWI5
11
+ ZTY1NmFlYWE4ZDAyZDcxNzhjOTA4YTJmNTYxMDA2M2IyNzdjYmY=
12
+ data.tar.gz: !binary |-
13
+ ZmQyMmQyMWE5ZDg4ZTc3MzJlODFjY2RhMzY1NDA1OTMyZmMxNzg1ODk3OWUy
14
+ Y2JkNWNkMTZkZGZiMjc4MDg1YjE1NTliN2FlZjI4NjJhNTA0Y2I1NWQ5YzEw
15
+ MWYyOTQ1Mzg0MTQ3ZmI3Mjc4YmIwOTI5Y2IxYTAyOTdkZDFhOWY=
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .DS_Store
2
+ .bundle
3
+ .rvmrc
4
+ Gemfile.lock
5
+ demo/tmp
6
+ demo/log/*.log
7
+ doc
8
+ pkg
9
+ test/coverage
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - 1.9.2
data/CHANGELOG.rdoc ADDED
@@ -0,0 +1,5 @@
1
+ = URB CHANGELOG
2
+
3
+ == Version 0.1.0 (April 2, 2014)
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem "urb", :path => "."
7
+ end
8
+
9
+ group :test do
10
+ gem "simplecov", :require => false
11
+ gem "minitest"
12
+ gem "mocha"
13
+ gem "rack"
14
+ gem "rack-minitest", :require => "rack-minitest/test", git: "git://github.com/brandonweiss/rack-minitest.git"
15
+ end
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Paul Engel
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.rdoc ADDED
@@ -0,0 +1,91 @@
1
+ == URB {<img src="https://secure.travis-ci.org/archan937/urb.png"/>}[http://travis-ci.org/archan937/urb] {<img src="https://codeclimate.com/github/archan937/urb.png"/>}[https://codeclimate.com/github/archan937/urb]
2
+
3
+ Shorten URLs in your Rack / Rails app.
4
+
5
+ === Installation
6
+
7
+ ==== Using Bundler
8
+
9
+ Add <tt>URB</tt> in <tt>Gemfile</tt> as a gem dependency:
10
+
11
+ gem "urb"
12
+
13
+ Run the following in your console to install with Bundler:
14
+
15
+ $ bundle install
16
+
17
+ === Usage
18
+
19
+ Invoke the view helper method <tt>urb</tt> within your template:
20
+
21
+ <!DOCTYPE html>
22
+ <html>
23
+ <head>
24
+ <title>Killer App</title>
25
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
26
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
27
+ <%= csrf_meta_tags %>
28
+ <%= urb %>
29
+ </head>
30
+
31
+ Click on links within your webpage or call the Javascript function <tt>URB.open()</tt>.
32
+
33
+ <script>
34
+ URB.open('/?p=today&f[]=paulengel&f[]=archan937&f[]=URB&f[]=demo&f[]=Rails&f[]=Long%20URL&f[]=foo&f[]=bar&f[]=baz&f[]=Ownage&f[]=AwesomeStuff&bd[]=Paul.Engel&foobarbaz_id[]=3&foobarbaz_id[]=1&foobarbaz_id[]=4&foobarbaz_id[]=5&foobarbaz_id[]=6&foobarbaz_id[]=7&foobarbaz_id[]=67&foobarbaz_id[]=108&foobarbaz_id[]=66&foobarbaz_id[]=65&foobarbaz_id[]=118&foobarbaz_id[]=68&foobarbaz_id[]=8&foobarbaz_id[]=128&foobarbaz_id[]=79&foobarbaz_id[]=78&foobarbaz_id[]=111&foobarbaz_id[]=9&foobarbaz_id[]=10&foobarbaz_id[]=129&foobarbaz_id[]=11&foobarbaz_id[]=124&foobarbaz_id[]=12&foobarbaz_id[]=130&foobarbaz_id[]=13&foobarbaz_id[]=121&foobarbaz_id[]=14&foobarbaz_id[]=77&foobarbaz_id[]=80&foobarbaz_id[]=15&foobarbaz_id[]=69&foobarbaz_id[]=16&foobarbaz_id[]=17&foobarbaz_id[]=131&foobarbaz_id[]=18&foobarbaz_id[]=117&foobarbaz_id[]=19&foobarbaz_id[]=81&foobarbaz_id[]=82&foobarbaz_id[]=20&foobarbaz_id[]=21&foobarbaz_id[]=96&foobarbaz_id[]=97&foobarbaz_id[]=98&foobarbaz_id[]=99&foobarbaz_id[]=112&foobarbaz_id[]=64&foobarbaz_id[]=63&foobarbaz_id[]=62&foobarbaz_id[]=22&foobarbaz_id[]=23&foobarbaz_id[]=120&foobarbaz_id[]=24&foobarbaz_id[]=87&foobarbaz_id[]=88&foobarbaz_id[]=61&foobarbaz_id[]=60&foobarbaz_id[]=70&foobarbaz_id[]=71&foobarbaz_id[]=100&foobarbaz_id[]=101&foobarbaz_id[]=25&foobarbaz_id[]=26&foobarbaz_id[]=132&foobarbaz_id[]=73&foobarbaz_id[]=72&foobarbaz_id[]=56&foobarbaz_id[]=55&foobarbaz_id[]=74&foobarbaz_id[]=75&foobarbaz_id[]=133&foobarbaz_id[]=83&foobarbaz_id[]=84&foobarbaz_id[]=27&foobarbaz_id[]=107&foobarbaz_id[]=28&foobarbaz_id[]=134&foobarbaz_id[]=135&foobarbaz_id[]=136&foobarbaz_id[]=29&foobarbaz_id[]=119&foobarbaz_id[]=113&foobarbaz_id[]=105&foobarbaz_id[]=104&foobarbaz_id[]=114&foobarbaz_id[]=89&foobarbaz_id[]=103&foobarbaz_id[]=30&foobarbaz_id[]=137&foobarbaz_id[]=76&foobarbaz_id[]=90&foobarbaz_id[]=93&foobarbaz_id[]=92&foobarbaz_id[]=109&foobarbaz_id[]=110&foobarbaz_id[]=139&foobarbaz_id[]=31&foobarbaz_id[]=32&foobarbaz_id[]=140&foobarbaz_id[]=33&foobarbaz_id[]=123&foobarbaz_id[]=34&foobarbaz_id[]=141&foobarbaz_id[]=35&foobarbaz_id[]=115&foobarbaz_id[]=36&foobarbaz_id[]=142&foobarbaz_id[]=86&foobarbaz_id[]=85&foobarbaz_id[]=94&foobarbaz_id[]=95&foobarbaz_id[]=37&foobarbaz_id[]=38&foobarbaz_id[]=40&foobarbaz_id[]=39&foobarbaz_id[]=41&foobarbaz_id[]=42&foobarbaz_id[]=43&foobarbaz_id[]=44&foobarbaz_id[]=45&foobarbaz_id[]=102&foobarbaz_id[]=57&foobarbaz_id[]=58&foobarbaz_id[]=46&foobarbaz_id[]=47&foobarbaz_id[]=48&foobarbaz_id[]=49&foobarbaz_id[]=50&foobarbaz_id[]=59&foobarbaz_id[]=51&foobarbaz_id[]=122&foobarbaz_id[]=52&foobarbaz_id[]=53&foobarbaz_id[]=116&foobarbaz_id[]=54&foobarbaz_id[]=106&foobarbaz_id[]=2&foobarbaz_id[]=91&foobarbaz_id[]=138');
35
+ </script>
36
+
37
+ URB will automatically shorten the URL when it refers to the application itself and exceeds <tt>URB::MAXLENGTH</tt> (which is 2000 characters).
38
+
39
+ ==== URL storage
40
+
41
+ The shortened URLs are stored using the {Moneta}[https://github.com/minad/moneta] gem. At default, they will be stored in memory.
42
+
43
+ To store them within a database, configure URB with <tt>URB.configure</tt> (shortcut: <tt>URB</tt>) and the arguments will be forwarded to the Moneta constructor:
44
+
45
+ (e.g. in config/initializers/u.rb)
46
+
47
+ URB.config :ActiveRecord, :table => "urls", :connection => {:adapter => "mysql2", :database => "my_awesome_app", :user => "someone", :password => "letmypass"}
48
+
49
+ or probably
50
+
51
+ (e.g. in config/initializers/u.rb)
52
+
53
+ URB :ActiveRecord, :table => "urls", :connection => ActiveRecord::Base.connection.instance_variable_get(:@config)
54
+
55
+ The corresponding migration file should look like:
56
+
57
+ class CreateUrls < ActiveRecord::Migration
58
+ def change
59
+ create_table :urls do |t|
60
+ t.text :k
61
+ t.text :v
62
+ t.timestamps
63
+ end
64
+ end
65
+ end
66
+
67
+ You can try this out in the provided demo application. Do not forget to uncomment the last line in {config/initializers/u.rb}[https://github.com/archan937/urb/blob/master/demo/config/initializers/u.rb].
68
+
69
+ === Console and demo Rails app
70
+
71
+ The URB repository is provided with a console which you can start with <tt>script/console</tt>.
72
+
73
+ Also, you can run the provided Rails 4 demo application to try out <tt>URB</tt> in your browser.
74
+
75
+ === Testing
76
+
77
+ Run the following command for testing:
78
+
79
+ $ rake
80
+
81
+ === License
82
+
83
+ Copyright (c) 2014 Paul Engel, released under the MIT license
84
+
85
+ http://gettopup.com – http://github.com/archan937 – http://twitter.com/archan937 – {pm_engel@icloud.com}[mailto:pm_engel@icloud.com]
86
+
87
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
88
+
89
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
90
+
91
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ task :default => :test
7
+
8
+ Rake::TestTask.new do |test|
9
+ test.pattern = "test/**/test_*.rb"
10
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,55 @@
1
+ if (typeof(URB) == 'undefined') {
2
+
3
+ // *
4
+ // * URB <%= URB::VERSION %> (Uncompressed)
5
+ // *
6
+ // * (c) 2014 Paul Engel
7
+ // * Except otherwise noted, URB is licensed under
8
+ // * http://creativecommons.org/licenses/by/3.0
9
+ // *
10
+ // * $Date: 2014-02-06 23:30:51 $
11
+ // *
12
+
13
+ URB = (function() {
14
+ var urb_path = '<%= URB::PATH %>', maxlength = <%= URB::MAXLENGTH %>,
15
+
16
+ $ = {
17
+ ready: function(f){'\v'=='v'?setTimeout(f,0):$.on(document,'DOMContentLoaded',f);},
18
+ on: function(e,t,f,r){if(e.attachEvent?(r?e.detachEvent('on'+t,e[t+f]):1):(r?e.removeEventListener(t,f,0):e.addEventListener(t,f,0))){e['e'+t+f]=f;e[t+f]=function(){e['e'+t+f](window.event);};e.attachEvent('on'+t,e[t+f]);}},
19
+ hasClass: function(e,c){return $.indexOf(c,e.className.split(' '))>=0;},
20
+ indexOf: function(v,a,i){for(i=a.length;i--&&a[i]!=v;);return i;},
21
+ request: function(d,e,f){f=f||'post';var c=document.createElement('form');c.setAttribute('method',f);c.setAttribute('action',d);for(var b in e){if(e.hasOwnProperty(b)){var a=document.createElement('input');a.setAttribute('type','hidden');a.setAttribute('name',b);a.setAttribute('value',e[b]);c.appendChild(a)}}document.body.appendChild(c);c.submit()}
22
+ },
23
+
24
+ init = function() {
25
+ $.on(document, 'click', function(event) {
26
+ var target = event.target || event.srcElement || window.event.target || window.event.srcElement, css = URB.css || '';
27
+ if (target.tagName.toLowerCase() == 'a' && ((css == '') || $.hasClass(target, css))) {
28
+ event.preventDefault();
29
+ open(target.getAttribute('href'));
30
+ }
31
+ });
32
+ },
33
+
34
+ open = function(url) {
35
+ var location = document.createElement('a'), path;
36
+ location.href = url;
37
+ if (location.host == '') {
38
+ location.href = location.href;
39
+ }
40
+ if ((location.host == window.location.host) && (path = location.pathname + location.search).length > maxlength) {
41
+ $.request(urb_path, {path: path});
42
+ } else {
43
+ window.location = url;
44
+ }
45
+ };
46
+
47
+ $.ready(init);
48
+
49
+ return {
50
+ version: '<%= URB::VERSION %>',
51
+ open: open
52
+ };
53
+ }());
54
+
55
+ }
@@ -0,0 +1,7 @@
1
+ module UrbHelper
2
+
3
+ def urb
4
+ render :partial => "urb/include"
5
+ end
6
+
7
+ end
@@ -0,0 +1 @@
1
+ <%= javascript_include_tag :urb %>
data/demo/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '4.0.1'
4
+ gem 'mysql2'
5
+ gem 'sass-rails', '~> 4.0.0'
6
+ gem 'uglifier', '>= 1.3.0'
7
+ gem 'coffee-rails', '~> 4.0.0'
8
+ gem 'jquery-rails'
9
+ gem 'turbolinks'
10
+ gem 'jbuilder', '~> 1.2'
11
+
12
+ gem 'urb', :path => '..'
13
+ gem 'pry'
data/demo/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
data/demo/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Demo::Application.load_tasks
File without changes
@@ -0,0 +1,16 @@
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 vendor/assets/javascripts of plugins, if any, 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.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require turbolinks
16
+ //= require_tree .
@@ -0,0 +1,13 @@
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 vendor/assets/stylesheets of plugins, if any, 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 top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
File without changes
@@ -0,0 +1,2 @@
1
+ class HomeController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
File without changes
File without changes
File without changes
@@ -0,0 +1,31 @@
1
+ <p>
2
+ <a href="/">
3
+ Home
4
+ </a>
5
+ /
6
+ <a href="/?p=today&f[]=paulengel&f[]=archan937">
7
+ Short URL
8
+ </a>
9
+ /
10
+ <a href="/?p=today&f[]=paulengel&f[]=archan937&f[]=URB&f[]=demo&f[]=Rails&f[]=Long%20URL&f[]=foo&f[]=bar&f[]=baz&f[]=Ownage&f[]=AwesomeStuff&bd[]=Paul.Engel&foobarbaz_id[]=3&foobarbaz_id[]=1&foobarbaz_id[]=4&foobarbaz_id[]=5&foobarbaz_id[]=6&foobarbaz_id[]=7&foobarbaz_id[]=67&foobarbaz_id[]=108&foobarbaz_id[]=66&foobarbaz_id[]=65&foobarbaz_id[]=118&foobarbaz_id[]=68&foobarbaz_id[]=8&foobarbaz_id[]=128&foobarbaz_id[]=79&foobarbaz_id[]=78&foobarbaz_id[]=111&foobarbaz_id[]=9&foobarbaz_id[]=10&foobarbaz_id[]=129&foobarbaz_id[]=11&foobarbaz_id[]=124&foobarbaz_id[]=12&foobarbaz_id[]=130&foobarbaz_id[]=13&foobarbaz_id[]=121&foobarbaz_id[]=14&foobarbaz_id[]=77&foobarbaz_id[]=80&foobarbaz_id[]=15&foobarbaz_id[]=69&foobarbaz_id[]=16&foobarbaz_id[]=17&foobarbaz_id[]=131&foobarbaz_id[]=18&foobarbaz_id[]=117&foobarbaz_id[]=19&foobarbaz_id[]=81&foobarbaz_id[]=82&foobarbaz_id[]=20&foobarbaz_id[]=21&foobarbaz_id[]=96&foobarbaz_id[]=97&foobarbaz_id[]=98&foobarbaz_id[]=99&foobarbaz_id[]=112&foobarbaz_id[]=64&foobarbaz_id[]=63&foobarbaz_id[]=62&foobarbaz_id[]=22&foobarbaz_id[]=23&foobarbaz_id[]=120&foobarbaz_id[]=24&foobarbaz_id[]=87&foobarbaz_id[]=88&foobarbaz_id[]=61&foobarbaz_id[]=60&foobarbaz_id[]=70&foobarbaz_id[]=71&foobarbaz_id[]=100&foobarbaz_id[]=101&foobarbaz_id[]=25&foobarbaz_id[]=26&foobarbaz_id[]=132&foobarbaz_id[]=73&foobarbaz_id[]=72&foobarbaz_id[]=56&foobarbaz_id[]=55&foobarbaz_id[]=74&foobarbaz_id[]=75&foobarbaz_id[]=133&foobarbaz_id[]=83&foobarbaz_id[]=84&foobarbaz_id[]=27&foobarbaz_id[]=107&foobarbaz_id[]=28&foobarbaz_id[]=134&foobarbaz_id[]=135&foobarbaz_id[]=136&foobarbaz_id[]=29&foobarbaz_id[]=119&foobarbaz_id[]=113&foobarbaz_id[]=105&foobarbaz_id[]=104&foobarbaz_id[]=114&foobarbaz_id[]=89&foobarbaz_id[]=103&foobarbaz_id[]=30&foobarbaz_id[]=137&foobarbaz_id[]=76&foobarbaz_id[]=90&foobarbaz_id[]=93&foobarbaz_id[]=92&foobarbaz_id[]=109&foobarbaz_id[]=110&foobarbaz_id[]=139&foobarbaz_id[]=31&foobarbaz_id[]=32&foobarbaz_id[]=140&foobarbaz_id[]=33&foobarbaz_id[]=123&foobarbaz_id[]=34&foobarbaz_id[]=141&foobarbaz_id[]=35&foobarbaz_id[]=115&foobarbaz_id[]=36&foobarbaz_id[]=142&foobarbaz_id[]=86&foobarbaz_id[]=85&foobarbaz_id[]=94&foobarbaz_id[]=95&foobarbaz_id[]=37&foobarbaz_id[]=38&foobarbaz_id[]=40&foobarbaz_id[]=39&foobarbaz_id[]=41&foobarbaz_id[]=42&foobarbaz_id[]=43&foobarbaz_id[]=44&foobarbaz_id[]=45&foobarbaz_id[]=102&foobarbaz_id[]=57&foobarbaz_id[]=58&foobarbaz_id[]=46&foobarbaz_id[]=47&foobarbaz_id[]=48&foobarbaz_id[]=49&foobarbaz_id[]=50&foobarbaz_id[]=59&foobarbaz_id[]=51&foobarbaz_id[]=122&foobarbaz_id[]=52&foobarbaz_id[]=53&foobarbaz_id[]=116&foobarbaz_id[]=54&foobarbaz_id[]=106&foobarbaz_id[]=2&foobarbaz_id[]=91&foobarbaz_id[]=138">
11
+ Long URL
12
+ </a>
13
+ /
14
+ <a href="http://LOCALHOST:3000?p=today&f[]=paulengel&f[]=archan937&f[]=URB&f[]=demo&f[]=Rails&f[]=Long%20URL&f[]=foo&f[]=bar&f[]=baz&f[]=Ownage&f[]=AwesomeStuff&bd[]=Paul.Engel&foobarbaz_id[]=3&foobarbaz_id[]=1&foobarbaz_id[]=4&foobarbaz_id[]=5&foobarbaz_id[]=6&foobarbaz_id[]=7&foobarbaz_id[]=67&foobarbaz_id[]=108&foobarbaz_id[]=66&foobarbaz_id[]=65&foobarbaz_id[]=118&foobarbaz_id[]=68&foobarbaz_id[]=8&foobarbaz_id[]=128&foobarbaz_id[]=79&foobarbaz_id[]=78&foobarbaz_id[]=111&foobarbaz_id[]=9&foobarbaz_id[]=10&foobarbaz_id[]=129&foobarbaz_id[]=11&foobarbaz_id[]=124&foobarbaz_id[]=12&foobarbaz_id[]=130&foobarbaz_id[]=13&foobarbaz_id[]=121&foobarbaz_id[]=14&foobarbaz_id[]=77&foobarbaz_id[]=80&foobarbaz_id[]=15&foobarbaz_id[]=69&foobarbaz_id[]=16&foobarbaz_id[]=17&foobarbaz_id[]=131&foobarbaz_id[]=18&foobarbaz_id[]=117&foobarbaz_id[]=19&foobarbaz_id[]=81&foobarbaz_id[]=82&foobarbaz_id[]=20&foobarbaz_id[]=21&foobarbaz_id[]=96&foobarbaz_id[]=97&foobarbaz_id[]=98&foobarbaz_id[]=99&foobarbaz_id[]=112&foobarbaz_id[]=64&foobarbaz_id[]=63&foobarbaz_id[]=62&foobarbaz_id[]=22&foobarbaz_id[]=23&foobarbaz_id[]=120&foobarbaz_id[]=24&foobarbaz_id[]=87&foobarbaz_id[]=88&foobarbaz_id[]=61&foobarbaz_id[]=60&foobarbaz_id[]=70&foobarbaz_id[]=71&foobarbaz_id[]=100&foobarbaz_id[]=101&foobarbaz_id[]=25&foobarbaz_id[]=26&foobarbaz_id[]=132&foobarbaz_id[]=73&foobarbaz_id[]=72&foobarbaz_id[]=56&foobarbaz_id[]=55&foobarbaz_id[]=74&foobarbaz_id[]=75&foobarbaz_id[]=133&foobarbaz_id[]=83&foobarbaz_id[]=84&foobarbaz_id[]=27&foobarbaz_id[]=107&foobarbaz_id[]=28&foobarbaz_id[]=134&foobarbaz_id[]=135&foobarbaz_id[]=136&foobarbaz_id[]=29&foobarbaz_id[]=119&foobarbaz_id[]=113&foobarbaz_id[]=105&foobarbaz_id[]=104&foobarbaz_id[]=114&foobarbaz_id[]=89&foobarbaz_id[]=103&foobarbaz_id[]=30&foobarbaz_id[]=137&foobarbaz_id[]=76&foobarbaz_id[]=90&foobarbaz_id[]=93&foobarbaz_id[]=92&foobarbaz_id[]=109&foobarbaz_id[]=110&foobarbaz_id[]=139&foobarbaz_id[]=31&foobarbaz_id[]=32&foobarbaz_id[]=140&foobarbaz_id[]=33&foobarbaz_id[]=123&foobarbaz_id[]=34&foobarbaz_id[]=141&foobarbaz_id[]=35&foobarbaz_id[]=115&foobarbaz_id[]=36&foobarbaz_id[]=142&foobarbaz_id[]=86&foobarbaz_id[]=85&foobarbaz_id[]=94&foobarbaz_id[]=95&foobarbaz_id[]=37&foobarbaz_id[]=38&foobarbaz_id[]=40&foobarbaz_id[]=39&foobarbaz_id[]=41&foobarbaz_id[]=42&foobarbaz_id[]=43&foobarbaz_id[]=44&foobarbaz_id[]=45&foobarbaz_id[]=102&foobarbaz_id[]=57&foobarbaz_id[]=58&foobarbaz_id[]=46&foobarbaz_id[]=47&foobarbaz_id[]=48&foobarbaz_id[]=49&foobarbaz_id[]=50&foobarbaz_id[]=59&foobarbaz_id[]=51&foobarbaz_id[]=122&foobarbaz_id[]=52&foobarbaz_id[]=53&foobarbaz_id[]=116&foobarbaz_id[]=54&foobarbaz_id[]=106&foobarbaz_id[]=2&foobarbaz_id[]=91&foobarbaz_id[]=138">
15
+ Same long URL
16
+ </a>
17
+ /
18
+ <a href="http://LOCALHOST:3000?p=today&f[]=paulengel&f[]=archan937&f[]=URB&f[]=demo&f[]=Rails&f[]=Long%20URL&f[]=foo&f[]=bar&f[]=baz&f[]=Ownage&f[]=AwesomeStuff&bd[]=Paul.Engel&foobarbaz_id[]=3&foobarbaz_id[]=1&foobarbaz_id[]=4&foobarbaz_id[]=5&foobarbaz_id[]=6&foobarbaz_id[]=7&foobarbaz_id[]=67&foobarbaz_id[]=108&foobarbaz_id[]=66&foobarbaz_id[]=65&foobarbaz_id[]=118&foobarbaz_id[]=68&foobarbaz_id[]=8&foobarbaz_id[]=128&foobarbaz_id[]=79&foobarbaz_id[]=78&foobarbaz_id[]=111&foobarbaz_id[]=9&foobarbaz_id[]=10&foobarbaz_id[]=129&foobarbaz_id[]=11&foobarbaz_id[]=124&foobarbaz_id[]=12&foobarbaz_id[]=130&foobarbaz_id[]=13&foobarbaz_id[]=121&foobarbaz_id[]=14&foobarbaz_id[]=77&foobarbaz_id[]=80&foobarbaz_id[]=15&foobarbaz_id[]=69&foobarbaz_id[]=16&foobarbaz_id[]=17&foobarbaz_id[]=131&foobarbaz_id[]=18&foobarbaz_id[]=117&foobarbaz_id[]=19&foobarbaz_id[]=81&foobarbaz_id[]=82&foobarbaz_id[]=20&foobarbaz_id[]=21&foobarbaz_id[]=96&foobarbaz_id[]=97&foobarbaz_id[]=98&foobarbaz_id[]=99&foobarbaz_id[]=112&foobarbaz_id[]=64&foobarbaz_id[]=63&foobarbaz_id[]=62&foobarbaz_id[]=22&foobarbaz_id[]=23&foobarbaz_id[]=120&foobarbaz_id[]=24&foobarbaz_id[]=87&foobarbaz_id[]=88&foobarbaz_id[]=61&foobarbaz_id[]=60&foobarbaz_id[]=70&foobarbaz_id[]=71&foobarbaz_id[]=100&foobarbaz_id[]=101&foobarbaz_id[]=25&foobarbaz_id[]=26&foobarbaz_id[]=132&foobarbaz_id[]=73&foobarbaz_id[]=72&foobarbaz_id[]=56&foobarbaz_id[]=55&foobarbaz_id[]=74&foobarbaz_id[]=75&foobarbaz_id[]=133&foobarbaz_id[]=83&foobarbaz_id[]=84&foobarbaz_id[]=27&foobarbaz_id[]=107&foobarbaz_id[]=28&foobarbaz_id[]=134&foobarbaz_id[]=135&foobarbaz_id[]=136&foobarbaz_id[]=29&foobarbaz_id[]=119&foobarbaz_id[]=113&foobarbaz_id[]=105&foobarbaz_id[]=104&foobarbaz_id[]=114&foobarbaz_id[]=89&foobarbaz_id[]=103&foobarbaz_id[]=30&foobarbaz_id[]=137&foobarbaz_id[]=76&foobarbaz_id[]=90&foobarbaz_id[]=93&foobarbaz_id[]=92&foobarbaz_id[]=109&foobarbaz_id[]=110&foobarbaz_id[]=139&foobarbaz_id[]=31&foobarbaz_id[]=32&foobarbaz_id[]=140&foobarbaz_id[]=33&foobarbaz_id[]=123&foobarbaz_id[]=34&foobarbaz_id[]=141&foobarbaz_id[]=35&foobarbaz_id[]=115&foobarbaz_id[]=36&foobarbaz_id[]=142&foobarbaz_id[]=86&foobarbaz_id[]=85&foobarbaz_id[]=94&foobarbaz_id[]=95&foobarbaz_id[]=37&foobarbaz_id[]=38&foobarbaz_id[]=40&foobarbaz_id[]=39&foobarbaz_id[]=41&foobarbaz_id[]=42&foobarbaz_id[]=43&foobarbaz_id[]=44&foobarbaz_id[]=45&foobarbaz_id[]=102&foobarbaz_id[]=57&foobarbaz_id[]=58&foobarbaz_id[]=46&foobarbaz_id[]=47&foobarbaz_id[]=48&foobarbaz_id[]=49&foobarbaz_id[]=50&foobarbaz_id[]=59&foobarbaz_id[]=51&foobarbaz_id[]=122&foobarbaz_id[]=52&foobarbaz_id[]=53&foobarbaz_id[]=116&foobarbaz_id[]=54&foobarbaz_id[]=106&foobarbaz_id[]=2">
19
+ Another long URL
20
+ </a>
21
+ /
22
+ <a href="http://github.com?p=today&f[]=paulengel&f[]=archan937">
23
+ Github
24
+ </a>
25
+ </p>
26
+ <p>
27
+ <%= controller.controller_name %>#<%= controller.action_name %>
28
+ </p>
29
+ <p>
30
+ <%= h params %>
31
+ </p>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>URB</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ <%= urb %>
9
+ </head>
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
data/demo/bin/bundle ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
data/demo/bin/rails ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
data/demo/bin/rake ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ # require 'active_record/railtie'
4
+ require 'action_controller/railtie'
5
+ require 'action_mailer/railtie'
6
+ require 'sprockets/railtie'
7
+ require 'rails/test_unit/railtie'
8
+
9
+ # Require the gems listed in Gemfile, including any gems
10
+ # you've limited to :test, :development, or :production.
11
+ Bundler.require(:default, Rails.env)
12
+
13
+ module Demo
14
+ class Application < Rails::Application
15
+ # Settings in config/environments/* take precedence over those specified here.
16
+ # Application configuration should go into files in config/initializers
17
+ # -- all .rb files in that directory are automatically loaded.
18
+
19
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
20
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
21
+ # config.time_zone = 'Central Time (US & Canada)'
22
+
23
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
24
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
25
+ # config.i18n.default_locale = :de
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,30 @@
1
+ # MySQL. Versions 4.1 and 5.0 are recommended.
2
+ #
3
+ # Install the MYSQL driver
4
+ # gem install mysql2
5
+ #
6
+ # Ensure the MySQL gem is defined in your Gemfile
7
+ # gem 'mysql2'
8
+ #
9
+ # And be sure to use new-style password hashing:
10
+ # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
11
+ development:
12
+ adapter: mysql2
13
+ host: 127.0.0.1
14
+ database: urb_development
15
+ username: root
16
+ pool: 5
17
+ encoding: utf8
18
+ local_infile: true
19
+
20
+ # Warning: The database defined as "test" will be erased and
21
+ # re-generated from your development database when you run "rake".
22
+ # Do not set this db to the same as development or production.
23
+ test:
24
+ adapter: mysql2
25
+ host: 127.0.0.1
26
+ database: urb_test
27
+ username: root
28
+ pool: 5
29
+ encoding: utf8
30
+ local_infile: true
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Demo::Application.initialize!
@@ -0,0 +1,29 @@
1
+ Demo::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ # config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end
@@ -0,0 +1,80 @@
1
+ Demo::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # Code is not reloaded between requests.
5
+ config.cache_classes = true
6
+
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both thread web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
14
+ config.consider_all_requests_local = false
15
+ config.action_controller.perform_caching = true
16
+
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
20
+ # config.action_dispatch.rack_cache = true
21
+
22
+ # Disable Rails's static asset server (Apache or nginx will already do this).
23
+ config.serve_static_assets = false
24
+
25
+ # Compress JavaScripts and CSS.
26
+ config.assets.js_compressor = :uglifier
27
+ # config.assets.css_compressor = :sass
28
+
29
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
30
+ config.assets.compile = false
31
+
32
+ # Generate digests for assets URLs.
33
+ config.assets.digest = true
34
+
35
+ # Version of your assets, change this if you want to expire all your assets.
36
+ config.assets.version = '1.0'
37
+
38
+ # Specifies the header that your server uses for sending files.
39
+ # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
40
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
41
+
42
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
43
+ # config.force_ssl = true
44
+
45
+ # Set to :debug to see everything in the log.
46
+ config.log_level = :info
47
+
48
+ # Prepend all log lines with the following tags.
49
+ # config.log_tags = [ :subdomain, :uuid ]
50
+
51
+ # Use a different logger for distributed setups.
52
+ # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
53
+
54
+ # Use a different cache store in production.
55
+ # config.cache_store = :mem_cache_store
56
+
57
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
58
+ # config.action_controller.asset_host = "http://assets.example.com"
59
+
60
+ # Precompile additional assets.
61
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
62
+ # config.assets.precompile += %w( search.js )
63
+
64
+ # Ignore bad email addresses and do not raise email delivery errors.
65
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
66
+ # config.action_mailer.raise_delivery_errors = false
67
+
68
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
69
+ # the I18n.default_locale when a translation can not be found).
70
+ config.i18n.fallbacks = true
71
+
72
+ # Send deprecation notices to registered listeners.
73
+ config.active_support.deprecation = :notify
74
+
75
+ # Disable automatic flushing of the log to improve performance.
76
+ # config.autoflush_log = false
77
+
78
+ # Use default logging formatter so that PID and timestamp are not suppressed.
79
+ config.log_formatter = ::Logger::Formatter.new
80
+ end