www_app 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +36 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +84 -0
- data/TODO.md +13 -0
- data/VERSION +1 -0
- data/bin/www_app +46 -0
- data/doc/Design.md +123 -0
- data/doc/Why_this_arch.rb +104 -0
- data/lib/public/jquery-2.1.1.js +4 -0
- data/lib/public/jquery.serialize-object.min.js +8 -0
- data/lib/public/underscore-1.7.0.js +6 -0
- data/lib/public/underscore-min.map +1 -0
- data/lib/public/underscore.string-2.3.0.js +1 -0
- data/lib/public/www_app.js +824 -0
- data/lib/www_app/Clean.rb +169 -0
- data/lib/www_app/dsl.rb +86 -0
- data/lib/www_app/source.rb +53 -0
- data/lib/www_app.rb +1024 -0
- data/specs/as_ruby/0000-new.rb +23 -0
- data/specs/as_ruby/0010-attrs.rb +29 -0
- data/specs/as_ruby/0011-class.rb +39 -0
- data/specs/as_ruby/0011-href.rb +37 -0
- data/specs/as_ruby/0011-id.rb +39 -0
- data/specs/as_ruby/0020-tag.rb +21 -0
- data/specs/as_ruby/0020-tag_content.rb +43 -0
- data/specs/as_ruby/0021-body.rb +16 -0
- data/specs/as_ruby/0021-form.rb +22 -0
- data/specs/as_ruby/0021-link.rb +26 -0
- data/specs/as_ruby/0021-script.rb +44 -0
- data/specs/as_ruby/0030-mustache.rb +113 -0
- data/specs/as_ruby/0040-css.rb +174 -0
- data/specs/as_ruby/0050-on.rb +64 -0
- data/specs/client-side/index.html +90 -0
- data/specs/client-side/index.js +777 -0
- data/specs/lib/config.ru +96 -0
- data/specs/lib/helpers.rb +230 -0
- data/specs/lib/qunit/qunit-1.15.0.css +237 -0
- data/specs/lib/qunit/qunit-1.15.0.js +2495 -0
- data/specs/lib/sample.rb +23 -0
- data/specs/sampe.2.rb +14 -0
- data/specs/sample.3.rb +17 -0
- data/specs/sample.rb +44 -0
- data/www_app.gemspec +38 -0
- metadata +271 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a2d329bf631e2d3ca2386b433a8b552d25896eda
|
4
|
+
data.tar.gz: 36ec7a7fb8580ce6bd15071da27ca9197f63217f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 50e3e9dbf94a9c28487c468719e936047f9719ce9f7a620bb719d6d35b188c9c87b79d6cdebf5ad01b2ff2520ee4b96600d5ecb574aa960df8940f46b32c80de
|
7
|
+
data.tar.gz: 110c46539691d9259483f85c4273af8b67c98dfd4b6c7f7550f8bb58cc5fd141237125d59519fd58e8228bd828bd5968d1e40ac6c7a33bbcbf2b5defedec6022
|
data/.gitignore
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
/node_modules/
|
2
|
+
/npm-debug.log
|
3
|
+
/lib/vendor/*
|
4
|
+
/.bundle
|
5
|
+
/.yardoc
|
6
|
+
/*.gem
|
7
|
+
/*.rbc
|
8
|
+
/*.gem
|
9
|
+
/*.rbc
|
10
|
+
/.config
|
11
|
+
/coverage/
|
12
|
+
/InstalledFiles
|
13
|
+
/pkg/
|
14
|
+
/spec/reports/
|
15
|
+
/test/tmp/
|
16
|
+
/test/version_tmp/
|
17
|
+
/tmp/
|
18
|
+
|
19
|
+
## Specific to RubyMotion:
|
20
|
+
|
21
|
+
|
22
|
+
## Environment normalisation:
|
23
|
+
/.bundle/
|
24
|
+
/lib/bundler/man/
|
25
|
+
|
26
|
+
# for a library or gem, you might want to ignore these files since the code is
|
27
|
+
# intended to run in multiple environments; otherwise, check them in:
|
28
|
+
/Gemfile.lock
|
29
|
+
/.ruby-version
|
30
|
+
/.ruby-gemset
|
31
|
+
|
32
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
33
|
+
.rvmrc
|
34
|
+
/node_modules/
|
35
|
+
/npm-debug.log
|
36
|
+
/lib/vendor/*
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013-2014 da99
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
WWW\_App:
|
4
|
+
---------
|
5
|
+
|
6
|
+
Create HTML pages using just Ruby: HTML/CSS/JS.
|
7
|
+
It's not done yet.
|
8
|
+
|
9
|
+
|
10
|
+
Ruby:
|
11
|
+
--------------
|
12
|
+
|
13
|
+
To install:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem install www_app
|
17
|
+
```
|
18
|
+
|
19
|
+
To Use:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
div {
|
23
|
+
|
24
|
+
border '1px solid #000'
|
25
|
+
background_color 'grey'
|
26
|
+
|
27
|
+
on('scary') {
|
28
|
+
border '2px dotted red'
|
29
|
+
background_color 'white'
|
30
|
+
}
|
31
|
+
|
32
|
+
p { 'Click the button to make me scared.' }
|
33
|
+
|
34
|
+
button {
|
35
|
+
parent 'div'
|
36
|
+
add_class 'scary'
|
37
|
+
|
38
|
+
'Scary-ify'
|
39
|
+
}
|
40
|
+
|
41
|
+
}
|
42
|
+
```
|
43
|
+
|
44
|
+
It generates the CSS, JS, and HTML.
|
45
|
+
|
46
|
+
Security:
|
47
|
+
-----------
|
48
|
+
|
49
|
+
1) Server-side: All data from user should be run through `:render` to
|
50
|
+
ensure sanitization/escaping.
|
51
|
+
|
52
|
+
2) Server-side: All JS meant for :script tags should be escaped before encoded into JSON.
|
53
|
+
|
54
|
+
3) Client-side: No untrusted data presented to user: `:inner_html/:inner_text`:
|
55
|
+
only uses content from the server after it has been sanitized/escaped.
|
56
|
+
|
57
|
+
4) Client-side: No client-side sanitization/escaping. Too many bugs and security issues
|
58
|
+
because of browser incompability/implementations. Content
|
59
|
+
to be used in client-size JS can only come from the server using "lockboxed vars".
|
60
|
+
|
61
|
+
5) Client-side: When using `:inner_html`, check for: `/<script/i` in String.
|
62
|
+
|
63
|
+
6) All forms require a CSRF token.
|
64
|
+
|
65
|
+
|
66
|
+
Notes:
|
67
|
+
-------
|
68
|
+
|
69
|
+
1) Blockquotes no longer allow the :cite attribute. Instead use the `cite` tag.
|
70
|
+
More info at: [http://html5doctor.com/cite-and-blockquote-reloaded/](http://html5doctor.com/cite-and-blockquote-reloaded/)
|
71
|
+
|
72
|
+
2) Originally, this was going to be programs written in 100% JSON. This has changed
|
73
|
+
because it turns out people do not want to create programs, they just want to customize them:
|
74
|
+
[https://www.youtube.com/watch?v=9nd9DwCdQR0#t=857](https://www.youtube.com/watch?v=9nd9DwCdQR0#t=857)
|
75
|
+
|
76
|
+
|
77
|
+
Fun fact:
|
78
|
+
-----
|
79
|
+
|
80
|
+
[JSON Applet](http://github.com/da99/json_applet) was changed to WWW\_Applet. WWW\_Applet was then changed to WWW\_App.
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
|
data/TODO.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
TODO:
|
4
|
+
-----
|
5
|
+
|
6
|
+
1) Timestamps on filenames for css, js, etc.
|
7
|
+
|
8
|
+
2) Cache control of HTML output.
|
9
|
+
|
10
|
+
3) Combine all JS files into one:
|
11
|
+
* if one fails, the rest fails.
|
12
|
+
* prevent caching of old content.
|
13
|
+
* self-contained one file client apps.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
data/bin/www_app
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# -*- bash -*-
|
3
|
+
#
|
4
|
+
#
|
5
|
+
|
6
|
+
case ARGV[0]
|
7
|
+
|
8
|
+
when "help"
|
9
|
+
|
10
|
+
puts %^
|
11
|
+
# ===================="
|
12
|
+
www_app help"
|
13
|
+
www_app install_js"
|
14
|
+
# ===================="
|
15
|
+
^
|
16
|
+
|
17
|
+
when "install_js"
|
18
|
+
|
19
|
+
fail "
|
20
|
+
Must automate downloading of LATEST (security reason)
|
21
|
+
underscore, jquery, etc.
|
22
|
+
"
|
23
|
+
require "fileutils"
|
24
|
+
args = ARGV.dup
|
25
|
+
|
26
|
+
applet_file = File.join File.dirname(File.dirname(__FILE__)), "lib/www_app.js"
|
27
|
+
|
28
|
+
target_dir = if ARGV[1]
|
29
|
+
ARGV[1]
|
30
|
+
else
|
31
|
+
Dir.pwd
|
32
|
+
end
|
33
|
+
|
34
|
+
new_file = File.join target_dir, "www_app.js"
|
35
|
+
FileUtils.cp applet_file, new_file
|
36
|
+
puts "#=== From: #{applet_file}"
|
37
|
+
puts "#=== Wrote: #{new_file}"
|
38
|
+
|
39
|
+
else
|
40
|
+
|
41
|
+
abort "Unknown operation: #{ARGV.first.inspect}"
|
42
|
+
|
43
|
+
end # === case
|
44
|
+
|
45
|
+
|
46
|
+
|
data/doc/Design.md
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
A
|
3
|
+
=========================
|
4
|
+
|
5
|
+
If :href is a Symbol
|
6
|
+
onclick, cancel default event
|
7
|
+
and run event named in
|
8
|
+
:href Symbol.
|
9
|
+
|
10
|
+
Buttons
|
11
|
+
=========================
|
12
|
+
|
13
|
+
```
|
14
|
+
button.^(:submit) { 'Save" }
|
15
|
+
button.^(:cancel, :red) { 'Cancel" }
|
16
|
+
button.^(:blue, :yell) { 'Save" }
|
17
|
+
```
|
18
|
+
|
19
|
+
This behavior is special to buttons:
|
20
|
+
All buttons
|
21
|
+
when clicked
|
22
|
+
run each event from class names
|
23
|
+
ignore if event does not exist.
|
24
|
+
|
25
|
+
Input
|
26
|
+
=========================
|
27
|
+
|
28
|
+
```
|
29
|
+
input(:text, :my_name, 'Robert')
|
30
|
+
input(:text, 'Robert')
|
31
|
+
input(:pass_phrase)
|
32
|
+
```
|
33
|
+
|
34
|
+
This behaviour is special to inputs:
|
35
|
+
when :input is in
|
36
|
+
fieldset with one or more class names:
|
37
|
+
the first class name is the default name.
|
38
|
+
if class name is :password,
|
39
|
+
type is set to :password
|
40
|
+
if first arg is Symbol,
|
41
|
+
name is set to first arg.
|
42
|
+
else
|
43
|
+
type is set to :text
|
44
|
+
if last arg is String,
|
45
|
+
value is set to last arg.
|
46
|
+
else
|
47
|
+
return super
|
48
|
+
|
49
|
+
Attaching Events to Tags and Parents
|
50
|
+
====================================
|
51
|
+
|
52
|
+
```
|
53
|
+
div {
|
54
|
+
observe :submit
|
55
|
+
form.action('...') {
|
56
|
+
button.^(:submit)
|
57
|
+
}
|
58
|
+
```
|
59
|
+
|
60
|
+
If no parent observes action name:
|
61
|
+
then attach to nearest :form tag.
|
62
|
+
else attach to tag (in this case, :button)
|
63
|
+
|
64
|
+
CSS + JS
|
65
|
+
========
|
66
|
+
|
67
|
+
```
|
68
|
+
div {
|
69
|
+
|
70
|
+
on(:click) {
|
71
|
+
|
72
|
+
border '1px solid #fff'
|
73
|
+
|
74
|
+
when_eq :my_var, 'some js' do
|
75
|
+
emit :my_box_was_clicked
|
76
|
+
end
|
77
|
+
|
78
|
+
if_not_then do
|
79
|
+
emit :dont_know_what
|
80
|
+
end
|
81
|
+
|
82
|
+
}
|
83
|
+
|
84
|
+
}
|
85
|
+
```
|
86
|
+
|
87
|
+
JS Templates
|
88
|
+
============
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
div.*(:mine) {
|
92
|
+
|
93
|
+
observe :record
|
94
|
+
|
95
|
+
span.^(:empty) { 'No records.' }
|
96
|
+
|
97
|
+
div.^(:list).template(:record, records) { |o|
|
98
|
+
|
99
|
+
div.^(:record) do
|
100
|
+
|
101
|
+
border_width '1px'
|
102
|
+
|
103
|
+
on(:delete) {
|
104
|
+
background 'some image'
|
105
|
+
server :delete
|
106
|
+
}
|
107
|
+
|
108
|
+
span.^(:title) { o[:title] }
|
109
|
+
a.href(:delete) { 'Delete' }
|
110
|
+
end
|
111
|
+
}
|
112
|
+
|
113
|
+
}
|
114
|
+
```
|
115
|
+
1) Parent and selectors.
|
116
|
+
2) Passing the message to target + observers.
|
117
|
+
3) Default message receivers:
|
118
|
+
Current tag, -> Parents -> Form
|
119
|
+
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
|
2
|
+
Why Services and not a programming language?
|
3
|
+
---------------------------
|
4
|
+
|
5
|
+
|
6
|
+
Ideas to remember, in this order:
|
7
|
+
|
8
|
+
1. the majority of software for the Majority of Humans requires
|
9
|
+
customization and settings/options: in other words, configuration
|
10
|
+
rather than creating an app. Science and Nintendo-style
|
11
|
+
video games require more "power", (ie a programming language).
|
12
|
+
|
13
|
+
2. most of the action in WWW\_Apps is:
|
14
|
+
describing things you are doing to the
|
15
|
+
stacks... and things you are doing to the
|
16
|
+
values on the stack.
|
17
|
+
|
18
|
+
3. universal problem solving: break up the problems
|
19
|
+
into re-usable components by complexing the problem
|
20
|
+
and comparing it to similar and different problems.
|
21
|
+
|
22
|
+
4. DSLs/POLs, even if they are a subset of a prog. lang.,
|
23
|
+
are stil their own culture/env./prog. lang. Just like
|
24
|
+
with anything else, people do not want to learn something
|
25
|
+
new unless they see LOTS of other people/companies using it,
|
26
|
+
or if it is being talked about a lot (eg XML, Java, etc.).
|
27
|
+
|
28
|
+
5. It doesn't matter if you can play well with others,
|
29
|
+
because no one wants to play with you. Hence, the lack of
|
30
|
+
good "virtual machine"-based architecture and sandboxing in
|
31
|
+
browsers. Hence, the lack of demand for programming languages
|
32
|
+
written using nothing but JSON.
|
33
|
+
|
34
|
+
6. The most important and the most easily mis-understood
|
35
|
+
and overlooked:
|
36
|
+
|
37
|
+
> It's not about solving problems.
|
38
|
+
> It's about finding "better" requirements.
|
39
|
+
|
40
|
+
Once the requirements change, you have to re-evaluate
|
41
|
+
the design/architecture immediately.
|
42
|
+
|
43
|
+
7. It's hard finding better requirements because of
|
44
|
+
familiarity and complexity (quantity and quantity).
|
45
|
+
Lazyiness and limited resources help you guide you to
|
46
|
+
fulfilling the requirements w/efficiency.
|
47
|
+
|
48
|
+
8. Programmers already have a common runtime:
|
49
|
+
HTML, CSS, Javascript, and their preferred server-side
|
50
|
+
language. They do not want something easier. They
|
51
|
+
want something familiar. Also, "write once, run anywhere"
|
52
|
+
is not something programmers want because they want to use
|
53
|
+
their own preferred language ...above all else... to generate
|
54
|
+
HTMl/CSS/JS. That leaves app-to-app messaging (ie JSON over AJAX).
|
55
|
+
|
56
|
+
9. Most apps/apps are:
|
57
|
+
|
58
|
+
> input -> JSON/AJAX -> Server -> markup
|
59
|
+
|
60
|
+
App/app makers do not neet programming capilities
|
61
|
+
outside of Nintendo-like gaming... because they will do
|
62
|
+
that in their favorite language on the server, then
|
63
|
+
send the final output to the user in the browser.
|
64
|
+
The "programming" happens on the server, and the client is
|
65
|
+
just a "dumb" GUI to collect and display input/output.
|
66
|
+
|
67
|
+
This is the closest people want to "write once/run everywhere"
|
68
|
+
because of their need to stick to their preferred language
|
69
|
+
and the limited needs of the consumer and producer (business).
|
70
|
+
|
71
|
+
Most industrial designers also do not want to run their own
|
72
|
+
business, but merely constant "experiment" with creating.
|
73
|
+
In other words, occasional invention, no innovation, and
|
74
|
+
constant experimenting. There is not much of a need, beyond
|
75
|
+
my own, of a better Smalltalk/Factor/Xananud system...
|
76
|
+
outside of Nintendo-like gaming.
|
77
|
+
|
78
|
+
10. If WWW\_App is going to be a programming language,
|
79
|
+
might as well go all the way: make it an abstraction over
|
80
|
+
everything (ie HTML/CSS/JS and all server-side langs,
|
81
|
+
including Ruby and Lua). A runtime will be created for
|
82
|
+
each language.
|
83
|
+
|
84
|
+
I originally wanted this to be an abstraction layer over
|
85
|
+
HTML, JS, CSS. However, during the development of "www\_app",
|
86
|
+
I realized I could do that w/ just Ruby. In other words,
|
87
|
+
I would not need a sophisticated runtime in the browser.
|
88
|
+
Most of the work would be on the server (to generate the HTML, CSS)
|
89
|
+
and the JS would mainly consist of calling functions in the browser
|
90
|
+
from my own api/libs.
|
91
|
+
|
92
|
+
The need for www\_app was pushed forward, also, because
|
93
|
+
most people do not need a common way to exchange code in programming
|
94
|
+
languages. Instead, their needs are configuration,
|
95
|
+
rather than a programming language or DSL/POL.
|
96
|
+
This is more higher level than HyperCard:
|
97
|
+
|
98
|
+
> Configure rather than create.
|
99
|
+
|
100
|
+
Also, I realized www\_app can become it's own programming
|
101
|
+
language with the power to replace PHP. It sounds crazy, but
|
102
|
+
no more crazy than the popularity of garbage like PHP and Wordpress.
|
103
|
+
It would only require an extra 2 weeks, but this is still too much
|
104
|
+
time that I can not afford because I am going broke.
|