web_translate_it_server 0.0.1
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/bin/wti-server +18 -0
- data/history.md +3 -0
- data/lib/public/screen.css +245 -0
- data/lib/views/index.erb +63 -0
- data/lib/web_translate_it_server.rb +56 -0
- data/license +22 -0
- data/readme.md +26 -0
- metadata +89 -0
data/bin/wti-server
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'trollop'
|
4
|
+
require 'web_translate_it_server'
|
5
|
+
|
6
|
+
options = Trollop::options do
|
7
|
+
banner <<-EOS
|
8
|
+
A synchronisation console for WebTranslateIt.
|
9
|
+
|
10
|
+
Usage: wti-server [options]+
|
11
|
+
|
12
|
+
[options] are:
|
13
|
+
EOS
|
14
|
+
opt :port, "Run server on a specific port", :default => 4000, :short => "-p"
|
15
|
+
opt :host, "Run server on a specific host", :default => "0.0.0.0", :short => "-h"
|
16
|
+
end
|
17
|
+
|
18
|
+
WebTranslateItServer.start(options[:host], options[:port])
|
data/history.md
ADDED
@@ -0,0 +1,245 @@
|
|
1
|
+
/*****************************************************************************/
|
2
|
+
/*
|
3
|
+
/* Common
|
4
|
+
/*
|
5
|
+
/*****************************************************************************/
|
6
|
+
|
7
|
+
/* Global Reset */
|
8
|
+
|
9
|
+
* {
|
10
|
+
margin: 0;
|
11
|
+
padding: 0;
|
12
|
+
}
|
13
|
+
|
14
|
+
html, body {
|
15
|
+
height: 100%;
|
16
|
+
}
|
17
|
+
|
18
|
+
body {
|
19
|
+
background-color: white;
|
20
|
+
font: 13.34px helvetica, arial, clean, sans-serif;
|
21
|
+
*font-size: small;
|
22
|
+
text-align: center;
|
23
|
+
}
|
24
|
+
|
25
|
+
h1, h2, h3, h4, h5, h6 {
|
26
|
+
font-size: 100%;
|
27
|
+
}
|
28
|
+
|
29
|
+
h1 {
|
30
|
+
margin-bottom: 1em;
|
31
|
+
}
|
32
|
+
|
33
|
+
h1 a {
|
34
|
+
text-decoration: none;
|
35
|
+
color: #000;
|
36
|
+
}
|
37
|
+
|
38
|
+
.failed, .color31 {
|
39
|
+
color: red !important;
|
40
|
+
}
|
41
|
+
|
42
|
+
.worked, .color32 {
|
43
|
+
color: green !important;
|
44
|
+
}
|
45
|
+
|
46
|
+
.errored, .color33 {
|
47
|
+
color: yellow !important;
|
48
|
+
}
|
49
|
+
|
50
|
+
p {
|
51
|
+
margin: 1em 0;
|
52
|
+
}
|
53
|
+
|
54
|
+
.update {
|
55
|
+
background-color: #DFF2BF;
|
56
|
+
border: 2px solid #4F8A10;
|
57
|
+
padding: 5px;
|
58
|
+
width: 300px;
|
59
|
+
line-height: 30px;
|
60
|
+
text-align: center;
|
61
|
+
}
|
62
|
+
|
63
|
+
select, input {
|
64
|
+
font-size: 16px;
|
65
|
+
}
|
66
|
+
|
67
|
+
a {
|
68
|
+
color: #00a;
|
69
|
+
}
|
70
|
+
|
71
|
+
a:hover {
|
72
|
+
color: black;
|
73
|
+
}
|
74
|
+
|
75
|
+
a:visited {
|
76
|
+
color: #a0a;
|
77
|
+
}
|
78
|
+
|
79
|
+
table {
|
80
|
+
font-size: inherit;
|
81
|
+
font: 100%;
|
82
|
+
border-collapse: collapse;
|
83
|
+
}
|
84
|
+
|
85
|
+
th {
|
86
|
+
text-align: center;
|
87
|
+
padding-right: 1em;
|
88
|
+
}
|
89
|
+
|
90
|
+
tr {
|
91
|
+
border-bottom: 1px solid #CCC;
|
92
|
+
}
|
93
|
+
|
94
|
+
td {
|
95
|
+
padding: .5em 1em;
|
96
|
+
}
|
97
|
+
|
98
|
+
.information {
|
99
|
+
background-color: #ffffc0;
|
100
|
+
color: #333;
|
101
|
+
padding: 5px;
|
102
|
+
}
|
103
|
+
|
104
|
+
/*****************************************************************************/
|
105
|
+
/*
|
106
|
+
/* Home
|
107
|
+
/*
|
108
|
+
/*****************************************************************************/
|
109
|
+
|
110
|
+
ul.posts {
|
111
|
+
list-style-type: none;
|
112
|
+
margin-bottom: 2em;
|
113
|
+
}
|
114
|
+
|
115
|
+
ul.posts li {
|
116
|
+
line-height: 1.75em;
|
117
|
+
}
|
118
|
+
|
119
|
+
ul.posts .date,
|
120
|
+
ul.posts .duration {
|
121
|
+
color: #aaa;
|
122
|
+
font-family: Monaco, "Courier New", monospace;
|
123
|
+
font-size: 80%;
|
124
|
+
}
|
125
|
+
|
126
|
+
/*****************************************************************************/
|
127
|
+
/*
|
128
|
+
/* Site
|
129
|
+
/*
|
130
|
+
/*****************************************************************************/
|
131
|
+
|
132
|
+
.site {
|
133
|
+
font-size: 110%;
|
134
|
+
text-align: justify;
|
135
|
+
width: 80%;
|
136
|
+
margin: 3em auto 2em auto;
|
137
|
+
line-height: 1.5em;
|
138
|
+
}
|
139
|
+
|
140
|
+
.title {
|
141
|
+
color: #a00;
|
142
|
+
font-weight: bold;
|
143
|
+
margin-bottom: 2em;
|
144
|
+
}
|
145
|
+
|
146
|
+
.site .title a {
|
147
|
+
color: #a00;
|
148
|
+
text-decoration: none;
|
149
|
+
}
|
150
|
+
|
151
|
+
.site .title a:hover {
|
152
|
+
color: black;
|
153
|
+
}
|
154
|
+
|
155
|
+
.site .title .extra {
|
156
|
+
color: #aaa;
|
157
|
+
text-decoration: none;
|
158
|
+
margin-left: 1em;
|
159
|
+
font-size: 0.9em;
|
160
|
+
}
|
161
|
+
|
162
|
+
.site .title a.extra:hover {
|
163
|
+
color: black;
|
164
|
+
}
|
165
|
+
|
166
|
+
.site .meta {
|
167
|
+
color: #aaa;
|
168
|
+
}
|
169
|
+
|
170
|
+
.site .footer {
|
171
|
+
font-size: 80%;
|
172
|
+
color: #666;
|
173
|
+
border-top: 4px solid #eee;
|
174
|
+
margin-top: 2em;
|
175
|
+
overflow: hidden;
|
176
|
+
}
|
177
|
+
|
178
|
+
.site .footer .contact {
|
179
|
+
float: left;
|
180
|
+
margin-right: 3em;
|
181
|
+
}
|
182
|
+
|
183
|
+
.site .footer .contact a {
|
184
|
+
color: #8085C1;
|
185
|
+
}
|
186
|
+
|
187
|
+
.site .footer .rss {
|
188
|
+
margin-top: 1.1em;
|
189
|
+
margin-right: -.2em;
|
190
|
+
float: right;
|
191
|
+
}
|
192
|
+
|
193
|
+
.site .footer .rss img {
|
194
|
+
border: 0;
|
195
|
+
}
|
196
|
+
|
197
|
+
/*****************************************************************************/
|
198
|
+
/*
|
199
|
+
/* Posts
|
200
|
+
/*
|
201
|
+
/*****************************************************************************/
|
202
|
+
|
203
|
+
#post {
|
204
|
+
|
205
|
+
}
|
206
|
+
|
207
|
+
/* standard */
|
208
|
+
|
209
|
+
#post pre {
|
210
|
+
border: 1px solid #ddd;
|
211
|
+
background-color: #eef;
|
212
|
+
padding: 0 .4em;
|
213
|
+
}
|
214
|
+
|
215
|
+
#post ul,
|
216
|
+
#post ol {
|
217
|
+
margin-left: 1.25em;
|
218
|
+
}
|
219
|
+
|
220
|
+
#post code {
|
221
|
+
border: 1px solid #ddd;
|
222
|
+
background-color: #eef;
|
223
|
+
font-size: 95%;
|
224
|
+
padding: 0 .2em;
|
225
|
+
}
|
226
|
+
|
227
|
+
#post pre code {
|
228
|
+
border: none;
|
229
|
+
}
|
230
|
+
|
231
|
+
/* terminal */
|
232
|
+
|
233
|
+
pre.terminal {
|
234
|
+
border: 1px solid black;
|
235
|
+
background-color: #333;
|
236
|
+
color: white;
|
237
|
+
padding: 5px;
|
238
|
+
overflow: auto;
|
239
|
+
word-wrap: break-word;
|
240
|
+
}
|
241
|
+
|
242
|
+
pre.terminal code {
|
243
|
+
font-family: 'Bitstream Vera Sans Mono', 'Courier', monospace;
|
244
|
+
background-color: #333;
|
245
|
+
}
|
data/lib/views/index.erb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<link href="<%= wti_root %>/screen.css" media="screen" rel="stylesheet" type="text/css" />
|
5
|
+
<link rel="shortcut icon" href="<%= wti_root %>/favicon.ico" type="image/x-icon" />
|
6
|
+
<title>Web Translate It Synchronisation Console</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div class="site">
|
10
|
+
<div class="title">
|
11
|
+
<a href="<%= wti_root %>/">Web Translate It Synchronisation Console</a>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div id="home">
|
15
|
+
<h1>Update</h1>
|
16
|
+
|
17
|
+
<div class="update">
|
18
|
+
Download files update for
|
19
|
+
<select name="locale" onchange="window.location=this.value;">
|
20
|
+
<option value="/" <%= "selected='true'" if locale == "" %>>All locales</option>
|
21
|
+
<% config.target_locales.each do |l| %>
|
22
|
+
<option value="/<%= l %>" <%= "selected='true'" if locale == l %>><%= l.upcase %></option>
|
23
|
+
<% end %>
|
24
|
+
</select>
|
25
|
+
<form method="post" action="<%= wti_root %>/pull/<%= locale %>">
|
26
|
+
<input type="submit" value="Update" onclick="if (window.hiddenCommit) { window.hiddenCommit.setAttribute('value', this.value); }else { hiddenCommit = document.createElement('input');hiddenCommit.type = 'hidden';hiddenCommit.value = this.value;hiddenCommit.name = this.name;this.form.appendChild(hiddenCommit); }this.setAttribute('originalValue', this.value);this.disabled = true;this.value='Please wait...';result = (this.form.onsubmit ? (this.form.onsubmit() ? this.form.submit() : false) : this.form.submit());if (result == false) { this.value = this.getAttribute('originalValue');this.disabled = false; }return result;" />
|
27
|
+
</form>
|
28
|
+
<div class="clear"></div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<% if config.before_pull %>
|
32
|
+
<p>
|
33
|
+
This command will be executed before pulling files:
|
34
|
+
<code><%= config.before_pull %></code>
|
35
|
+
</p>
|
36
|
+
<% end %>
|
37
|
+
<% if config.after_pull %>
|
38
|
+
<p>
|
39
|
+
This command will be executed after pulling files:
|
40
|
+
<code><%= config.after_pull %></code>
|
41
|
+
</p>
|
42
|
+
<% end %>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
<div class="footer">
|
46
|
+
<div class="contact">
|
47
|
+
<p>
|
48
|
+
<a href="http://docs.webtranslateit.com">Documentation</a><br/>
|
49
|
+
<a href="https://github.com/AtelierConvivialite/web_translate_it_server/">Source</a><br/>
|
50
|
+
<a href="https://github.com/AtelierConvivialite/web_translate_it_server/issues">Issues</a><br/>
|
51
|
+
<a href="http://twitter.com/webtranslateit">Twitter</a>
|
52
|
+
</p>
|
53
|
+
</div>
|
54
|
+
<div class="contact">
|
55
|
+
<p>
|
56
|
+
wti v.<%= WebTranslateIt::Util.version %><br/>
|
57
|
+
Built with <a href="http://sinatrarb.com/">Sinatra</a>
|
58
|
+
</p>
|
59
|
+
</div>
|
60
|
+
</div>
|
61
|
+
</div>
|
62
|
+
</body>
|
63
|
+
</html>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'sinatra/base'
|
3
|
+
require 'erb'
|
4
|
+
require 'web_translate_it'
|
5
|
+
|
6
|
+
class WebTranslateItServer < Sinatra::Base
|
7
|
+
attr_reader :config
|
8
|
+
|
9
|
+
dir = File.dirname(File.expand_path(__FILE__))
|
10
|
+
|
11
|
+
set :views, "#{dir}/views"
|
12
|
+
set :public, "#{dir}/public"
|
13
|
+
set :static, true
|
14
|
+
set :lock, true
|
15
|
+
|
16
|
+
helpers do
|
17
|
+
def wti_root
|
18
|
+
""
|
19
|
+
end
|
20
|
+
|
21
|
+
def highlight(value, expected)
|
22
|
+
return if value.nil?
|
23
|
+
print_value = value == true ? "Yes" : "No"
|
24
|
+
value == expected ? "<em>#{print_value}</em>" : "<em class=\"information\">#{print_value}</em>"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
get '/' do
|
29
|
+
@config = ::WebTranslateIt::Configuration.new('.')
|
30
|
+
erb :index, :locals => { :config => config, :locale => "" }
|
31
|
+
end
|
32
|
+
|
33
|
+
get '/:locale' do
|
34
|
+
@config = ::WebTranslateIt::Configuration.new('.')
|
35
|
+
erb :index, :locals => { :config => config, :locale => params[:locale] }
|
36
|
+
end
|
37
|
+
|
38
|
+
post '/pull/' do
|
39
|
+
`wti pull`
|
40
|
+
redirect "/"
|
41
|
+
end
|
42
|
+
|
43
|
+
post '/pull/:locale' do
|
44
|
+
`wti pull -l #{params[:locale]}`
|
45
|
+
redirect "/#{params[:locale]}"
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.start(host, port)
|
49
|
+
puts "Starting wti server on port #{port}..."
|
50
|
+
Dir::mkdir('log') unless FileTest::directory?('log')
|
51
|
+
logger = ::File.open("log/webtranslateit.log", "a+")
|
52
|
+
STDOUT.reopen(logger)
|
53
|
+
STDERR.reopen(logger)
|
54
|
+
WebTranslateItServer.run! :host => host, :port => port
|
55
|
+
end
|
56
|
+
end
|
data/license
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2011 Atelier Convivialité
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
17
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
19
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
20
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
21
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/readme.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Web Translate It Synchronisation Console
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
`wti-server` is a sinatra app you can use to run a friendly web interface to sync your translations. It allows a translation team to refresh the language files on a staging server without asking the developers to manually `wti pull`.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
gem install web_translate_it_server
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Go to the directory of the application you want to run the server on and do:
|
14
|
+
|
15
|
+
wti-server
|
16
|
+
|
17
|
+
By default, it starts an application on localhost on the port 4000. You will find the tool on `http://localhost:4000`.
|
18
|
+
|
19
|
+
Should you need to use another host or port, you can use the `-h` and `-p` options. For example: `wti server -p 1234`.
|
20
|
+
|
21
|
+
You may want to run some commands before or after syncing translations. You can use the hooks to do so. For instance, you could add the following in your `.wti` file:
|
22
|
+
|
23
|
+
before_pull: "echo 'some unix command'"
|
24
|
+
after_pull: "touch tmp/restart.txt"
|
25
|
+
|
26
|
+
`before_pull` and `after_pull` are respectively executed before and after pulling language files.
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: web_translate_it_server
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Édouard Brière
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-11-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: web_translate_it
|
16
|
+
requirement: &70234480962660 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.9'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70234480962660
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: trollop
|
27
|
+
requirement: &70234480961960 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.16.2
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70234480961960
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sinatra
|
38
|
+
requirement: &70234480961180 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 1.2.6
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70234480961180
|
47
|
+
description:
|
48
|
+
email: edouard@atelierconvivialite.com
|
49
|
+
executables:
|
50
|
+
- wti-server
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files:
|
53
|
+
- history.md
|
54
|
+
- readme.md
|
55
|
+
files:
|
56
|
+
- history.md
|
57
|
+
- license
|
58
|
+
- readme.md
|
59
|
+
- lib/public/screen.css
|
60
|
+
- lib/views/index.erb
|
61
|
+
- lib/web_translate_it_server.rb
|
62
|
+
- bin/wti-server
|
63
|
+
homepage: https://webtranslateit.com
|
64
|
+
licenses: []
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options:
|
67
|
+
- --main
|
68
|
+
- readme.md
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.8.11
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Synchonization server for webtranslateit.com.
|
89
|
+
test_files: []
|