teamster 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 352fed9c58d9e148cd5ea4d2b3678284d86cd546
4
- data.tar.gz: e074460a270688178eac6d911f527d099a45a610
3
+ metadata.gz: a6206844754e6167984d2917877c66c578b11754
4
+ data.tar.gz: ca07df0e85a826f4e0d70fe699599acac6529d24
5
5
  SHA512:
6
- metadata.gz: ac9afe990868e69976eb0120a2433f2b0e5325cd5de534eec42edd73e7d4043063e341676ccea9a0ff5696d0d50b51579b8e494a0a51de4408d74320e320269f
7
- data.tar.gz: 00ed4953d544d13fdace29b7e07249c234d2eaa2a52cc675df680d08a10a4603718decdf9c3cfcbfb902e8cdc2a56a52ff08d0745d992d0d44888e4febb397f0
6
+ metadata.gz: 33d2f2642c2626cf1ac9b3f7156eda22925ac13fa6315f6406bbfc3a1eaf50b9dcd87fcd76347930ad6858a6545f0c0296dd86ee140662bb0cc3d400ceb58afd
7
+ data.tar.gz: fb59b51f9aa89d9678f209945d18d4d1e40f51c9947f0cd29e79d11a1252525dd717b86729b05245dbb01b5917a5c441b49936063520b21c52b27a5dbd9436fb
data/README.md CHANGED
@@ -1,24 +1,20 @@
1
- teamster
2
- ========
1
+ # teamster
3
2
 
4
3
  A simple bare-bones extensible web portal for individuals or small teams
5
4
 
6
5
 
7
- Dependencies
8
- ============
6
+ #### Dependencies
9
7
 
10
8
  To run teamster, there is a few dependencies:
11
9
 
12
10
  * Only supported in OS X and linux. Not test on Windows. YMMV.
13
11
 
14
- Install
15
- =======
12
+ #### Install
16
13
 
17
14
  Teamster has been packaged into a gem. To install, simply run `gem install teamster`.
18
15
 
19
16
 
20
- Usage
21
- =====
17
+ ## Usage
22
18
 
23
19
  * Create a new folder where you want your site to live and navigate into it: `mkdir new-site && cd new-site`
24
20
  * Initialize teamster and answer some configuration questions: `teamster init`
@@ -27,41 +23,37 @@ Usage
27
23
  Open a browser and point to http://localhost:9292. A bare teamster page should be shown.
28
24
 
29
25
 
30
- Running In A "Production" Environment
31
- =====================================
26
+ ## Running In A "Production" Environment
32
27
 
33
28
  I do not recommended this application be exposed to the wide Internet just yet, but it should be secure enough for an individual or small team to use over their private LAN.
34
29
 
35
30
  When the `--prod` flag is passed, teamster will not run using rackup, but will utilize the [Puma](http://puma.io/) app server to serve itself. It will create and bind itself to a UNIX socket file and a Puma state file.
36
31
 
37
- Use With Nginx
38
- --------------
32
+ #### Use With Nginx
39
33
 
40
34
  Personally, I'm using this in conjunction with the popular [Nginx](http://nginx.org/) web server. To follow these, Nginx must already be installed on your system.
41
35
 
42
36
  * Run teamster in production mode: `teamster start --prod --socket-file /tmp/teamster.sock --state-file /srv/my-site/app.state`
43
37
  * In the nginx site configuration file, add the following:
44
38
 
45
- > upstream app {
46
- > server unix:///tmp/teamster.sock;
47
- > }
48
- >
49
- > server {
50
- > server_name my-site.example.com;
51
- > }
52
- >
53
- > location / {
54
- > proxy_pass http://app;
55
- > }
56
- > }
39
+ upstream app {
40
+ server unix:///tmp/teamster.sock;
41
+ }
42
+
43
+ server {
44
+ server_name my-site.example.com;
45
+
46
+ location / {
47
+ proxy_pass http://app;
48
+ }
49
+ }
57
50
 
58
51
  * Restart nginx.
59
52
 
60
53
  Open a browser and point to http://my-site.example.com. A bare teamster page should be shown.
61
54
 
62
55
 
63
- Create Modules
64
- ==============
56
+ ## Create Modules
65
57
 
66
58
  To create your custom modules:
67
59
 
@@ -74,3 +66,38 @@ This will create the following files in your site folder:
74
66
  * lib/teamster-modules/MODULENAME/views/MODULENAME.erb
75
67
 
76
68
  In MODULENAME.rb, a class MODULENAME will be created. While it may sub-class from Teamster::Module::Base, it is also a sub-class of Sinatra::Base. When developing it, you can use helper methods and other nifty stuff available from Sinatra. However, do take note of the scoping.
