firefly 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in firefly.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ firefly (2.0.0.pre1)
5
+ dm-aggregates (~> 1.0.2)
6
+ dm-core (~> 1.0.2)
7
+ dm-migrations (~> 1.0.2)
8
+ dm-mysql-adapter (~> 1.0.2)
9
+ dm-transactions (~> 1.0.2)
10
+ haml (~> 3.0.18)
11
+ sinatra (~> 1.0)
12
+
13
+ GEM
14
+ remote: http://rubygems.org/
15
+ specs:
16
+ addressable (2.2.4)
17
+ data_objects (0.10.3)
18
+ addressable (~> 2.1)
19
+ dm-aggregates (1.0.2)
20
+ dm-core (~> 1.0.2)
21
+ dm-core (1.0.2)
22
+ addressable (~> 2.2)
23
+ extlib (~> 0.9.15)
24
+ dm-do-adapter (1.0.2)
25
+ data_objects (~> 0.10.2)
26
+ dm-core (~> 1.0.2)
27
+ dm-migrations (1.0.2)
28
+ dm-core (~> 1.0.2)
29
+ dm-mysql-adapter (1.0.2)
30
+ dm-do-adapter (~> 1.0.2)
31
+ do_mysql (~> 0.10.2)
32
+ dm-transactions (1.0.2)
33
+ dm-core (~> 1.0.2)
34
+ do_mysql (0.10.3)
35
+ data_objects (= 0.10.3)
36
+ extlib (0.9.15)
37
+ haml (3.0.25)
38
+ rack (1.2.1)
39
+ rack-test (0.5.7)
40
+ rack (>= 1.0)
41
+ rspec (1.3.1)
42
+ sinatra (1.1.2)
43
+ rack (~> 1.1)
44
+ tilt (~> 1.2)
45
+ tilt (1.2.2)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ firefly!
52
+ rack-test (~> 0.5.4)
53
+ rspec (~> 1.3.0)
data/HISTORY CHANGED
@@ -1,33 +1,40 @@
1
+ = HEAD
2
+
3
+ * 2011-02-01 Improved GUI [ariejan]
4
+ * 2011-02-01 Improved error handling / reporting [ariejan]
5
+ * 2011-01-31 Added a CodeFactory to generate unique short codes (and prevent collisions with custom short codes) [ariejan]
6
+ * 2011-01-30 Use dm-mysql-adapater as default, dm-sqlite-adapter is optional [ariejan]
7
+
1
8
  = 1.2.1/1.2.2 / 2011-01-26
2
9
 
3
10
  * 2011-01-26 - Added GUI support for custom short codes. [ariejan]
4
11
 
5
12
  = 1.2.0 / 2011-01-26
6
13
 
7
- * 2010-12-30 - Support for specifying one's own preferred short codes via the API. Also, invalid URL creations return a 422 code, not 200.
14
+ * 2010-12-30 - Support for specifying one's own preferred short codes via the API. Also, invalid URL creations return a 422 code, not 200. [ariejan]
8
15
  * 2010-12-30 - Make Barby optional to save some gems for those of us who don't need QR code generation. [mboeh]
9
16
 
10
17
  = 1.1.0 / 2010-10-02
11
18
 
12
- * 2010-10-02 - Generate a QR Code image when accessing http://:host/:code.png
19
+ * 2010-10-02 - Generate a QR Code image when accessing http://:host/:code.png [ariejan]
13
20
 
14
21
  = 1.0.0 / 2010-09-19
15
22
 
16
- * 2010-09-18 - Added better support for URLs with spaces and other special characters. Closes #19
23
+ * 2010-09-18 - Added better support for URLs with spaces and other special characters. Closes #19 [ariejan]
17
24
 
18
25
  = 0.4.5 / 2010-08-10
19
26
 
