plezi 0.12.22 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +18 -0
  3. data/LICENSE.txt +17 -18
  4. data/README.md +54 -698
  5. data/Rakefile +7 -4
  6. data/bin/config.ru +22 -0
  7. data/{test → bin}/console +4 -6
  8. data/bin/hello_world +52 -0
  9. data/bin/setup +8 -0
  10. data/exe/plezi +145 -0
  11. data/lib/plezi.rb +24 -137
  12. data/lib/plezi/activation.rb +28 -0
  13. data/lib/plezi/api.rb +62 -0
  14. data/lib/plezi/controller/controller.rb +259 -0
  15. data/lib/plezi/controller/controller_class.rb +176 -0
  16. data/lib/plezi/controller/cookies.rb +40 -0
  17. data/lib/plezi/helpers.rb +60 -0
  18. data/lib/plezi/rake.rb +2 -24
  19. data/lib/plezi/render/erb.rb +34 -0
  20. data/lib/plezi/render/has_cache.rb +36 -0
  21. data/lib/plezi/render/markdown.rb +63 -0
  22. data/lib/plezi/render/render.rb +49 -0
  23. data/lib/plezi/render/sass.rb +55 -0
  24. data/lib/plezi/render/slim.rb +33 -0
  25. data/lib/plezi/router/adclient.rb +23 -0
  26. data/lib/plezi/router/assets.rb +67 -0
  27. data/lib/plezi/router/errors.rb +29 -0
  28. data/lib/plezi/router/route.rb +112 -0
  29. data/lib/plezi/router/router.rb +120 -0
  30. data/lib/plezi/version.rb +1 -1
  31. data/lib/plezi/websockets/message_dispatch.rb +91 -0
  32. data/lib/plezi/websockets/redis.rb +55 -0
  33. data/plezi.gemspec +25 -16
  34. data/resources/404.erb +5 -4
  35. data/resources/500.erb +5 -4
  36. data/resources/{500.html → 503.html} +8 -9
  37. data/resources/client.js +253 -0
  38. data/resources/config.ru +5 -36
  39. data/resources/ctrlr.rb +34 -0
  40. data/resources/gemfile +4 -0
  41. data/resources/mini_app.rb +28 -82
  42. data/resources/mini_exec +7 -0
  43. data/resources/mini_welcome_page.html +0 -0
  44. data/resources/procfile +3 -0
  45. data/resources/rakefile +4 -8
  46. data/resources/routes.rb +9 -26
  47. data/resources/{websockets.js → simple-client.js} +3 -3
  48. metadata +60 -85
  49. data/bin/plezi +0 -104
  50. data/docs/async_helpers.md +0 -245
  51. data/docs/controllers.md +0 -27
  52. data/docs/logging.md +0 -49
  53. data/docs/routes.md +0 -209
  54. data/docs/websockets.md +0 -213
  55. data/lib/plezi/builders/ac_model.rb +0 -59
  56. data/lib/plezi/builders/app_builder.rb +0 -137
  57. data/lib/plezi/builders/builder.rb +0 -43
  58. data/lib/plezi/builders/form_builder.rb +0 -27
  59. data/lib/plezi/common/api.rb +0 -92
  60. data/lib/plezi/common/cache.rb +0 -122
  61. data/lib/plezi/common/defer.rb +0 -21
  62. data/lib/plezi/common/dsl.rb +0 -94
  63. data/lib/plezi/common/redis.rb +0 -65
  64. data/lib/plezi/common/renderer.rb +0 -141
  65. data/lib/plezi/common/settings.rb +0 -52
  66. data/lib/plezi/handlers/controller_core.rb +0 -106
  67. data/lib/plezi/handlers/controller_magic.rb +0 -284
  68. data/lib/plezi/handlers/http_router.rb +0 -205
  69. data/lib/plezi/handlers/placebo.rb +0 -112
  70. data/lib/plezi/handlers/route.rb +0 -216
  71. data/lib/plezi/handlers/session.rb +0 -109
  72. data/lib/plezi/handlers/stubs.rb +0 -156
  73. data/lib/plezi/handlers/ws_identity.rb +0 -253
  74. data/lib/plezi/handlers/ws_object.rb +0 -308
  75. data/lib/plezi/helpers/http_sender.rb +0 -84
  76. data/lib/plezi/helpers/magic_helpers.rb +0 -104
  77. data/lib/plezi/helpers/mime_types.rb +0 -1995
  78. data/lib/plezi/oauth.rb +0 -5
  79. data/lib/plezi/oauth/auth_controller.rb +0 -229
  80. data/logo/dark.png +0 -0
  81. data/logo/light.png +0 -0
  82. data/logo/sign.png +0 -0
  83. data/resources/404.haml +0 -121
  84. data/resources/404.html +0 -124
  85. data/resources/404.slim +0 -120
  86. data/resources/500.haml +0 -120
  87. data/resources/500.slim +0 -120
  88. data/resources/Gemfile +0 -86
  89. data/resources/code.rb +0 -8
  90. data/resources/controller.rb +0 -142
  91. data/resources/database.yml +0 -33
  92. data/resources/db_ac_config.rb +0 -59
  93. data/resources/db_dm_config.rb +0 -51
  94. data/resources/db_sequel_config.rb +0 -33
  95. data/resources/en.yml +0 -204
  96. data/resources/haml_config.rb +0 -6
  97. data/resources/i18n_config.rb +0 -14
  98. data/resources/initialize.rb +0 -49
  99. data/resources/mini_exec.rb +0 -7
  100. data/resources/oauth_config.rb +0 -24
  101. data/resources/plezi_client.js +0 -198
  102. data/resources/plezi_websockets.html +0 -47
  103. data/resources/redis_config.rb +0 -42
  104. data/resources/slim_config.rb +0 -11
  105. data/resources/welcome_page.html +0 -272
  106. data/test/dispatch +0 -58
  107. data/test/hello_world +0 -13
  108. data/test/plezi_tests.rb +0 -581
