firefly 0.3.1 → 0.4.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.
- data/HISTORY +13 -0
- data/README.md +17 -1
- data/VERSION +1 -1
- data/firefly.gemspec +3 -2
- data/lib/firefly/config.rb +2 -1
- data/lib/firefly/server.rb +14 -1
- data/public/images/twitter.png +0 -0
- data/public/style.css +8 -1
- data/views/index.haml +17 -7
- data/views/info.haml +13 -6
- data/views/layout.haml +3 -3
- metadata +5 -4
data/HISTORY
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
= HEAD
|
2
|
+
|
3
|
+
* 2010-04-14 - Added button to quickly tweet a URL. Closes #3 [ariejan]
|
4
|
+
|
5
|
+
* 2010-04-14 - Disable autocomplete and spellcheck for the big url input field. Closes #6 [ariejan]
|
6
|
+
|
7
|
+
* 2010-04-14 - After shortening an URL highlight the url that was added in the overview. [ariejan]
|
8
|
+
|
9
|
+
* 2010-04-14 - Made it easy to copy a short url from the overview. Closes #4 [ariejan]
|
10
|
+
|
11
|
+
* 2010-04-13 - Added links to source and issues in footer. [ariejan]
|
12
|
+
- Include domain name in page title. [ariejan]
|
13
|
+
|
1
14
|
= 0.3.1 / 2010-04-13
|
2
15
|
|
3
16
|
* 2010-04-13 - Fixed issue with setting `created_at` timestamp. [ariejan]
|
data/README.md
CHANGED
@@ -14,7 +14,11 @@ After you have installed the Firefly gem you should create a `config.ru` file th
|
|
14
14
|
disable :run
|
15
15
|
|
16
16
|
app = Firefly::Server.new do
|
17
|
+
# The domain you use for shortening.
|
17
18
|
set :hostname, "localhost:3000"
|
19
|
+
# set :hostname, "aj.gs"
|
20
|
+
|
21
|
+
# Used for authenticating you.
|
18
22
|
set :api_key, "test"
|
19
23
|
|
20
24
|
# Use Sqlite3 by default
|
@@ -24,6 +28,16 @@ After you have installed the Firefly gem you should create a `config.ru` file th
|
|
24
28
|
# Make sure to install the do_mysql gem:
|
25
29
|
# sudo gem install do_mysql
|
26
30
|
# set :database, "mysql://root@localhost/firefly"
|
31
|
+
|
32
|
+
# Set the number of recent urls to show in the overview.
|
33
|
+
# Defaults to 25
|
34
|
+
# set :recent_urls, 10
|
35
|
+
|
36
|
+
# Set the tweet template.
|
37
|
+
# The tag %short_url% will be replaced with the actual url.
|
38
|
+
#
|
39
|
+
# Default: Check this out: %short_url%
|
40
|
+
# set :tweet, "I loved this: %short_url% - Go check it out now!"
|
27
41
|
end
|
28
42
|
|
29
43
|
run app
|
@@ -41,8 +55,10 @@ All configuration is done in `config.ru`.
|
|
41
55
|
* `:hostname` sets the hostname to use for shortened URLs.
|
42
56
|
* `:api_key` sets the API key. This key is required when posting new URLs
|
43
57
|
* `:database` a database URI that [DataMapper][1] can understand.
|
58
|
+
* `:recent_urls` sets the number of URLs to show in the overview. Default: 25.
|
59
|
+
* `:tweet` set the template to use for tweets. Default: `"Check this out: %short_url%"`
|
44
60
|
|
45
|
-
It's possible to use all kinds of backends with DataMapper. Sqlite3 and MySQL have been tested, but others
|
61
|
+
It's possible to use all kinds of backends with DataMapper. Sqlite3 and MySQL have been tested, but others may work as well.
|
46
62
|
|
47
63
|
[1]: http://datamapper.org/
|
48
64
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/firefly.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{firefly}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.4.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ariejan de Vroom"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-14}
|
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
14
|
s.email = %q{ariejan@ariejan.net}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
"lib/firefly/url.rb",
|
34
34
|
"lib/firefly/version.rb",
|
35
35
|
"public/favicon.ico",
|
36
|
+
"public/images/twitter.png",
|
36
37
|
"public/jquery-1.4.2.min.js",
|
37
38
|
"public/reset.css",
|
38
39
|
"public/style.css",
|
data/lib/firefly/config.rb
CHANGED
data/lib/firefly/server.rb
CHANGED
@@ -59,14 +59,27 @@ module Firefly
|
|
59
59
|
|
60
60
|
return code, result
|
61
61
|
end
|
62
|
+
|
63
|
+
def is_highlighted?(url)
|
64
|
+
return false unless @highlight
|
65
|
+
@highlight == url.code
|
66
|
+
end
|
67
|
+
|
68
|
+
# Format a tweet
|
69
|
+
def tweet(url)
|
70
|
+
config[:tweet].gsub('%short_url%', url)
|
71
|
+
end
|
62
72
|
end
|
63
73
|
|
64
74
|
before do
|
65
75
|
@authenticated = has_valid_api_cookie?
|
66
76
|
@config = config
|
77
|
+
@highlight = nil
|
78
|
+
@title = "Firefly — #{@config[:hostname]}"
|
67
79
|
end
|
68
80
|
|
69
81
|
get '/' do
|
82
|
+
@highlight ||= params[:highlight]
|
70
83
|
@urls = Firefly::Url.all(:limit => config[:recent_urls], :order => [ :created_at.desc ])
|
71
84
|
haml :index
|
72
85
|
end
|
@@ -93,7 +106,7 @@ module Firefly
|
|
93
106
|
@result ||= "Invalid URL specified."
|
94
107
|
|
95
108
|
if params[:visual]
|
96
|
-
redirect "
|
109
|
+
redirect "/?highlight=#{@code}"
|
97
110
|
else
|
98
111
|
@result
|
99
112
|
end
|
Binary file
|
data/public/style.css
CHANGED
@@ -81,4 +81,11 @@ body { padding:0; margin:0; }
|
|
81
81
|
#main .sidebox { float: right; width: 320px; }
|
82
82
|
|
83
83
|
#main .the_form { margin-bottom: 30px; }
|
84
|
-
|
84
|
+
|
85
|
+
#main table tr td.value { white-space: nowrap; }
|
86
|
+
#main table tr.highlighted td.value { background-color: #ccffcc; }
|
87
|
+
#main table tr td.value.fill { width: 100%; white-space: normal; }
|
88
|
+
#main table tr td.value.center { text-align: center; }
|
89
|
+
#main table tr td.label { font-weight: bold; }
|
90
|
+
#main table tr td input.short_url { border: 1px solid #CCC; color: #666; font-family: Monaco, 'Courier New', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace; font-size: 11px; height: 16px; padding: 3px 5px 2px; width: 160px; }
|
91
|
+
#main table tr td img.twitter { border: 0; margin: 0; padding: 0; float: right; width: 16px; height: 16px; }
|
data/views/index.haml
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
%form{ :action => '/api/add', :method => 'post' }
|
15
15
|
%input{ :type => "hidden", :name => "visual", :value => "1" }
|
16
16
|
%p
|
17
|
-
%input.big_url{ :type => 'text', :name => 'url', :id => 'url', :size => 50 }
|
17
|
+
%input.big_url{ :type => 'text', :name => 'url', :id => 'url', :size => 50, :autocomplete => "off", :spellcheck => 'false' }
|
18
18
|
%p
|
19
19
|
%input.big_url{ :type => 'submit', :name => 'submit', :id => 'submit', :value => "Make it short!" }
|
20
20
|
|
@@ -26,14 +26,24 @@
|
|
26
26
|
%td.label Full URL
|
27
27
|
%td.label Clicks
|
28
28
|
%td.label Shortened at
|
29
|
+
%td.label
|
29
30
|
- @urls.each do |url|
|
30
|
-
%tr
|
31
|
-
%td.value
|
32
|
-
|
33
|
-
%td.value=
|
31
|
+
%tr{ :class => is_highlighted?(url) ? 'highlighted' : '' }
|
32
|
+
%td.value
|
33
|
+
%input{ :type => "text", :value => short_url(url), :class => 'short_url', :size => 21 }
|
34
|
+
%td.value.fill <a href="#{url.url}">#{url.url}</a>
|
35
|
+
%td.value.center= url.clicks
|
34
36
|
%td.value= url.created_at.strftime("%Y-%m-%d %H:%M")
|
35
|
-
|
36
|
-
|
37
|
+
%td.value
|
38
|
+
%a{ :href => "http://twitter.com/home?status=#{tweet(short_url(url))}" }
|
39
|
+
%img.twitter{ :src => "/images/twitter.png", :width => "16", :height => "16" }
|
40
|
+
|
41
|
+
:javascript
|
42
|
+
$(document).ready(function() {
|
43
|
+
$('input.short_url').each(function(index) {
|
44
|
+
$(this).mouseup(function() { $(this).select(); });
|
45
|
+
});
|
46
|
+
});
|
37
47
|
- else
|
38
48
|
%h1 Please enter your API key
|
39
49
|
|
data/views/info.haml
CHANGED
@@ -6,14 +6,21 @@
|
|
6
6
|
%table
|
7
7
|
%tr
|
8
8
|
%td.label Short URL
|
9
|
-
%td.value #{@short_url}
|
10
|
-
%tr
|
11
9
|
%td.label Full URL
|
12
|
-
%td.value <a href="#{@url.url}">#{@url.url}</a>
|
13
|
-
%tr
|
14
10
|
%td.label Clicks
|
15
|
-
%td.value= @url.clicks
|
16
|
-
%tr
|
17
11
|
%td.label Shortened at
|
12
|
+
|
13
|
+
%tr
|
14
|
+
%td.value
|
15
|
+
%input{ :type => "text", :value => short_url(@url), :class => 'short_url', :size => 21 }
|
16
|
+
%td.value.fill <a href="#{@url.url}">#{@url.url}</a>
|
17
|
+
%td.value.center= @url.clicks
|
18
18
|
%td.value= @url.created_at.strftime("%Y-%m-%d %H:%M")
|
19
|
+
|
20
|
+
:javascript
|
21
|
+
$(document).ready(function() {
|
22
|
+
$('input.short_url').each(function(index) {
|
23
|
+
$(this).mouseup(function() { $(this).select(); });
|
24
|
+
});
|
25
|
+
});
|
19
26
|
|
data/views/layout.haml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
!!!
|
2
2
|
%html
|
3
3
|
%head
|
4
|
-
%title
|
4
|
+
%title #{@title}
|
5
5
|
%meta(charset="UTF-8")
|
6
6
|
%link{ :rel => "stylesheet", :href => u('reset.css') }
|
7
7
|
%link{ :rel => "stylesheet", :href => u('style.css') }
|
@@ -10,11 +10,11 @@
|
|
10
10
|
.header
|
11
11
|
%ul.nav
|
12
12
|
%li.current
|
13
|
-
%a{ :href => '/' }
|
13
|
+
%a{ :href => '/' } #{@title}
|
14
14
|
|
15
15
|
#main
|
16
16
|
= yield
|
17
17
|
|
18
18
|
#footer
|
19
19
|
%p
|
20
|
-
Powered by <a href="http://github.com/ariejan/firefly">Firefly</a> v#{Firefly::Version}
|
20
|
+
Powered by <a href="http://github.com/ariejan/firefly">Firefly</a> v#{Firefly::Version} | <a href="http://github.com/ariejan/firefly/tree/v#{Firefly::Version}">Source</a> | <a href="http://github.com/ariejan/firefly/issues">Issues</a>
|
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
7
|
+
- 4
|
8
|
+
- 0
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ariejan de Vroom
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-14 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- lib/firefly/url.rb
|
142
142
|
- lib/firefly/version.rb
|
143
143
|
- public/favicon.ico
|
144
|
+
- public/images/twitter.png
|
144
145
|
- public/jquery-1.4.2.min.js
|
145
146
|
- public/reset.css
|
146
147
|
- public/style.css
|