20
- * 2010-08-10 - Added sorting of shortened URLs. Closes #12.
21
- * 2010-08-10 - Added CSV, XML and YAML export of all shortened URLs. Closes #11.
22
- * 2010-08-10 - Updated bookmarklet JavaScript to escape URL-unsafe charachters in the API key. Fixes #17
27
+ * 2010-08-10 - Added sorting of shortened URLs. Closes #12. [ariejan]
28
+ * 2010-08-10 - Added CSV, XML and YAML export of all shortened URLs. Closes #11. [ariejan]
29
+ * 2010-08-10 - Updated bookmarklet JavaScript to escape URL-unsafe charachters in the API key. Fixes #17 [ariejan]
23
30
 
24
31
  = 0.4.4 / 2010-06-20
25
32
 
26
- * 2010-06-20 - Updated gem dependencies for DataMapper 1.0.0
33
+ * 2010-06-20 - Updated gem dependencies for DataMapper 1.0.0 [ariejan]
27
34
 
28
35
  = 0.4.3 / 2010-06-06
29
36
 
30
- * 2010-06-06 - Handle invalid API keys correctly.
37
+ * 2010-06-06 - Handle invalid API keys correctly. [ariejan]
31
38
 
32
39
  = 0.4.2 / 2010-06-06
33
40
 
data/README.md CHANGED
@@ -14,36 +14,34 @@ After you have installed the Firefly gem you should create a `config.ru` file th
14
14
 
15
15
  require 'rubygems'
16
16
  require 'firefly'
17
-
17
+
18
18
  disable :run
19
-
19
+
20
20
  app = Firefly::Server.new do
21
21
  # The domain you use for shortening.
22
- set :hostname, "localhost:3000"
22
+ set :hostname, "localhost:9393"
23
23
  # set :hostname, "aj.gs"
24
-
24
+
25
25
  # Used for authenticating you.
26
- set :api_key, "test"
27
-
28
- # Use Sqlite3 by default
29
- set :database, "sqlite3://#{Dir.pwd}/firefly.sqlite3"
30
-
31
- # You can use MySQL as well.
32
- # Make sure to install the do_mysql gem:
33
- # sudo gem install do_mysql
34
- # set :database, "mysql://root@localhost/firefly"
35
-
26
+ set :api_key, "changeme"
27
+
28
+ # Default MySQL:
29
+ set :database, "mysql://root:password@localhost/firefly"
30
+
31
+ # Use Sqlite3: gem install dm-sqlite-adapter
32
+ # set :database, "sqlite3://#{Dir.pwd}/firefly.sqlite3"
33
+
36
34
  # Set the number of recent urls to show in the overview.
37
35
  # Defaults to 25
38
36
  # set :recent_urls, 10
39
-
37
+
40
38
  # Set the tweet template.
41
39
  # The tag %short_url% will be replaced with the actual url.
42
40
  #
43
41
  # Default: Check this out: %short_url%
44
42
  # set :tweet, "I loved this: %short_url% - Go check it out now!"
45
43
  end
46
-
44
+
47
45
  run app
48
46
 
49
47
  Next you can start your web server. You may try thin:
@@ -90,17 +88,17 @@ If you're on a MacOSX you could add the following function to your `~/.profile`
90
88
  URL=$1
91
89
  SHORT_URL=`curl -s -d "url=$URL&api_key=test" http://localhost:3000/api/add`
92
90
  echo $SHORT_URL | pbcopy
93
-
91
+
94
92
  echo "-- $URL => $SHORT_URL"
95
93
  echo "Short URL copied to clipboard."
96
94
  }
97
-
95
+
98
96
  After you restart Terminal.app (or at least reload the `.profile` file) you can use it like this:
99
97
 
100
98
  $ shorten http://ariejan.net
101
99
  -- http://ariejan.net => http://aj.gs/1
102
100
  Short URL copied to clipboard.
103
-
101
+
104
102
  # Bugs, Feature Requests, etc.
105
103
 