69
+
70
+
71
+ #### Helpers Available To Modules
72
+
73
+ This is a small list of helper methods that can be used in your modules.
74
+
75
+ * **logged_in?**
76
+
77
+ This returns `true` or `false`. Useful to check if a user has logged in.
78
+
79
+ get '/login_checker' do
80
+ if logged_in?
81
+ puts "User has logged in."
82
+ else
83
+ puts "You are not logged in."
84
+ end
85
+ end
86
+
87
+ * **login_required**
88
+
89
+ This halts a route from being run if a user has not yet logged in. Once a user has logged in, the route will be reloaded. The way to use this helper is:
90
+
91
+ get '/protected_route' do
92
+ login_required
93
+ do_stuff
94
+ end
95
+
96
+ * **current_user**
97
+
98
+ This just returns the username (or canonical name) of the currently logged in user. Since login is not yet implemented, this returns some random string.
99
+
100
+ get '/show_name' do
101
+ login_required
102
+ puts "Hello, #{current_user}"
103
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
data/bin/teamster CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- ['fileutils', 'getoptlong', 'yaml'].each do |gemfile|
2
+ ['fileutils', 'getoptlong', 'yaml', 'rubygems/package', 'zlib'].each do |gemfile|
3
3
  require gemfile
4
4
  end
5
5
 
@@ -23,6 +23,8 @@ class TeamsterApp
23
23
  ["--help", GetoptLong::NO_ARGUMENT ],
24
24
  ["--overwrite", GetoptLong::NO_ARGUMENT ],
25
25
  ["--create-module", GetoptLong::REQUIRED_ARGUMENT],
26
+ ["--import-module", GetoptLong::REQUIRED_ARGUMENT],
27
+ ["--export-module", GetoptLong::REQUIRED_ARGUMENT],
26
28
  ["--socket-file", GetoptLong::REQUIRED_ARGUMENT],
27
29
  ["--state-file", GetoptLong::REQUIRED_ARGUMENT])
28
30
  @config = {}.tap do |hsh|
@@ -42,6 +44,10 @@ class TeamsterApp
42
44
  quit show_version
43
45
  elsif name = @config[:create_module]
44
46
  create_module_for name.downcase
47
+ elsif name = @config[:import_module]
48
+ import_module_for name.downcase
49
+ elsif name = @config[:export_module]
50
+ export_module_for name.downcase
45
51
  elsif ARGV.size == 1
46
52
  command = ARGV.first.to_sym
47
53
  send command
@@ -144,6 +150,35 @@ class TeamsterApp
144
150
  puts "Summary View : \"lib/teamster-modules/#{name}/views/#{name}_summary.erb\""
145
151
  end
146
152
 
153
+ def import_module_for(name)
154
+ puts "Importing module: #{name}"
155
+ zip_file = "#{name}.zip"
156
+ if File.exists?(zip_file)
157
+ if `which unzip`.length != 0
158
+ `unzip #{zip_file}`
159
+ puts "\nSuccessfully imported #{name}. Please restart teamster to use."
160
+ else
161
+ puts "\nUnable to import module. Export depends on cli tool \"unzip\"."
162
+ end
163
+ else
164
+ puts "Unable to find file: #{zip_file}"
165
+ end
166
+ end
167
+
168
+ def export_module_for(name)
169
+ puts "Exporting module: #{name}"
170
+ zip_file = "#{name}.zip"
171
+ puts "The following files will be zipped:"
172
+ puts "- lib/teamster-modules/#{name}.rb"
173
+ puts '- Everything in folder lib/teamster-modules/#{name}/'
174
+ if `which zip`.length != 0
175
+ `zip -r #{zip_file} lib/teamster-modules/#{name}.rb lib/teamster-modules/#{name}/`
176
+ puts "\nExported to #{zip_file}!"
177
+ else
178
+ puts "\nUnable to export module. Export depends on cli tool \"zip\"."
179
+ end
180
+ end
181
+
147
182
  def create_file(filename, method, *args)
148
183
  case [File.exists?(filename), !!@config[:overwrite]]
149
184
  when [true, false]
@@ -1,14 +1,21 @@
1
1
  module Teamster
2
2
  module Core
3
3
  class Login < Sinatra::Base
4
+ helpers do
5
+ def redirect_back
6
+ referrer = URI::parse(request.referrer)
7
+ redirect to referrer.path
8
+ end
9
+ end
10
+
4
11
  get '/login/?' do
5
12
  session[:current_user] = "A Registered User (Login Not Implemented)"
6
- redirect to '/'
13
+ redirect_back
7
14
  end
8
15
 
9
16
  get '/logout/?' do
10
17
  session[:current_user] = nil
11
- redirect to '/'
18
+ redirect_back
12
19
  end
13
20
  end
14
21
  end
data/lib/teamster.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'sinatra/base'
2
2
  require 'yaml'
3
3
  require 'json'
4
+ require 'uri'
4
5
  require_relative 'teamster/login'
5
6
  require_relative 'teamster/general_helper'
6
7
  require_relative 'teamster/base_module'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nur Muhammad Bin Sirat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-16 00:00:00.000000000 Z
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma