rewritten 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +26 -8
- data/lib/rewritten/server/views/new.erb +1 -1
- data/lib/rewritten/server/views/to.erb +1 -1
- data/lib/rewritten/server/views/{mappings.erb → translations.erb} +6 -6
- data/lib/rewritten/server.rb +6 -6
- data/lib/rewritten/version.rb +1 -1
- data/rewritten.gemspec +17 -11
- metadata +7 -7
data/README.rdoc
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
= Rewritten
|
2
2
|
|
3
3
|
Rewritten is a lookup-based rewriting engine that rewrites requested
|
4
|
-
URLs on the fly. The URL manipulations depend on
|
4
|
+
URLs on the fly. The URL manipulations depend on translations found in
|
5
5
|
a redis database.
|
6
6
|
|
7
|
-
If a matching translation is found, the result is either a
|
8
|
-
|
9
|
-
|
7
|
+
If a matching translation is found, the result of a request is either a
|
8
|
+
redirection or a modification of path and request parameters. For URLs
|
9
|
+
without translation entries the request is left unmodified.
|
10
10
|
|
11
11
|
Rewritten takes larges parts from the Resque codebase (which rocks). The
|
12
12
|
gem is compromised of four parts:
|
@@ -14,9 +14,19 @@ gem is compromised of four parts:
|
|
14
14
|
1. A Ruby library for creating, modifying and querying translations
|
15
15
|
2. A Sinatra app for displaying and managing translations
|
16
16
|
3. A Rack app for rewriting and redirecting request (Rack::Rewritten::Url)
|
17
|
-
4. A Rack app for substituting URLs in HTML pages with their current translation (Rack::Rewritten
|
17
|
+
4. A Rack app for substituting URLs in HTML pages with their current translation (Rack::Rewritten::Html)
|
18
18
|
5. A Rack app for recording successful request (Rack::Rewritten::Record)
|
19
19
|
|
20
|
+
|
21
|
+
== New Relic Notice
|
22
|
+
|
23
|
+
There seem to be unresolved issues when Rack::Rewritten::Html is used
|
24
|
+
in conjunction with the New Relic gem (being a rack app as well).
|
25
|
+
Unfortunately the only workaround so far is either disabling New Relic
|
26
|
+
or Rack::Rewritten::Html (pointers in the right debugging direction or
|
27
|
+
pull requests are welcome).
|
28
|
+
|
29
|
+
|
20
30
|
== Overview
|
21
31
|
|
22
32
|
The Rewritten library allows you to create new URL translations and
|
@@ -33,18 +43,25 @@ Translations are removed in a similar fashion.
|
|
33
43
|
|
34
44
|
== Usage in your Rack stack
|
35
45
|
|
46
|
+
To take full advantage of the engine you would use both, the URL and
|
47
|
+
HTML, rack apps as follows:
|
48
|
+
|
36
49
|
use Rack::Rewritten::Url
|
37
50
|
use Rack::Rewritten::Html
|
38
51
|
run Your::App
|
39
52
|
|
53
|
+
This way the URL rewriting and generation is stays decoupled from your
|
54
|
+
app. For a Rails app, for instance, you wouldn't need to mess with your
|
55
|
+
<tt>routes.rb</tt> or path helpers when dealing with custom URLs.
|
56
|
+
|
40
57
|
|
41
58
|
== The Front End
|
42
59
|
|
43
60
|
Rewritten comes with a Sinatra-based front end for dislaying and
|
44
|
-
managing your URL translations (in the familiar Resque
|
61
|
+
managing your URL translations (in the familiar Resque layout).
|
45
62
|
|
63
|
+
[IMAGE]
|
46
64
|
|
47
|
-
[PICTURE]
|
48
65
|
|
49
66
|
=== Standalone
|
50
67
|
|
@@ -65,7 +82,8 @@ run Rack::URLMap.new \
|
|
65
82
|
"/" => Your::App.new,
|
66
83
|
"/resque" => Rewritten::Server.new
|
67
84
|
|
68
|
-
Check
|
85
|
+
Check lib/test.ru for a functional example.
|
86
|
+
|
69
87
|
|
70
88
|
|
71
89
|
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
<div style="float: left; margin-top: 10px">
|
7
|
-
<form method="POST" action="<%= u "/
|
7
|
+
<form method="POST" action="<%= u "/translations" %>">
|
8
8
|
<label>From:</label><br/> <input type="text" name="from" /> <br />
|
9
9
|
<label>To:</label><br/> <input type="text" name="to" value="<%= params[:to] %>" /> <br />
|
10
10
|
<input type="submit" value="Create" />
|
@@ -32,15 +32,15 @@
|
|
32
32
|
|
33
33
|
<h1 class='wi'>Translations</h1>
|
34
34
|
|
35
|
-
<p class='intro'>The list below contains all the registered translations from
|
36
|
-
url to target url.
|
37
|
-
target.</p>
|
35
|
+
<p class='intro'>The list below contains all the registered translations from an
|
36
|
+
url to target url. To view all translations for a target click on the
|
37
|
+
target URL.</p>
|
38
38
|
|
39
|
-
<a href="<%= u('/new') %>"> + New
|
39
|
+
<a href="<%= u('/new') %>"> + New Translation </a>
|
40
40
|
|
41
41
|
<p class='sub'>Showing <%= (start = params[:start].to_i)+1 %> to <%= start + Rewritten.per_page %> of <b><%=size = Rewritten.size('froms')%></b> translations. </p>
|
42
42
|
|
43
|
-
<table class='
|
43
|
+
<table class=''>
|
44
44
|
<tr>
|
45
45
|
<th>from URL (Browser Location)</th>
|
46
46
|
<th>to URL (Your App)</th>
|
@@ -49,7 +49,7 @@
|
|
49
49
|
<% for mapping in Rewritten.list_range("froms", params[:start].to_i, Rewritten.per_page) %>
|
50
50
|
<tr>
|
51
51
|
<td class=''><a href="<%= mapping %>" target="new"><%= mapping %></td>
|
52
|
-
<td class='
|
52
|
+
<td class=''><a href="<%= u("/to?to=#{to=Rewritten.redis.get("from:#{mapping}")}") %>"><%= to %></td>
|
53
53
|
</tr>
|
54
54
|
<% end %>
|
55
55
|
|
data/lib/rewritten/server.rb
CHANGED
@@ -139,21 +139,21 @@ module Rewritten
|
|
139
139
|
|
140
140
|
|
141
141
|
get "/?" do
|
142
|
-
redirect url_path(:
|
142
|
+
redirect url_path(:translations)
|
143
143
|
end
|
144
144
|
|
145
|
-
get "/
|
146
|
-
show '
|
145
|
+
get "/translations" do
|
146
|
+
show 'translations'
|
147
147
|
end
|
148
148
|
|
149
149
|
get "/new" do
|
150
150
|
show "new"
|
151
151
|
end
|
152
152
|
|
153
|
-
post "/
|
153
|
+
post "/translations" do
|
154
154
|
if params[:from]!='' && params[:to]!=''
|
155
155
|
Rewritten.add_translation(params[:from], params[:to])
|
156
|
-
redirect u('
|
156
|
+
redirect u('translations')
|
157
157
|
else
|
158
158
|
show "new"
|
159
159
|
end
|
@@ -200,7 +200,7 @@ module Rewritten
|
|
200
200
|
|
201
201
|
def self.tabs
|
202
202
|
#@tabs ||= ["Overview", "Working", "Failed", "Queues", "Workers", "Stats"]
|
203
|
-
@tabs ||= ["
|
203
|
+
@tabs ||= ["Translations", "Hits"]
|
204
204
|
end
|
205
205
|
|
206
206
|
end
|
data/lib/rewritten/version.rb
CHANGED
data/rewritten.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Kai Rubarth"]
|
9
9
|
s.email = ["kai@doxter.de"]
|
10
10
|
s.homepage = ""
|
11
|
-
s.summary = %q{
|
11
|
+
s.summary = %q{A redis-based URL rewriting engine}
|
12
12
|
|
13
13
|
s.rubyforge_project = "rewritten"
|
14
14
|
|
@@ -23,16 +23,22 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "multi_json", "~> 1.0"
|
24
24
|
|
25
25
|
s.description = <<description
|
26
|
-
Rewritten is a
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
26
|
+
Rewritten is a lookup-based rewriting engine that rewrites requested
|
27
|
+
URLs on the fly. The URL manipulations depend on translations found in
|
28
|
+
a redis database.
|
29
|
+
|
30
|
+
If a matching translation is found, the result of a request is either a
|
31
|
+
redirection or a modification of path and request parameters. For URLs
|
32
|
+
without translation entries the request is left unmodified.
|
33
|
+
|
34
|
+
Rewritten takes larges parts from the Resque codebase (which rocks). The
|
35
|
+
gem is compromised of four parts:
|
36
|
+
|
37
|
+
1. A Ruby library for creating, modifying and querying translations
|
38
|
+
2. A Sinatra app for displaying and managing translations
|
39
|
+
3. A Rack app for rewriting and redirecting request (Rack::Rewritten::Url)
|
40
|
+
4. A Rack app for substituting URLs in HTML pages with their current translation (Rack::Rewritten::Html)
|
41
|
+
5. A Rack app for recording successful request (Rack::Rewritten::Record)
|
36
42
|
description
|
37
43
|
|
38
44
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rewritten
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kai Rubarth
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-06 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
version: "1.0"
|
82
82
|
type: :runtime
|
83
83
|
version_requirements: *id004
|
84
|
-
description: " Rewritten is a
|
84
|
+
description: " Rewritten is a lookup-based rewriting engine that rewrites requested\n URLs on the fly. The URL manipulations depend on translations found in\n a redis database.\n\n If a matching translation is found, the result of a request is either a\n redirection or a modification of path and request parameters. For URLs\n without translation entries the request is left unmodified.\n\n Rewritten takes larges parts from the Resque codebase (which rocks). The\n gem is compromised of four parts:\n\n 1. A Ruby library for creating, modifying and querying translations\n 2. A Sinatra app for displaying and managing translations\n 3. A Rack app for rewriting and redirecting request (Rack::Rewritten::Url)\n 4. A Rack app for substituting URLs in HTML pages with their current translation (Rack::Rewritten::Html)\n 5. A Rack app for recording successful request (Rack::Rewritten::Record)\n"
|
85
85
|
email:
|
86
86
|
- kai@doxter.de
|
87
87
|
executables:
|
@@ -123,13 +123,13 @@ files:
|
|
123
123
|
- lib/rewritten/server/views/key_sets.erb
|
124
124
|
- lib/rewritten/server/views/key_string.erb
|
125
125
|
- lib/rewritten/server/views/layout.erb
|
126
|
-
- lib/rewritten/server/views/mappings.erb
|
127
126
|
- lib/rewritten/server/views/new.erb
|
128
127
|
- lib/rewritten/server/views/next_more.erb
|
129
128
|
- lib/rewritten/server/views/overview.erb
|
130
129
|
- lib/rewritten/server/views/queues.erb
|
131
130
|
- lib/rewritten/server/views/stats.erb
|
132
131
|
- lib/rewritten/server/views/to.erb
|
132
|
+
- lib/rewritten/server/views/translations.erb
|
133
133
|
- lib/rewritten/server/views/workers.erb
|
134
134
|
- lib/rewritten/server/views/working.erb
|
135
135
|
- lib/rewritten/version.rb
|
@@ -169,6 +169,6 @@ rubyforge_project: rewritten
|
|
169
169
|
rubygems_version: 1.6.2
|
170
170
|
signing_key:
|
171
171
|
specification_version: 3
|
172
|
-
summary:
|
172
|
+
summary: A redis-based URL rewriting engine
|
173
173
|
test_files: []
|
174
174
|
|