106
104
  * [Source][5]
@@ -110,10 +108,11 @@ Feel free to fork Firefly and create patches for it. Here are some basic instruc
110
108
 
111
109
  * [Fork][7] Firefly
112
110
  * Create a topic branch - `git checkout -b my_branch`
111
+ * Write tests and code
113
112
  * Push to your branch - `git push origin my_branch`
114
- * Create an [Issue][8] with a link to your branch
113
+ * Create a GitHub Pull Request so I can merge your changes
115
114
  * That's it!
116
-
115
+
117
116
  [1]: http://ariejan.net/2010/07/12/screencast-firefly-url-shortener-in-less-than-25-minutes/
118
117
  [2]: http://ariejan.net/2010/06/06/setup-your-own-firefly-url-shortener-in-25-minutes/
119
118
  [3]: http://heroku.com
@@ -131,7 +130,7 @@ Feel free to fork Firefly and create patches for it. Here are some basic instruc
131
130
  # License
132
131
 
133
132
  Copyright (c) 2009 Ariejan de Vroom
134
-
133
+
135
134
  Permission is hereby granted, free of charge, to any person obtaining
136
135
  a copy of this software and associated documentation files (the
137
136
  "Software"), to deal in the Software without restriction, including
@@ -139,10 +138,10 @@ Feel free to fork Firefly and create patches for it. Here are some basic instruc
139
138
  distribute, sublicense, and/or sell copies of the Software, and to
140
139
  permit persons to whom the Software is furnished to do so, subject to
141
140
  the following conditions:
142
-
141
+
143
142
  The above copyright notice and this permission notice shall be
144
143
  included in all copies or substantial portions of the Software.
145
-
144
+
146
145
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
147
146
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
148
147
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
data/Rakefile CHANGED
@@ -1,31 +1,5 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gemspec|
7
- gemspec.name = "firefly"
8
- gemspec.summary = "FireFly is a simple URL shortner for personal use"
9
- gemspec.description = "FireFly is a simple URL shortner for personal use. It's powered by Sinatra and can be run with any Rack-capable web server."
10
- gemspec.email = "ariejan@ariejan.net"
11
- gemspec.homepage = "http://github.com/ariejan/firefly"
12
- gemspec.authors = ["Ariejan de Vroom"]
13
- gemspec.rubyforge_project = 'firefly'
14
- gemspec.add_dependency('sinatra', '~> 1.0')
15
- gemspec.add_dependency('dm-core', '~> 1.0.2')
16
- gemspec.add_dependency('dm-migrations', '~> 1.0.2')
17
- gemspec.add_dependency('dm-transactions', '~> 1.0.2')
18
- gemspec.add_dependency('dm-aggregates', '~> 1.0.2')
19
- gemspec.add_dependency('dm-sqlite-adapter', '~> 1.0.2')
20
- gemspec.add_dependency('haml', '~> 3.0.18')
21
-
22
- gemspec.add_development_dependency('rspec', '~> 1.3.0')
23
- gemspec.add_development_dependency('rack-test', '~> 0.5.4')
24
- end
25
- Jeweler::GemcutterTasks.new
26
- rescue LoadError
27
- puts "Jeweler not available. Install it with: gem install jeweler"
28
- end
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
29
3
 
30
4
  require 'spec/rake/spectask'
31
5
  Spec::Rake::SpecTask.new(:spec) do |spec|
@@ -39,6 +13,6 @@ Spec::Rake::SpecTask.new(:rcov) do |spec|
39
13
  spec.rcov = true
40
14
  end
41
15
 
42
- task :spec => :check_dependencies
16
+ task :spec
43
17
 
44
18
  task :default => :spec
data/config.ru.example CHANGED
@@ -6,17 +6,17 @@ disable :run
6
6
  app = Firefly::Server.new do
7
7
  set :hostname, "localhost:3000"
8
8
  set :api_key, "test"
