teamster 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -4
- data/VERSION +1 -1
- data/bin/teamster +24 -233
- data/lib/teamster/base_module.rb +6 -2
- data/lib/teamster-cli.rb +237 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efa78525723570ac964b9cde25d7188e4cbcc2fc
|
4
|
+
data.tar.gz: 0df540f5059c29981a08704f42425bb56dcfb8eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e48c0e5723c8aabecb87c897300db7037ef86057bd87e9cd2e666b07012346567fadbd8f44c1fbabc8ded588ddcbaa35a92720f959ed675d344c6937ea27cd9b
|
7
|
+
data.tar.gz: 9852bdffc5ef8d64fc424328445ec5f0f0ed65bfc64141ce510fe8e8a35212a303cf919335a256c1c64ca002bf036b9f5ddfa20ee49056eefa79d153ea6a6663
|
data/README.md
CHANGED
@@ -22,6 +22,10 @@ Teamster has been packaged into a gem. To install, simply run `gem install teams
|
|
22
22
|
|
23
23
|
Open a browser and point to http://localhost:9292. A bare teamster page should be shown.
|
24
24
|
|
25
|
+
#### Login Credentials
|
26
|
+
|
27
|
+
Right now, the default login credential is "Administrator/password". There is no way to create new users, short of modifying the users file directly.
|
28
|
+
|
25
29
|
|
26
30
|
## Running In A "Production" Environment
|
27
31
|
|
@@ -65,8 +69,17 @@ This will create the following files in your site folder:
|
|
65
69
|
* lib/teamster-modules/MODULENAME.rb
|
66
70
|
* lib/teamster-modules/MODULENAME/views/MODULENAME.erb
|
67
71
|
|
68
|
-
In MODULENAME.rb, a class MODULENAME will be created.
|
72
|
+
In MODULENAME.rb, a class MODULENAME will be created. It is subclassed from Sinatra::Base and it also includes some helper class methods from Teamster::Modules::BaseModule. When developing it, you can treat it just like a Sinatra web application.
|
73
|
+
|
74
|
+
#### Conventions To Adhere To
|
75
|
+
|
76
|
+
Your teamster module application should reside in the `lib/teamster-modules` folder, and all other files should be in the `lib/teamster-modules/<modulename>` folder. Thie will help greatly when importing and exporting. If you need to modulename configuration, data or other content, please store them in subfolders, for example, `lib/teamster-modules/<modulename>/conf`.
|
77
|
+
|
78
|
+
The only exception to this rule are css & javascript files. Name your files as `<modulename>.css` & `<modulename>.js` and place them in the public/css & public/js folders respectively.
|
79
|
+
|
80
|
+
When creating HTTP routes, your base route should always be `/<modulename>`. Other routes for your teamster module should be children of this route.
|
69
81
|
|
82
|
+
When creating views, your summary view should be named `<modulename>_summary.erb` in lowercase. It is highly encouraged for other views of the same module to be prepended with `<modulename>_`.
|
70
83
|
|
71
84
|
#### Helpers Available To Modules
|
72
85
|
|
@@ -78,9 +91,9 @@ This returns `true` or `false`. Useful to check if a user has logged in.
|
|
78
91
|
|
79
92
|
get '/login_checker' do
|
80
93
|
if logged_in?
|
81
|
-
|
94
|
+
"User has logged in."
|
82
95
|
else
|
83
|
-
|
96
|
+
"You are not logged in."
|
84
97
|
end
|
85
98
|
end
|
86
99
|
|
@@ -95,7 +108,7 @@ This halts a route from being run if a user has not yet logged in. Once a user h
|
|
95
108
|
|
96
109
|
* **current_user**
|
97
110
|
|
98
|
-
This just returns the username
|
111
|
+
This just returns the username of the currently logged in user.
|
99
112
|
|
100
113
|
get '/show_name' do
|
101
114
|
login_required
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.1
|
data/bin/teamster
CHANGED
@@ -5,6 +5,7 @@ require 'getoptlong'
|
|
5
5
|
require 'yaml'
|
6
6
|
require 'bcrypt'
|
7
7
|
require 'base64'
|
8
|
+
require "#{File.dirname(__FILE__)}/../lib/teamster-cli"
|
8
9
|
|
9
10
|
DEFAULT_UNIX_SOCKET_FILE = '/tmp/teamster.app.sock'
|
10
11
|
DEFAULT_APP_STATE_FILE = '/srv/my-site/teamster.app.state'
|
@@ -12,6 +13,8 @@ CONFIG_FILE = 'conf/teamster.conf'
|
|
12
13
|
VERSION = File.read(File.dirname(__FILE__) + '/../VERSION')
|
13
14
|
|
14
15
|
class TeamsterApp
|
16
|
+
include Teamster::CLI
|
17
|
+
|
15
18
|
class << self
|
16
19
|
def read_options_and_run
|
17
20
|
read_options
|
@@ -25,9 +28,6 @@ class TeamsterApp
|
|
25
28
|
["--prod", GetoptLong::NO_ARGUMENT ],
|
26
29
|
["--help", GetoptLong::NO_ARGUMENT ],
|
27
30
|
["--overwrite", GetoptLong::NO_ARGUMENT ],
|
28
|
-
["--create-module", GetoptLong::REQUIRED_ARGUMENT],
|
29
|
-
["--import-module", GetoptLong::REQUIRED_ARGUMENT],
|
30
|
-
["--export-module", GetoptLong::REQUIRED_ARGUMENT],
|
31
31
|
["--socket-file", GetoptLong::REQUIRED_ARGUMENT],
|
32
32
|
["--state-file", GetoptLong::REQUIRED_ARGUMENT])
|
33
33
|
@config = {}.tap do |hsh|
|
@@ -45,15 +45,10 @@ class TeamsterApp
|
|
45
45
|
quit detailed_usage
|
46
46
|
elsif @config[:version]
|
47
47
|
quit show_version
|
48
|
-
elsif
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
elsif name = @config[:export_module]
|
53
|
-
export_module_for name.downcase
|
54
|
-
elsif ARGV.size == 1
|
55
|
-
command = ARGV.first.to_sym
|
56
|
-
send command
|
48
|
+
elsif ARGV.size > 0
|
49
|
+
command = ARGV.shift.to_sym
|
50
|
+
args = ARGV
|
51
|
+
send command, *args
|
57
52
|
else
|
58
53
|
quit usage
|
59
54
|
end
|
@@ -63,13 +58,14 @@ class TeamsterApp
|
|
63
58
|
|
64
59
|
# --{ COMMANDS }-- #
|
65
60
|
|
66
|
-
def init
|
61
|
+
def init(*args)
|
67
62
|
current_working_folder = Dir.pwd
|
63
|
+
team_name = args[0]
|
68
64
|
content = File.dirname(__FILE__) + '/../content'
|
69
65
|
puts "Initializing Teamster in current folder."
|
70
66
|
puts "Creating required content..."
|
71
67
|
FileUtils.mkdir_p "conf"
|
72
|
-
create_config
|
68
|
+
create_config team_name
|
73
69
|
FileUtils.mkdir_p "data"
|
74
70
|
create_user
|
75
71
|
FileUtils.cp_r "#{content}/views", current_working_folder
|
@@ -78,11 +74,11 @@ class TeamsterApp
|
|
78
74
|
FileUtils.mkdir_p "lib/teamster-modules"
|
79
75
|
create_file "lib/teamster-modules.rb", "teamster_modules"
|
80
76
|
puts "Teamster initialized!"
|
81
|
-
puts "- Run \"teamster
|
77
|
+
puts "- Run \"teamster create <NAME>\" to create a placeholder module."
|
82
78
|
puts "- Run \"teamster start\" to start teamster!"
|
83
79
|
end
|
84
80
|
|
85
|
-
def start
|
81
|
+
def start(*)
|
86
82
|
puts "Starting teamster..."
|
87
83
|
if File.exists?(CONFIG_FILE)
|
88
84
|
if @config[:prod]
|
@@ -97,7 +93,7 @@ class TeamsterApp
|
|
97
93
|
end
|
98
94
|
end
|
99
95
|
|
100
|
-
def stop
|
96
|
+
def stop(*)
|
101
97
|
puts "Stopping teamster..."
|
102
98
|
state_file = @config[:state_file] || DEFAULT_APP_STATE_FILE
|
103
99
|
if File.exists? state_file
|
@@ -108,7 +104,7 @@ class TeamsterApp
|
|
108
104
|
end
|
109
105
|
end
|
110
106
|
|
111
|
-
def restart
|
107
|
+
def restart(*)
|
112
108
|
puts "Restarting teamster..."
|
113
109
|
state_file = @config[:state_file] || DEFAULT_APP_STATE_FILE
|
114
110
|
if File.exists? state_file
|
@@ -118,228 +114,23 @@ class TeamsterApp
|
|
118
114
|
end
|
119
115
|
end
|
120
116
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
warn msg
|
125
|
-
exit code
|
126
|
-
end
|
127
|
-
|
128
|
-
def create_config
|
129
|
-
ask_user_for :title, "What is your team name"
|
130
|
-
File.open(CONFIG_FILE, 'w') {|fh| fh.write @config.to_yaml}
|
117
|
+
def create(*args)
|
118
|
+
name = args[0]
|
119
|
+
create_module_for name.downcase
|
131
120
|
end
|
132
121
|
|
133
|
-
def
|
134
|
-
|
135
|
-
|
136
|
-
File.open("./data/users", "w") do |fh|
|
137
|
-
fh.write({"users" => users}.to_yaml)
|
138
|
-
end
|
139
|
-
FileUtils.chmod 0600, './data/users'
|
140
|
-
end
|
141
|
-
|
142
|
-
def b64_enc(obj)
|
143
|
-
Base64.strict_encode64(obj)
|
122
|
+
def import(*args)
|
123
|
+
name = args[0]
|
124
|
+
import_module_for name.downcase
|
144
125
|
end
|
145
126
|
|
146
|
-
def
|
147
|
-
|
148
|
-
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
def ask_user(question)
|
153
|
-
print "#{question}: "
|
154
|
-
STDIN.gets.strip
|
155
|
-
end
|
156
|
-
|
157
|
-
def create_module_for(name)
|
158
|
-
puts "Creating placeholders for module #{name}...\n"
|
159
|
-
FileUtils.mkdir_p "lib/teamster-modules/#{name}/views"
|
160
|
-
create_file "lib/teamster-modules/#{name}.rb", "module_placeholder_for", name
|
161
|
-
create_file "lib/teamster-modules/#{name}/#{name}_helper.rb", "module_helper_placeholder_for", name
|
162
|
-
create_file "lib/teamster-modules/#{name}/views/#{name}.erb", "view_placeholder_for", name
|
163
|
-
create_file "lib/teamster-modules/#{name}/views/#{name}_summary.erb", "view_summary_placeholder_for", name
|
164
|
-
puts "\nBasic module creation done!"
|
165
|
-
puts "Controller : \"lib/teamster-modules/#{name}.rb\""
|
166
|
-
puts "Helper : \"lib/teamster-modules/#{name}/#{name}_helper.rb\""
|
167
|
-
puts "View : \"lib/teamster-modules/#{name}/views/#{name}.erb\""
|
168
|
-
puts "Summary View : \"lib/teamster-modules/#{name}/views/#{name}_summary.erb\""
|
169
|
-
end
|
170
|
-
|
171
|
-
def import_module_for(name)
|
172
|
-
puts "Importing module: #{name}"
|
173
|
-
zip_file = "#{name}.zip"
|
174
|
-
if File.exists?(zip_file)
|
175
|
-
if `which unzip`.length != 0
|
176
|
-
`unzip #{zip_file}`
|
177
|
-
puts "\nSuccessfully imported #{name}. Please restart teamster to use."
|
178
|
-
else
|
179
|
-
puts "\nUnable to import module. Export depends on cli tool \"unzip\"."
|
180
|
-
end
|
181
|
-
else
|
182
|
-
puts "Unable to find file: #{zip_file}"
|
183
|
-
end
|
127
|
+
def export(*args)
|
128
|
+
name = args[0]
|
129
|
+
export_module_for name.downcase
|
184
130
|
end
|
185
131
|
|
186
|
-
|
187
|
-
puts "Exporting module: #{name}"
|
188
|
-
zip_file = "#{name}.zip"
|
189
|
-
puts "The following files will be zipped:"
|
190
|
-
puts "- lib/teamster-modules/#{name}.rb"
|
191
|
-
puts '- Everything in folder lib/teamster-modules/#{name}/'
|
192
|
-
if `which zip`.length != 0
|
193
|
-
`zip -r #{zip_file} lib/teamster-modules/#{name}.rb lib/teamster-modules/#{name}/`
|
194
|
-
puts "\nExported to #{zip_file}!"
|
195
|
-
else
|
196
|
-
puts "\nUnable to export module. Export depends on cli tool \"zip\"."
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
def create_file(filename, method, *args)
|
201
|
-
case [File.exists?(filename), !!@config[:overwrite]]
|
202
|
-
when [true, false]
|
203
|
-
puts "File \"#{filename}\" exists. Run with --overwrite to overwrite file."
|
204
|
-
else
|
205
|
-
puts "Creating file #{filename}..."
|
206
|
-
File.open(filename, "w") {|fh| fh.write(send(method.to_sym, *args))}
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
def show_version
|
211
|
-
"Current version of teamster: #{VERSION}"
|
212
|
-
end
|
213
|
-
|
214
|
-
def usage
|
215
|
-
<<-HELP
|
216
|
-
Initialize application:
|
217
|
-
teamster init
|
218
|
-
|
219
|
-
Run web application:
|
220
|
-
teamster start
|
221
|
-
|
222
|
-
Run web application in production (uses unix socket & state file):
|
223
|
-
teamster start --prod [--socket-file FILE] [--state-file FILE]
|
224
|
-
|
225
|
-
Verify by opening browser and navigating to "http://localhost:9292".
|
226
|
-
|
227
|
-
For more detailed help, please run "teamster --help".
|
228
|
-
HELP
|
229
|
-
end
|
230
|
-
|
231
|
-
def detailed_usage
|
232
|
-
<<-DETAIL
|
233
|
-
Teamster is a simple and extensible web portal for teams.
|
234
|
-
|
235
|
-
Current version: #{VERSION}
|
236
|
-
|
237
|
-
Usage:
|
238
|
-
teamster [COMMAND] [OPTIONS]
|
239
|
-
|
240
|
-
Commands:
|
241
|
-
init, start, stop, restart
|
242
|
-
|
243
|
-
Options (standalone):
|
244
|
-
--help Display this detailed help.
|
245
|
-
--version Version of the teamster used.
|
246
|
-
--create-module NAME Creates a stub of a module
|
247
|
-
--import-module FILE << PENDING IMPLEMENTATION >>
|
248
|
-
--export-module FILE << PENDING IMPLEMENTATION >>
|
249
|
-
|
250
|
-
|
251
|
-
Options used with \"start\":
|
252
|
-
--prod Binds a unix socket to be used by a web
|
253
|
-
server (eg. Nginx) and creates a state file
|
254
|
-
that is used by the Puma app server.
|
255
|
-
--socket-file FILE Relative/absolute path to the UNIX socket file.
|
256
|
-
--state-file FILE Relative/absolute path to the Puma state file.
|
257
|
-
|
258
|
-
|
259
|
-
Options used with \"stop\":
|
260
|
-
--socket-file FILE Relative/absolute path to the UNIX socket file.
|
261
|
-
--state-file FILE Relative/absolute path to the Puma state file.
|
262
|
-
|
263
|
-
|
264
|
-
Options used with \"restart\":
|
265
|
-
--socket-file FILE Relative/absolute path to the UNIX socket file.
|
266
|
-
--state-file FILE Relative/absolute path to the Puma state file.
|
267
|
-
DETAIL
|
268
|
-
end
|
269
|
-
|
270
|
-
def config_ru
|
271
|
-
<<-CODE
|
272
|
-
require 'teamster'
|
273
|
-
Dir.glob("lib/*.rb").each {|file| require File.absolute_path(file)}
|
274
|
-
run Teamster::Core::App
|
275
|
-
CODE
|
276
|
-
end
|
277
|
-
|
278
|
-
def teamster_modules
|
279
|
-
<<-CODE
|
280
|
-
Dir.glob(File.dirname(__FILE__) + '/teamster-modules/*.rb').each do |mdl|
|
281
|
-
require mdl
|
282
|
-
end
|
283
|
-
CODE
|
284
|
-
end
|
285
|
-
|
286
|
-
def module_placeholder_for(name)
|
287
|
-
<<-CODE
|
288
|
-
require_relative \"#{name}/#{name}_helper\"
|
289
|
-
|
290
|
-
\# NOTE: If the namespace is changed, please take care of the
|
291
|
-
\# namespace of the sub-class and helper modules.
|
292
|
-
|
293
|
-
module Teamster
|
294
|
-
module Modules
|
295
|
-
class #{name.capitalize} < Base
|
296
|
-
\# Stuff that needs to be done before registration with core.
|
297
|
-
has_helpers #{name.capitalize}Helper \# Add modules here (comma separated) if there are helper modules.
|
298
|
-
views_at \"\#\{File.dirname(__FILE__)\}/#{name}/views\"
|
299
|
-
under_development \# Remove this line when development is finished.
|
300
|
-
|
301
|
-
\# Register this class so it can be used.
|
302
|
-
register self
|
303
|
-
|
304
|
-
get '/#{name}/?' do
|
305
|
-
erb :#{name}
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
309
|
-
end
|
310
|
-
CODE
|
311
|
-
end
|
312
|
-
|
313
|
-
def module_helper_placeholder_for(name)
|
314
|
-
<<-CODE
|
315
|
-
module Teamster
|
316
|
-
module Modules
|
317
|
-
module #{name.capitalize}Helper
|
318
|
-
def #{name}_summary?
|
319
|
-
true
|
320
|
-
end
|
321
|
-
|
322
|
-
def #{name}_summary
|
323
|
-
erb :#{name}_summary
|
324
|
-
end
|
325
|
-
end
|
326
|
-
end
|
327
|
-
end
|
328
|
-
CODE
|
329
|
-
end
|
330
|
-
|
331
|
-
def view_placeholder_for(name)
|
332
|
-
<<-CODE
|
333
|
-
<h1 style='text-align: center'>PLACEHOLDER FOR #{name.upcase}</h1>
|
334
|
-
<p style='text-align: center'>Page under construction. Please check back later!</p>
|
335
|
-
CODE
|
336
|
-
end
|
132
|
+
# --{ HELPERS }-- #
|
337
133
|
|
338
|
-
def view_summary_placeholder_for(name)
|
339
|
-
<<-CODE
|
340
|
-
<p>Under development right now..</p>
|
341
|
-
CODE
|
342
|
-
end
|
343
134
|
end
|
344
135
|
end
|
345
136
|
|
data/lib/teamster/base_module.rb
CHANGED
data/lib/teamster-cli.rb
ADDED
@@ -0,0 +1,237 @@
|
|
1
|
+
module Teamster
|
2
|
+
module CLI
|
3
|
+
def self.included(base)
|
4
|
+
base.extend ClassMethods
|
5
|
+
end
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def quit(msg, code = 0)
|
9
|
+
warn msg
|
10
|
+
exit code
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_config(team_name)
|
14
|
+
if team_name
|
15
|
+
@config[:title] = team_name
|
16
|
+
else
|
17
|
+
ask_user_for :title, "What is your team name"
|
18
|
+
end
|
19
|
+
File.open(CONFIG_FILE, 'w') {|fh| fh.write @config.to_yaml}
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_user
|
23
|
+
puts "Creating default user.."
|
24
|
+
users = [{"name" => "Administrator", "pass" => b64_enc(BCrypt::Password.create("password"))}]
|
25
|
+
File.open("./data/users", "w") do |fh|
|
26
|
+
fh.write({"users" => users}.to_yaml)
|
27
|
+
end
|
28
|
+
FileUtils.chmod 0600, './data/users'
|
29
|
+
end
|
30
|
+
|
31
|
+
def b64_enc(obj)
|
32
|
+
Base64.strict_encode64(obj)
|
33
|
+
end
|
34
|
+
|
35
|
+
def ask_user_for(opt, question)
|
36
|
+
unless @config[opt]
|
37
|
+
@config[opt] = ask_user question
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def ask_user(question)
|
42
|
+
print "#{question}: "
|
43
|
+
STDIN.gets.strip
|
44
|
+
end
|
45
|
+
|
46
|
+
def create_module_for(name)
|
47
|
+
puts "Creating placeholders for module #{name}...\n"
|
48
|
+
FileUtils.mkdir_p "lib/teamster-modules/#{name}/views"
|
49
|
+
create_file "lib/teamster-modules/#{name}.rb", "module_placeholder_for", name
|
50
|
+
create_file "lib/teamster-modules/#{name}/#{name}_helper.rb", "module_helper_placeholder_for", name
|
51
|
+
create_file "lib/teamster-modules/#{name}/views/#{name}.erb", "view_placeholder_for", name
|
52
|
+
create_file "lib/teamster-modules/#{name}/views/#{name}_summary.erb", "view_summary_placeholder_for", name
|
53
|
+
puts "\nBasic module creation done!"
|
54
|
+
puts "Controller : \"lib/teamster-modules/#{name}.rb\""
|
55
|
+
puts "Helper : \"lib/teamster-modules/#{name}/#{name}_helper.rb\""
|
56
|
+
puts "View : \"lib/teamster-modules/#{name}/views/#{name}.erb\""
|
57
|
+
puts "Summary View : \"lib/teamster-modules/#{name}/views/#{name}_summary.erb\""
|
58
|
+
end
|
59
|
+
|
60
|
+
def import_module_for(name)
|
61
|
+
puts "Importing module: #{name}"
|
62
|
+
zip_file = "#{name}.zip"
|
63
|
+
if File.exists?(zip_file)
|
64
|
+
if `which unzip`.length != 0
|
65
|
+
`unzip #{zip_file}`
|
66
|
+
puts "\nSuccessfully imported #{name}. Please restart teamster to use."
|
67
|
+
else
|
68
|
+
puts "\nUnable to import module. Export depends on cli tool \"unzip\"."
|
69
|
+
end
|
70
|
+
else
|
71
|
+
puts "Unable to find file: #{zip_file}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def export_module_for(name)
|
76
|
+
puts "Exporting module: #{name}"
|
77
|
+
zip_file = "#{name}.zip"
|
78
|
+
puts "The following files will be zipped:"
|
79
|
+
puts "- lib/teamster-modules/#{name}.rb"
|
80
|
+
puts '- Everything in folder lib/teamster-modules/#{name}/'
|
81
|
+
if `which zip`.length != 0
|
82
|
+
`zip -r #{zip_file} lib/teamster-modules/#{name}.rb lib/teamster-modules/#{name}/`
|
83
|
+
puts "\nExported to #{zip_file}!"
|
84
|
+
else
|
85
|
+
puts "\nUnable to export module. Export depends on cli tool \"zip\"."
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def create_file(filename, method, *args)
|
90
|
+
case [File.exists?(filename), !!@config[:overwrite]]
|
91
|
+
when [true, false]
|
92
|
+
puts "File \"#{filename}\" exists. Run with --overwrite to overwrite file."
|
93
|
+
else
|
94
|
+
puts "Creating file #{filename}..."
|
95
|
+
File.open(filename, "w") {|fh| fh.write(send(method.to_sym, *args))}
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def show_version
|
100
|
+
"Current version of teamster: #{VERSION}"
|
101
|
+
end
|
102
|
+
|
103
|
+
def usage
|
104
|
+
<<-HELP
|
105
|
+
Initialize application:
|
106
|
+
teamster init
|
107
|
+
|
108
|
+
Run web application:
|
109
|
+
teamster start
|
110
|
+
|
111
|
+
Run web application in production (uses unix socket & state file):
|
112
|
+
teamster start --prod [--socket-file FILE] [--state-file FILE]
|
113
|
+
|
114
|
+
Verify by opening browser and navigating to "http://localhost:9292".
|
115
|
+
|
116
|
+
For more detailed help, please run "teamster --help".
|
117
|
+
HELP
|
118
|
+
end
|
119
|
+
|
120
|
+
def detailed_usage
|
121
|
+
<<-DETAIL
|
122
|
+
Teamster is a simple and extensible web portal for teams.
|
123
|
+
|
124
|
+
Current version: #{VERSION}
|
125
|
+
|
126
|
+
Usage:
|
127
|
+
teamster [COMMAND] [OPTIONS]
|
128
|
+
|
129
|
+
Commands:
|
130
|
+
init, start, stop, restart
|
131
|
+
|
132
|
+
Options (standalone):
|
133
|
+
--help Display this detailed help.
|
134
|
+
--version Version of the teamster used.
|
135
|
+
--create-module NAME Creates a stub of a module
|
136
|
+
--import-module FILE << PENDING IMPLEMENTATION >>
|
137
|
+
--export-module FILE << PENDING IMPLEMENTATION >>
|
138
|
+
|
139
|
+
|
140
|
+
Options used with \"start\":
|
141
|
+
--prod Binds a unix socket to be used by a web
|
142
|
+
server (eg. Nginx) and creates a state file
|
143
|
+
that is used by the Puma app server.
|
144
|
+
--socket-file FILE Relative/absolute path to the UNIX socket file.
|
145
|
+
--state-file FILE Relative/absolute path to the Puma state file.
|
146
|
+
|
147
|
+
|
148
|
+
Options used with \"stop\":
|
149
|
+
--socket-file FILE Relative/absolute path to the UNIX socket file.
|
150
|
+
--state-file FILE Relative/absolute path to the Puma state file.
|
151
|
+
|
152
|
+
|
153
|
+
Options used with \"restart\":
|
154
|
+
--socket-file FILE Relative/absolute path to the UNIX socket file.
|
155
|
+
--state-file FILE Relative/absolute path to the Puma state file.
|
156
|
+
DETAIL
|
157
|
+
end
|
158
|
+
|
159
|
+
def config_ru
|
160
|
+
<<-CODE
|
161
|
+
require 'teamster'
|
162
|
+
Dir.glob("lib/*.rb").each {|file| require File.absolute_path(file)}
|
163
|
+
run Teamster::Core::App
|
164
|
+
CODE
|
165
|
+
end
|
166
|
+
|
167
|
+
def teamster_modules
|
168
|
+
<<-CODE
|
169
|
+
Dir.glob(File.dirname(__FILE__) + '/teamster-modules/*.rb').each do |mdl|
|
170
|
+
require mdl
|
171
|
+
end
|
172
|
+
CODE
|
173
|
+
end
|
174
|
+
|
175
|
+
def module_placeholder_for(name)
|
176
|
+
<<-CODE
|
177
|
+
require_relative \"#{name}/#{name}_helper\"
|
178
|
+
|
179
|
+
\# NOTE: If the namespace is changed, please take care of the
|
180
|
+
\# namespace of the sub-class and helper modules.
|
181
|
+
|
182
|
+
module Teamster
|
183
|
+
module Modules
|
184
|
+
class #{name.capitalize} < Sinatra::Base
|
185
|
+
\# Class methods that contain Teamster-Module specific helpers.
|
186
|
+
include BaseModule
|
187
|
+
|
188
|
+
\# Stuff that needs to be done before registration with core.
|
189
|
+
has_helpers #{name.capitalize}Helper \# Add modules here (comma separated) if there are helper modules.
|
190
|
+
views_at \"\#\{File.dirname(__FILE__)\}/#{name}/views\"
|
191
|
+
under_development \# Remove this line when development is finished.
|
192
|
+
|
193
|
+
\# Register this class so it can be used.
|
194
|
+
register self
|
195
|
+
|
196
|
+
get '/#{name}/?' do
|
197
|
+
erb :#{name}
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
CODE
|
203
|
+
end
|
204
|
+
|
205
|
+
def module_helper_placeholder_for(name)
|
206
|
+
<<-CODE
|
207
|
+
module Teamster
|
208
|
+
module Modules
|
209
|
+
module #{name.capitalize}Helper
|
210
|
+
def #{name}_summary?
|
211
|
+
true
|
212
|
+
end
|
213
|
+
|
214
|
+
def #{name}_summary
|
215
|
+
erb :#{name}_summary
|
216
|
+
end
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
CODE
|
221
|
+
end
|
222
|
+
|
223
|
+
def view_placeholder_for(name)
|
224
|
+
<<-CODE
|
225
|
+
<h1 style='text-align: center'>PLACEHOLDER FOR #{name.upcase}</h1>
|
226
|
+
<p style='text-align: center'>Page under construction. Please check back later!</p>
|
227
|
+
CODE
|
228
|
+
end
|
229
|
+
|
230
|
+
def view_summary_placeholder_for(name)
|
231
|
+
<<-CODE
|
232
|
+
<p>Under development right now..</p>
|
233
|
+
CODE
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teamster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nur Muhammad Bin Sirat
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- content/views/login_required.erb
|
70
70
|
- content/views/navbar.erb
|
71
71
|
- content/views/no_summary.erb
|
72
|
+
- lib/teamster-cli.rb
|
72
73
|
- lib/teamster.rb
|
73
74
|
- lib/teamster/base_module.rb
|
74
75
|
- lib/teamster/core_helper.rb
|