data/resources/code.rb DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- # load all framework and gems
5
- load ::File.expand_path(File.join("..", "initialize.rb"), __FILE__)
6
-
7
- # set up the routes
8
- load ::File.expand_path(File.join("..", "routes.rb"), __FILE__)
@@ -1,142 +0,0 @@
1
- #########################################
2
- # this is your SampleController
3
- #
4
- # feed it and give it plenty of children, borothers and sisters.
5
- #
6
- #########################################
7
- #
8
- # this is a skelaton for a RESTful and WebSocket controller implementation.
9
- #
10
- # it can also be used for non RESTful requests by utilizing only the
11
- # index method or other, non-RESTful, named methods.
12
- #
13
- # if a method returns false, an 404 not found is assumed. and routes continue to search.
14
- #
15
- # otherwise, the method's returned value is added to the response body (if it's a String).
16
- #
17
- # methods should return true (if the response was set/sent) or the body's string as their last value.
18
- #
19
- # no inheritance is required (the Plezi framework inherits your code, not the other way around).
20
- #
21
- # here are some of the available controller properties and methods:
22
- #
23
- # attr_accessor :params, :request, :response, :cookies
24
- #
25
- # params:: short-cut for request.params
26
- # request:: the request object
27
- # response:: the response object.
28
- # cookies:: a magic cookie-jar (sets and gets cookies).
29
- # flash:: a hash used for one-time cookies (get and set). any added values will be available for the same client for this and the next connection, after which they are removed.
30
- #
31
- # redirect_to:: easily set up redirection.
32
- # send_data:: easily send data, setting the content-type header.
33
- # render:: easily render Slim, Haml and IRB files into String text.
34
- #
35
- class SampleController
36
-
37
- # it is possible to includes all the Plezi::FeedHaml helper methods...
38
- # ... this breakes the strict MVC architecture by running the HAML view
39
- # as part of the controller class. It's good for hacking, but bad practice.
40
- # include Plezi::FeedHaml if defined? Plezi::FeedHaml
41
-
42
- # called before any action except WebSockets actions
43
- def before
44
- # some actions before the request is parsed
45
- # you can remove this, ofcourse. the router doesn't require the method to exist.
46
-
47
- ## uncomment the following line for a very loose reloading - use for debug mode only.
48
- # load Root.join("environment.rb").to_s unless ENV['RACK_ENV'] == 'production'
49
-
50
- true
51
- end
52
-
53
- # called after any action except WebSockets actions
54
- def after
55
- # some actions after the request is parsed
56
- # you can remove this, ofcourse. the router doesn't require the method to exist.
57
- true
58
- end
59
-
60
- # called when request is GET and there's no "id" in quary
61
- def index
62
- # while using sym redirection (unlike string redirection),
63
- # Plezi will attempt to auto-format a valid URL.
64
- redirect_to "assets_welcome.html".to_sym
65
- end
66
-
67
- # called when the params[:id] == fail. this a demonstration for custom routing.
68
- def fail
69
- # throw up this code and feed plezi your own lines :)
70
- raise "Plezi raising hell!"
71
- end
72
-
73
- # called when request is GET and quary defines "id"
74
- def show
75
- "I'd love to show you object with id: #{params[:id]}"
76
- end
77
-
78
- # called when the request is GET and the params[:id] == "new"
79
- def new
80
- "let's make something new."
81
- end
82
-
83
- # called when request is POST or PUT and there's no "id" in quary
84
- def save
85
- false
86
- end
87
-
88
- # called when request is POST or PUT and quary defines "id"
89
- def update
90
- false
91
- end
92
-
93
- # called when request is DELETE and quary defines "id"
94
- def delete
95
- false
96
- end
97
-
98
- # called before the protocol is swithed from HTTP to WebSockets.
99
- #
100
- # this allows setting headers, cookies and other data (such as authentication)
101
- # prior to allowing a WebSocket to open.
102
- #
103
- # if the method returns false, the connection will be refused and the remaining routes will be attempted.
104
- def pre_connect
105
- # false
106
- true
107
- end
108
-
109
- # called immediately after a WebSocket connection has been established.
110
- def on_open
111
- # response.close
112
- # false
113
- end
114
-
115
- # called when new data is recieved
116
- #
117
- # data is a string that contains binary or UTF8 (message dependent) data.
118
- #
119
- # the demo content simply broadcasts the message.
120
- def on_message data
121
- # broadcast sends an asynchronous message to all sibling instances, but not to self.
122
- data = ERB::Util.html_escape data
123
- broadcast :_print_out, data
124
- response << "You said: #{data}"
125
- response << (request.ssl? ? "FYI: Yes, This is an SSL connection..." : "FYI: Nope, this isn't an SSL connection (clear text).") if data.match /ssl\?/i
126
- end
127
-
128
- # called when a disconnect packet has been recieved or the connection has been cut
129
- # (ISN'T called after a disconnect message has been sent).
130
- def on_close
131
- end
132
-
133
- # a demo event method that recieves a broadcast from instance siblings.
134
- #
135
- # methods that are protected and methods that start with an underscore are hidden from the router
136
- # BUT, broadcasted methods must be public (or the broadcast will quietly fail)... so we have to use
137
- # the _underscore for this method.
138
- def _print_out data
139
- response << "Someone said: #{data}"
140
- end
141
-
142
- end
@@ -1,33 +0,0 @@
1
- # The following are common database setting as recomended by Heroku:
2
- default: &default
3
- adapter: postgresql
4
- host: localhost
5
- username: user
6
-
7
- development:
8
- <<: *default
9
- database: app-dev
10
-
11
- production:
12
- <<: *default
13
- database: app-dev
14
-
15
- # # Here is an Sqlite3 example DB.
16
- # # You can use it to update the default if you want to use Sqlite3
17
- # sqlite3_db:
18
- # adapter: sqlite3
19
- # pool: 5
20
- # timeout: 5000
21
- # database: db/db.sqlite3
22
-
23
-
24
- # # Here is a MySQL example DB.
25
- # # You can use it to update the default if you want to use MySQL
26
- # mysql_db:
27
- # adapter: mysql2
28
- # encoding: utf8
29
- # username: root
30
- # password: password
31
- # host: localhost
32
- # port: 3306
33
- # database: database_name
@@ -1,59 +0,0 @@
1
- #################
2
- ## SETTINGS FOR DATABASES
3
- #
4
- # this file contains common settings and rake tasks for ORM gems.
5
- #
6
- # please review / edit the settings you need.
7
- #
8
- ############
9
- ## ActiveRecord without Rails
10
- # more info at:
11
- # https://www.youtube.com/watch?v=o0SzhgYntK8
12
- # demo code here:
13
- # https://github.com/stungeye/ActiveRecord-without-Rails
14
- if defined? ActiveRecord
15
- puts "Loading ActiveRecord database setting: #{ENV['ENV']}"
16
- ActiveRecord::Base.establish_connection( YAML::load( File.open( Root.join('db', 'config.yml').to_s ) )[ ENV["ENV"].to_s ] )
17
-
18
- # if debugging purposes, uncomment this line to see the ActiveRecord's generated SQL:
19
- # ActiveRecord::Base.logger = Plezi.logger
20
-
21
- # Uncomment this line to make the logger output look nicer in Windows.
22
- # ActiveSupport::LogSubscriber.colorize_logging = false
23
-
24
- # Load ActiveRecord Tasks, if implemented
25
- if defined? Rake
26
-
27
- begin
28
- require 'standalone_migrations'
29
- StandaloneMigrations::Tasks.load_tasks
30
- rescue Exception => e
31
- ActiveRecord::Tasks::DatabaseTasks.env = ENV['ENV'] || 'development'
32
- ActiveRecord::Tasks::DatabaseTasks.database_configuration = YAML.load(File.read(Root.join('db', 'config.yml').to_s))
33
- ActiveRecord::Tasks::DatabaseTasks.db_dir = Root.join('db').to_s
34
- ActiveRecord::Tasks::DatabaseTasks.fixtures_path = Root.join( 'db', 'fixtures').to_s
35
- ActiveRecord::Tasks::DatabaseTasks.migrations_paths = [Root.join('db', 'migrate').to_s]
36
- ActiveRecord::Tasks::DatabaseTasks.seed_loader = Class.new do
37
- def self.load_seed
38
- filename = Root.join('db', 'seeds.rb').to_s
39
- unless File.file?(filename)
40
- IO.write filename, ''
41
- end
42
- load filename
43
- end
44
- end
45
- ActiveRecord::Tasks::DatabaseTasks.root = Root.to_s
46
-
47
- task :environment do
48
- ActiveRecord::Base.configurations = ActiveRecord::Tasks::DatabaseTasks.database_configuration
49
- ActiveRecord::Base.establish_connection ActiveRecord::Tasks::DatabaseTasks.env.to_sym
50
- end
51
-
52
- load 'active_record/railties/databases.rake'
53
-
54
- end
55
- end
56
-
57
-
58
- end
59
-
@@ -1,51 +0,0 @@
1
- #################
2
- ## SETTINGS FOR DATABASES
3
- #
4
- # this file contains common settings and rake tasks for ORM gems.
5
- #
6
- # please review / edit the settings you need.
7
- #
8
- ############
9
- ## DataMapper
10
- # more info @:
11
- # http://datamapper.org
12
- if defined? DataMapper
13
- # If you want the logs...
14
- DataMapper::Logger.new(Plezi.logger, :debug)
15
-
16
- if defined? SQLite3
17
- # An in-memory Sqlite3 connection:
18
- DataMapper.setup(:default, 'sqlite::memory:')
19
-
20
- # A Sqlite3 connection to a persistent database
21
- DataMapper.setup(:default, "sqlite:///#{Root.join('db', 'db.sqlite3').to_s}")
22
- elsif defined? PG
23
- # A Postgres connection:
24
- if ENV['DYNO']
25
- DataMapper.setup(:default, ENV['HEROKU_POSTGRESQL_RED_URL'])
26
- else
27
- Root.to_s.split(/\/\\/).last
28
- DataMapper.setup(:default, "postgres://localhost/#{Root.to_s.split(/[\/\\]/).last}")
29
- end
30
- end
31
- if defined? Rake
32
- ##########
33
- # start rake segment
34
-
35
- namespace :db do
36
- take :rebuild do
37
- DataMapper.finalize.auto_migrate!
38
- end
39
- task :migrate do
40
- DataMapper.finalize.auto_upgrade!
41
- end
42
-
43
- end
44
-
45
- # end rake segment
46
- ##########
47
- end
48
-
49
- end
50
-
51
-
@@ -1,33 +0,0 @@
1
- #################
2
- ## SETTINGS FOR DATABASES
3
- #
4
- # this file contains common settings and rake tasks for ORM gems.
5
- #
6
- # please review / edit the settings you need.
7
- #
8
- ############
9
- ## Sequel
10
- # more info @:
11
- # http://sequel.jeremyevans.net
12
- if defined? Sequel
13
-
14
- if defined? PG && ENV['DYNO']
15
- # A default Postgres connection for Heroku:
16
- DB = Sequel.connect(ENV['HEROKU_POSTGRESQL_RED_URL'])
17
- else
18
- # use db/config.yaml to connect to database
19
- DB = Sequel.connect( YAML::load( File.open( Root.join('db', 'config.yml').to_s ) )[ ENV["ENV"].to_s ] )
20
- end
21
- if defined? Rake
22
- ##########
23
- # start rake segment
24
-
25
- # not yet implemented
26
-
27
- # end rake segment
28
- ##########
29
- end
30
-
31
- end
32
-
33
-
data/resources/en.yml DELETED
@@ -1,204 +0,0 @@
1
- en:
2
- date:
3
- abbr_day_names:
4
- - Sun
5
- - Mon
6
- - Tue
7
- - Wed
8
- - Thu
9
- - Fri
10
- - Sat
11
- abbr_month_names:
12
- -
13
- - Jan
14
- - Feb
15
- - Mar
16
- - Apr
17
- - May
18
- - Jun
19
- - Jul
20
- - Aug
21
- - Sep
22
- - Oct
23
- - Nov
24
- - Dec
25
- day_names:
26
- - Sunday
27
- - Monday
28
- - Tuesday
29
- - Wednesday
30
- - Thursday
31
- - Friday
32
- - Saturday
33
- formats:
34
- default: ! '%Y-%m-%d'
35
- long: ! '%B %d, %Y'
36
- short: ! '%b %d'
37
- month_names:
38
- -
39
- - January
40
- - February
41
- - March
42
- - April
43
- - May
44
- - June
45
- - July
46
- - August
47
- - September
48
- - October
49
- - November
50
- - December
51
- order:
52
- - :year
53
- - :month
54
- - :day
55
- datetime:
56
- distance_in_words:
57
- about_x_hours:
58
- one: about 1 hour
59
- other: about %{count} hours
60
- about_x_months:
61
- one: about 1 month
62
- other: about %{count} months
63
- about_x_years:
64
- one: about 1 year
65
- other: about %{count} years
66
- almost_x_years:
67
- one: almost 1 year
68
- other: almost %{count} years
69
- half_a_minute: half a minute
70
- less_than_x_minutes:
71
- one: less than a minute
72
- other: less than %{count} minutes
73
- less_than_x_seconds:
74
- one: less than 1 second
75
- other: less than %{count} seconds
76
- over_x_years:
77
- one: over 1 year
78
- other: over %{count} years
79
- x_days:
80
- one: 1 day
81
- other: ! '%{count} days'
82
- x_minutes:
83
- one: 1 minute
84
- other: ! '%{count} minutes'
85
- x_months:
86
- one: 1 month
87
- other: ! '%{count} months'
88
- x_seconds:
89
- one: 1 second
90
- other: ! '%{count} seconds'
91
- prompts:
92
- day: Day
93
- hour: Hour
94
- minute: Minute
95
- month: Month
96
- second: Seconds
97
- year: Year
98
- errors:
99
- format: ! '%{attribute} %{message}'
100
- messages:
101
- accepted: must be accepted
102
- blank: can't be blank
103
- present: must be blank
104
- confirmation: ! "doesn't match %{attribute}"
105
- empty: can't be empty
106
- equal_to: must be equal to %{count}
107
- even: must be even
108
- exclusion: is reserved
109
- greater_than: must be greater than %{count}
110
- greater_than_or_equal_to: must be greater than or equal to %{count}
111
- inclusion: is not included in the list
112
- invalid: is invalid
113
- less_than: must be less than %{count}
114
- less_than_or_equal_to: must be less than or equal to %{count}
115
- not_a_number: is not a number
116
- not_an_integer: must be an integer
117
- odd: must be odd
118
- record_invalid: ! 'Validation failed: %{errors}'
119
- restrict_dependent_destroy:
120
- one: "Cannot delete record because a dependent %{record} exists"
121
- many: "Cannot delete record because dependent %{record} exist"
122
- taken: has already been taken
123
- too_long:
124
- one: is too long (maximum is 1 character)
125
- other: is too long (maximum is %{count} characters)
126
- too_short:
127
- one: is too short (minimum is 1 character)
128
- other: is too short (minimum is %{count} characters)
129
- wrong_length:
130
- one: is the wrong length (should be 1 character)
131
- other: is the wrong length (should be %{count} characters)
132
- other_than: "must be other than %{count}"
133
- template:
134
- body: ! 'There were problems with the following fields:'
135
- header:
136
- one: 1 error prohibited this %{model} from being saved
137
- other: ! '%{count} errors prohibited this %{model} from being saved'
138
- helpers:
139
- select:
140
- prompt: Please select
141
- submit:
142
- create: Create %{model}
143
- submit: Save %{model}
144
- update: Update %{model}
145
- number:
146
- currency:
147
- format:
148
- delimiter: ! ','
149
- format: ! '%u%n'
150
- precision: 2
151
- separator: .
152
- significant: false
153
- strip_insignificant_zeros: false
154
- unit: $
155
- format:
156
- delimiter: ! ','
157
- precision: 3
158
- separator: .
159
- significant: false
160
- strip_insignificant_zeros: false
161
- human:
162
- decimal_units:
163
- format: ! '%n %u'
164
- units:
165
- billion: Billion
166
- million: Million
167
- quadrillion: Quadrillion
168
- thousand: Thousand
169
- trillion: Trillion
170
- unit: ''
171
- format:
172
- delimiter: ''
173
- precision: 3
174
- significant: true
175
- strip_insignificant_zeros: true
176
- storage_units:
177
- format: ! '%n %u'
178
- units:
179
- byte:
180
- one: Byte
181
- other: Bytes
182
- gb: GB
183
- kb: KB
184
- mb: MB
185
- tb: TB
186
- percentage:
187
- format:
188
- delimiter: ''
189
- format: "%n%"
190
- precision:
191
- format:
192
- delimiter: ''
193
- support:
194
- array:
195
- last_word_connector: ! ', and '
196
- two_words_connector: ! ' and '
197
- words_connector: ! ', '
198
- time:
199
- am: am
200
- formats:
201
- default: ! '%a, %d %b %Y %H:%M:%S %z'
202
- long: ! '%B %d, %Y %H:%M'
203
- short: ! '%d %b %H:%M'
204
- pm: pm