9
-
9
+
10
10
  # Use Sqlite3 by default
11
11
  set :database, "sqlite3://#{Dir.pwd}/firefly.sqlite3"
12
-
12
+
13
13
  # Set number of recent urls to show
14
14
  set :recent_urls, 10
15
-
15
+
16
16
  # You can use MySQL as well.
17
17
  # Make sure to install the do_mysql gem:
18
18
  # sudo gem install do_mysql
19
19
  # set :database, "mysql://root@localhost/firefly"
20
20
  end
21
21
 
22
- run app
22
+ run app
data/firefly.gemspec CHANGED
@@ -1,104 +1,32 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "firefly/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{firefly}
8
- s.version = "1.2.2"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Ariejan de Vroom"]
12
- s.date = %q{2011-01-28}
6
+ s.name = "firefly"
7
+ s.version = Firefly::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Ariejan de Vroom"]
10
+ s.email = ["ariejan@ariejan.net"]
11
+ s.homepage = "http://github.com/ariejan/firefly"
12
+ s.summary = %q{FireFly is a simple URL shortner for personal use}
13
13
  s.description = %q{FireFly is a simple URL shortner for personal use. It's powered by Sinatra and can be run with any Rack-capable web server.}
14
- s.email = %q{ariejan@ariejan.net}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".gitignore",
21
- "HISTORY",
22
- "LICENSE",
23
- "README.md",
24
- "Rakefile",
25
- "VERSION",
26
- "config.ru.example",
27
- "firefly.gemspec",
28
- "lib/firefly.rb",
29
- "lib/firefly/base62.rb",
30
- "lib/firefly/config.rb",
31
- "lib/firefly/server.rb",
32
- "lib/firefly/url.rb",
33
- "lib/firefly/version.rb",
34
- "public/favicon.ico",
35
- "public/images/twitter.png",
36
- "public/jquery-1.4.2.min.js",
37
- "public/reset.css",
38
- "public/style.css",
39
- "spec/files/export.csv",
40
- "spec/files/export.xml",
41
- "spec/files/export.yml",
42
- "spec/firefly/api_spec.rb",
43
- "spec/firefly/base62_spec.rb",
44
- "spec/firefly/server_spec.rb",
45
- "spec/firefly/url_spec.rb",
46
- "spec/fixtures/urls.yml",
47
- "spec/spec.opts",
48
- "spec/spec_helper.rb",
49
- "views/index.haml",
50
- "views/info.haml",
51
- "views/layout.haml"
52
- ]
53
- s.homepage = %q{http://github.com/ariejan/firefly}
54
- s.rdoc_options = ["--charset=UTF-8"]
14
+
15
+ s.rubyforge_project = "firefly"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
55
20
  s.require_paths = ["lib"]
56
- s.rubyforge_project = %q{firefly}
57
- s.rubygems_version = %q{1.3.7}
58
- s.summary = %q{FireFly is a simple URL shortner for personal use}
59
- s.test_files = [
60
- "spec/firefly/api_spec.rb",
61
- "spec/firefly/base62_spec.rb",
62
- "spec/firefly/server_spec.rb",
63
- "spec/firefly/url_spec.rb",
64
- "spec/spec_helper.rb"
65
- ]
66
21
 
67
- if s.respond_to? :specification_version then
68
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
69
- s.specification_version = 3
22
+ s.add_runtime_dependency("sinatra", ["~> 1.0"])
23
+ s.add_runtime_dependency("dm-core", ["~> 1.0.2"])
24
+ s.add_runtime_dependency("dm-migrations", ["~> 1.0.2"])
25
+ s.add_runtime_dependency("dm-transactions", ["~> 1.0.2"])
26
+ s.add_runtime_dependency("dm-aggregates", ["~> 1.0.2"])
27
+ s.add_runtime_dependency("dm-mysql-adapter", ["~> 1.0.2"])
28
+ s.add_runtime_dependency("haml", ["~> 3.0.18"])
70
29
 
71
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
72
- s.add_runtime_dependency(%q<sinatra>, ["~> 1.0"])
73
- s.add_runtime_dependency(%q<dm-core>, ["~> 1.0.2"])
74
- s.add_runtime_dependency(%q<dm-migrations>, ["~> 1.0.2"])
75
- s.add_runtime_dependency(%q<dm-transactions>, ["~> 1.0.2"])
76
- s.add_runtime_dependency(%q<dm-aggregates>, ["~> 1.0.2"])
77
- s.add_runtime_dependency(%q<dm-sqlite-adapter>, ["~> 1.0.2"])
78
- s.add_runtime_dependency(%q<haml>, ["~> 3.0.18"])
79
- s.add_development_dependency(%q<rspec>, ["~> 1.3.0"])
80
- s.add_development_dependency(%q<rack-test>, ["~> 0.5.4"])
81
- else
82
- s.add_dependency(%q<sinatra>, ["~> 1.0"])
83
- s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
84
- s.add_dependency(%q<dm-migrations>, ["~> 1.0.2"])
85
- s.add_dependency(%q<dm-transactions>, ["~> 1.0.2"])
86
- s.add_dependency(%q<dm-aggregates>, ["~> 1.0.2"])
87
- s.add_dependency(%q<dm-sqlite-adapter>, ["~> 1.0.2"])
88
- s.add_dependency(%q<haml>, ["~> 3.0.18"])
89
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
90
- s.add_dependency(%q<rack-test>, ["~> 0.5.4"])
91
- end
92
- else
93
- s.add_dependency(%q<sinatra>, ["~> 1.0"])
94
- s.add_dependency(%q<dm-core>, ["~> 1.0.2"])
95
- s.add_dependency(%q<dm-migrations>, ["~> 1.0.2"])
96
- s.add_dependency(%q<dm-transactions>, ["~> 1.0.2"])
97
- s.add_dependency(%q<dm-aggregates>, ["~> 1.0.2"])
98
- s.add_dependency(%q<dm-sqlite-adapter>, ["~> 1.0.2"])
99
- s.add_dependency(%q<haml>, ["~> 3.0.18"])
100
- s.add_dependency(%q<rspec>, ["~> 1.3.0"])
101
- s.add_dependency(%q<rack-test>, ["~> 0.5.4"])
102
- end
30
+ s.add_development_dependency("rspec", ["~> 1.3.0"])
31
+ s.add_development_dependency("rack-test", ["~> 0.5.4"])
103
32
  end
104
-
Binary file
data/lib/firefly.rb CHANGED
@@ -11,7 +11,6 @@ begin
11
11
  require 'barby'
12
12
  require 'barby/outputter/png_outputter'
13
13
  rescue LoadError
14
-
15
14
  end
16
15
 
17
16
  $:.unshift(File.dirname(__FILE__)) unless
@@ -24,5 +23,7 @@ end
24
23
  require 'firefly/config'
25
24
  require 'firefly/version'
26
25
  require 'firefly/base62'
26
+ require 'firefly/code_factory'
27
27
  require 'firefly/url'
28
28
  require 'firefly/server'
29
+
@@ -0,0 +1,23 @@
1
+ module Firefly
2
+ class CodeFactory
3
+ include DataMapper::Resource
4
+
5
+ property :id, Serial
6
+ property :count, Integer, :default => 0
7
+
8
+ # Returns the next auto increment value and updates
9
+ # the counter
10
+ def self.next_code!
11
+ code = nil
12
+
13
+ Firefly::CodeFactory.transaction do
14
+ c = Firefly::CodeFactory.first
15
+ code = Firefly::Base62.encode(c.count + 1)
16
+ c.update(:count => c.count + 1)
17
+ end
18
+
19
+ code
20
+ end
21
+
22
+ end
23
+ end