cytoplasm 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +38 -0
- data/app/assets/images/cytoplasm/triangle-medium-circle-1.png +0 -0
- data/app/assets/images/cytoplasm/triangle-medium-circle-2.png +0 -0
- data/app/assets/images/cytoplasm/triangle-medium-circle-3.png +0 -0
- data/app/assets/images/cytoplasm/triangle-medium-circle-4.png +0 -0
- data/app/assets/javascripts/cytoplasm/cytoAjax.js.erb +53 -0
- data/app/assets/javascripts/cytoplasm/cytoColorPicker.js.erb +204 -0
- data/app/assets/javascripts/cytoplasm/cytoRadio.js.erb +210 -0
- data/app/assets/javascripts/cytoplasm/cytoSelect.js.erb +414 -0
- data/app/assets/javascripts/cytoplasm/cytoSlider.js.erb +170 -0
- data/app/assets/javascripts/cytoplasm/cytoTable.js.erb +48 -0
- data/app/assets/javascripts/cytoplasm/cytoUpload.js.erb +200 -0
- data/app/assets/javascripts/cytoplasm/cytoplasm.js.erb +220 -0
- data/app/assets/javascripts/cytoplasm/jquery.ba-throttle-debounce.min.js +9 -0
- data/app/assets/javascripts/cytoplasm/jquery.color.js +663 -0
- data/app/assets/javascripts/cytoplasm/less-1.3.1.min.js +9 -0
- data/app/assets/stylesheets/cytoplasm/cytoplasm.less +113 -0
- data/app/controllers/cytoplasm/fonts_controller.rb +46 -0
- data/app/controllers/cytoplasm/settings_controller.rb +34 -0
- data/app/views/cytoplasm/settings/edit.html.erb +529 -0
- data/app/views/cytoplasm/settings/index.html.erb +18 -0
- data/config/routes.rb +6 -0
- data/lib/cytoplasm.rb +317 -0
- data/lib/cytoplasm/ajax.rb +34 -0
- data/lib/cytoplasm/railtie.rb +12 -0
- data/lib/cytoplasm/version.rb +3 -0
- data/lib/tasks/cytoplasm_tasks.rake +4 -0
- data/test/cytoplasm_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/about.js +2 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/demos.js +2 -0
- data/test/dummy/app/assets/javascripts/docs.js +2 -0
- data/test/dummy/app/assets/javascripts/downloads.js +2 -0
- data/test/dummy/app/assets/javascripts/home.js +2 -0
- data/test/dummy/app/assets/stylesheets/about.css +4 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/demos.css +4 -0
- data/test/dummy/app/assets/stylesheets/docs.css +4 -0
- data/test/dummy/app/assets/stylesheets/downloads.css +4 -0
- data/test/dummy/app/assets/stylesheets/home.css +4 -0
- data/test/dummy/app/controllers/about_controller.rb +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/demos_controller.rb +4 -0
- data/test/dummy/app/controllers/docs_controller.rb +5 -0
- data/test/dummy/app/controllers/downloads_controller.rb +4 -0
- data/test/dummy/app/controllers/home_controller.rb +7 -0
- data/test/dummy/app/helpers/about_helper.rb +2 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/demos_helper.rb +2 -0
- data/test/dummy/app/helpers/docs_helper.rb +2 -0
- data/test/dummy/app/helpers/downloads_helper.rb +2 -0
- data/test/dummy/app/helpers/home_helper.rb +2 -0
- data/test/dummy/app/views/about/index.html.erb +2 -0
- data/test/dummy/app/views/demos/index.html.erb +15 -0
- data/test/dummy/app/views/docs/index.html.erb +15 -0
- data/test/dummy/app/views/downloads/index.html.erb +60 -0
- data/test/dummy/app/views/home/index.html.erb +74 -0
- data/test/dummy/app/views/layouts/application.html.erb +30 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cytoplasm.vars.yml +4 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +65 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +178434 -0
- data/test/dummy/log/production.log +4 -0
- data/test/dummy/log/test.log +43 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/cytoplasm/cytoplasm.vars.less +36 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/functional/about_controller_test.rb +9 -0
- data/test/dummy/test/functional/demos_controller_test.rb +9 -0
- data/test/dummy/test/functional/docs_controller_test.rb +7 -0
- data/test/dummy/test/functional/downloads_controller_test.rb +9 -0
- data/test/dummy/test/functional/home_controller_test.rb +9 -0
- data/test/dummy/test/unit/helpers/about_helper_test.rb +4 -0
- data/test/dummy/test/unit/helpers/demos_helper_test.rb +4 -0
- data/test/dummy/test/unit/helpers/docs_helper_test.rb +4 -0
- data/test/dummy/test/unit/helpers/downloads_helper_test.rb +4 -0
- data/test/dummy/test/unit/helpers/home_helper_test.rb +4 -0
- data/test/dummy/tmp/cache/assets/C23/A50/sprockets%2F1011830ce123d00a75be4330f2721412 +0 -0
- data/test/dummy/tmp/cache/assets/C2E/4E0/sprockets%2F5b29288e435665a224409e7d76530c95 +0 -0
- data/test/dummy/tmp/cache/assets/C75/590/sprockets%2Fc3abe8a0059292e1e3818278c0434027 +0 -0
- data/test/dummy/tmp/cache/assets/C77/C20/sprockets%2F165a39476f3fa731c0af49432141049c +0 -0
- data/test/dummy/tmp/cache/assets/C87/580/sprockets%2Fd904f7e82971fdde744127c702222195 +0 -0
- data/test/dummy/tmp/cache/assets/C8F/0F0/sprockets%2F369f11075c8c5f939359cb5cb0569281 +0 -0
- data/test/dummy/tmp/cache/assets/CA0/B40/sprockets%2F26961c657dc345435242accb433d260a +0 -0
- data/test/dummy/tmp/cache/assets/CA3/4B0/sprockets%2Fb78b7754bf248ba091802070be5c1630 +0 -0
- data/test/dummy/tmp/cache/assets/CA7/8F0/sprockets%2F901b96894219d63a767e8898f73d4ce7 +0 -0
- data/test/dummy/tmp/cache/assets/CAC/280/sprockets%2F408a235a236b0a3aa1302733211db5ba +0 -0
- data/test/dummy/tmp/cache/assets/CAE/FD0/sprockets%2F3bb22e4d409072c2278c1771893ec19e +0 -0
- data/test/dummy/tmp/cache/assets/CB2/AD0/sprockets%2F0c26131d87e0691ba9904e46ff5820b9 +0 -0
- data/test/dummy/tmp/cache/assets/CB8/330/sprockets%2F8d9120752c9f38f7a5e164395e5d0c04 +0 -0
- data/test/dummy/tmp/cache/assets/CBA/320/sprockets%2Fa34641007e856c6bd67567e2ac8668c4 +0 -0
- data/test/dummy/tmp/cache/assets/CCE/F60/sprockets%2F37d1a6c1a8d398c4404b1b00076912fd +0 -0
- data/test/dummy/tmp/cache/assets/CD7/990/sprockets%2F55411442048c5a69b45be06da29ee62c +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CD8/900/sprockets%2Fc68606f026190266d8099ada290bbaa4 +0 -0
- data/test/dummy/tmp/cache/assets/CDF/870/sprockets%2Fb878faf942403e313a5b103e5d80488e +0 -0
- data/test/dummy/tmp/cache/assets/CE1/E60/sprockets%2F08ae5c39217fa93841884cfcb0037c46 +0 -0
- data/test/dummy/tmp/cache/assets/CE2/AE0/sprockets%2F79562f7c45761a5d0dba9361d11ae594 +0 -0
- data/test/dummy/tmp/cache/assets/CE3/080/sprockets%2F7d4d7689d6fa8236f0b4848c03ba1215 +0 -0
- data/test/dummy/tmp/cache/assets/CE4/530/sprockets%2F70521f5a32e550f6da0d76e896c7183e +0 -0
- data/test/dummy/tmp/cache/assets/CE5/D30/sprockets%2F8c9834a63b25a66203918a75ff56e2ac +0 -0
- data/test/dummy/tmp/cache/assets/CEE/7F0/sprockets%2F8b32778387c589166e26a7e5a6aa4cc3 +0 -0
- data/test/dummy/tmp/cache/assets/CF3/120/sprockets%2Fe2b304b015ce82a222d634e7e544b0b3 +0 -0
- data/test/dummy/tmp/cache/assets/CF7/ED0/sprockets%2F8061089f9dc8af8cc6353949d9b9d212 +0 -0
- data/test/dummy/tmp/cache/assets/CF9/7C0/sprockets%2F40fc2f3d2a468a00e463f1d313cb1683 +0 -0
- data/test/dummy/tmp/cache/assets/D03/6B0/sprockets%2Fd3cfc780201b87a3439e35c5236bb71a +0 -0
- data/test/dummy/tmp/cache/assets/D05/D40/sprockets%2F1c9faaf28d05409b88ad3113374d613c +0 -0
- data/test/dummy/tmp/cache/assets/D06/7A0/sprockets%2Fa46b76e739460d2691f4121ffa8a0ca0 +0 -0
- data/test/dummy/tmp/cache/assets/D0D/A10/sprockets%2F5c22f257a7abbc8e5720b17433657f6d +0 -0
- data/test/dummy/tmp/cache/assets/D0E/4A0/sprockets%2F6b27287928ba630c1b25dfa80ee18b48 +0 -0
- data/test/dummy/tmp/cache/assets/D0E/7D0/sprockets%2F89200785fe2710582a6c1b8d04ae7fbe +0 -0
- data/test/dummy/tmp/cache/assets/D12/010/sprockets%2F8067431ced3f34f1c97d34c3b4fb7049 +0 -0
- data/test/dummy/tmp/cache/assets/D12/1E0/sprockets%2Fba248329196c372b79d1f4c4f2a771bf +0 -0
- data/test/dummy/tmp/cache/assets/D14/170/sprockets%2F40a7b83bb067eea7ce2c8394e1529287 +0 -0
- data/test/dummy/tmp/cache/assets/D15/8E0/sprockets%2F4752afcb2967724e7e47b58b200d8ed2 +0 -0
- data/test/dummy/tmp/cache/assets/D15/CE0/sprockets%2Fa1310379a19df3c1796f2f67dcd5915d +0 -0
- data/test/dummy/tmp/cache/assets/D21/A50/sprockets%2Feb094bfe70c49891ce65c0178d88d904 +0 -0
- data/test/dummy/tmp/cache/assets/D2D/E60/sprockets%2F34ec37e4221a9a127bf1de1ee52951b0 +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D47/930/sprockets%2F1a738430fd705a9dddde85a18dd29782 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D50/750/sprockets%2F7fbcc321810c8f493f86364fee480ed9 +0 -0
- data/test/dummy/tmp/cache/assets/D52/430/sprockets%2F6ada07f0c9869f9f35b05fa0988dc717 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D60/2A0/sprockets%2Ff1857b8a367fbae328221040cfcb2f1c +0 -0
- data/test/dummy/tmp/cache/assets/D65/180/sprockets%2F346621e7334bd914afc87bc6a9d1bc0a +0 -0
- data/test/dummy/tmp/cache/assets/D65/F10/sprockets%2F0a60d2fd5c544ea66af4d382b5e3d147 +0 -0
- data/test/dummy/tmp/cache/assets/D68/A20/sprockets%2F8b8272d3eaf9323f1c34114cbcbf56f3 +0 -0
- data/test/dummy/tmp/cache/assets/D69/0A0/sprockets%2Fe6c078d521b528e004f5dd673ddb2a6d +0 -0
- data/test/dummy/tmp/cache/assets/D69/0B0/sprockets%2Fb9e3ae8763ce66c2090d9413bdd400fa +0 -0
- data/test/dummy/tmp/cache/assets/D6E/3E0/sprockets%2F1be4cbdc9c19703c546405f087aee92d +0 -0
- data/test/dummy/tmp/cache/assets/D73/5F0/sprockets%2F6aee922214ffea56b31595f1a5ed8c92 +0 -0
- data/test/dummy/tmp/cache/assets/D78/840/sprockets%2F326ec6387a9d1b45ec2cdf7093b79f0e +0 -0
- data/test/dummy/tmp/cache/assets/D83/C70/sprockets%2Ff536f7a68e692747fca1d2fcd5c07f57 +0 -0
- data/test/dummy/tmp/cache/assets/D87/C40/sprockets%2F9dcd7a6999affe28e91e514cee079016 +0 -0
- data/test/dummy/tmp/cache/assets/D88/700/sprockets%2Fe13c6f31271a8ac23e63ef0a118ebe2b +0 -0
- data/test/dummy/tmp/cache/assets/D98/8B0/sprockets%2Fedbef6e0d0a4742346cf479f2c522eb0 +0 -0
- data/test/dummy/tmp/cache/assets/DA4/140/sprockets%2F24502b9d4e4eea6f709e089c0fdff30f +0 -0
- data/test/dummy/tmp/cache/assets/DBE/210/sprockets%2Fbedb89fd02eac0dc7aa93c820c612343 +0 -0
- data/test/dummy/tmp/cache/assets/DBE/950/sprockets%2F46cc27391a6badaac462d9b3aa43ec73 +0 -0
- data/test/dummy/tmp/cache/assets/DC7/E10/sprockets%2Fac6d2602a61a59c16ad89cbf2d2d48de +0 -0
- data/test/dummy/tmp/cache/assets/DC8/E80/sprockets%2F117e87cbd2939c4a9afcbbca2a3684d0 +0 -0
- data/test/dummy/tmp/cache/assets/DCD/AD0/sprockets%2Ffb914fa2e51ab43f0f857f0fddd8713b +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DEB/B50/sprockets%2Fdcfb6dd7dae66f42a5a10e80a33d1b24 +0 -0
- data/test/dummy/tmp/cache/assets/DEC/A90/sprockets%2F3f26f0f2e3ea4a0e194b22be6c3b5cce +0 -0
- data/test/dummy/tmp/cache/assets/E00/880/sprockets%2Fecb876bb310c1a3e6fd534ece45c9ed9 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E05/E70/sprockets%2Fead5bfd3417fc5de81d3794c3e443cfe +0 -0
- data/test/dummy/tmp/cache/assets/E1A/970/sprockets%2Ff89b4657cfc95e2d28f6fad44c58edfb +0 -0
- data/test/dummy/tmp/cache/assets/E2E/720/sprockets%2Ff76ac8420ca62debb77ecbfe7d0c6d45 +0 -0
- data/test/dummy/tmp/cache/assets/E38/2A0/sprockets%2Fc6e8ba43cbed7d3981f70bcfeb3a69c9 +0 -0
- data/test/dummy/tmp/cache/assets/E69/B60/sprockets%2Ffdbf7ec615e9a92e4857cdade17f4daa +0 -0
- data/test/dummy/tmp/cache/assets/E71/0E0/sprockets%2Fcbbecea061be6e609adc04133b9badab +0 -0
- data/test/dummy/tmp/cache/assets/E8C/480/sprockets%2Fdacb331ac961cf7b7cbc69abe8fb74dd +0 -0
- data/test/dummy/tmp/cache/assets/E8D/B40/sprockets%2Fb862bf7fb4b4c634aeaa9dfc97babc6b +0 -0
- data/test/test_helper.rb +15 -0
- metadata +420 -0
@@ -0,0 +1,18 @@
|
|
1
|
+
<h2 style="margin:0px;">Welcome to Cytoplasm's Management Interface!</h2>
|
2
|
+
<p>This portion of Cytoplasm serves as a management tool for your website's graphical layout.</p>
|
3
|
+
|
4
|
+
<hr />
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<li><%=link_to("Tweak your current layout",cytoplasm_edit_url)%></li>
|
8
|
+
<li><%=link_to("Save and publish your current layout as a theme","#")%></li>
|
9
|
+
<li><%=link_to("Load up a layout theme","#")%></li>
|
10
|
+
<li><%=link_to("Browse layout themes","#")%></li>
|
11
|
+
<li><%=link_to("Manage Fonts","#")%></li>
|
12
|
+
</ul>
|
13
|
+
|
14
|
+
<script type="text/javascript">
|
15
|
+
$.Cytoplasm("ready",function(){
|
16
|
+
|
17
|
+
});
|
18
|
+
</script>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
get "/cytoplasm" => "Cytoplasm/settings", :controller => Cytoplasm::SettingsController, :action => :index, :as => :cytoplasm
|
3
|
+
get "/cytoplasm/edit" => "Cytoplasm/settings#edit", :controller => Cytoplasm::SettingsController, :action => :edit, :as => :cytoplasm_edit
|
4
|
+
get "/cytoplasm/fonts/fetch_all" => "Cytoplasm/fonts#fetch_all"
|
5
|
+
get "/cytoplasm/settings/fetch" => "Cytoplasm/settings#fetch"
|
6
|
+
end
|
data/lib/cytoplasm.rb
ADDED
@@ -0,0 +1,317 @@
|
|
1
|
+
require 'cytoplasm/version'
|
2
|
+
require 'cytoplasm/railtie'
|
3
|
+
require 'yaml'
|
4
|
+
require 'active_support/core_ext/hash/deep_merge'
|
5
|
+
require 'less'
|
6
|
+
|
7
|
+
module Cytoplasm
|
8
|
+
# List of all Cytoplasm configuration settings, with their corresponding default values.
|
9
|
+
# Create a YAML file at config/initializers/cytoplasm.yml to extend the default settings.
|
10
|
+
@conf = {
|
11
|
+
:jqueryui => {
|
12
|
+
:version => "1.9.2",
|
13
|
+
:theme => "ui-darkness"
|
14
|
+
},
|
15
|
+
:fontloader => {
|
16
|
+
:directory => "fontsquirrel",
|
17
|
+
:googlewebfonts_apikey => "AIzaSyDs7hjZSILIAN3T4oFv3qf_DCyy6PfC30E"
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
# List of all Cytoplasm variables, with their corresponding default values.
|
22
|
+
# Create a YAML file at config/initializers/cytoplasm.vars.yml to extend the default values.
|
23
|
+
@vars = {
|
24
|
+
:layout => {
|
25
|
+
:mode => "fluid",
|
26
|
+
:padding => "20px",
|
27
|
+
:header => {
|
28
|
+
:logo => {
|
29
|
+
:enabled => true,
|
30
|
+
:position => "absolute",
|
31
|
+
:align => "left",
|
32
|
+
:x => "0px",
|
33
|
+
:y => "0px"
|
34
|
+
},
|
35
|
+
:nav => {
|
36
|
+
:enabled => true,
|
37
|
+
:align => "right",
|
38
|
+
:background => "transparent",
|
39
|
+
:font => "light"
|
40
|
+
}
|
41
|
+
},
|
42
|
+
:content => {
|
43
|
+
|
44
|
+
},
|
45
|
+
:footer => {
|
46
|
+
|
47
|
+
}
|
48
|
+
},
|
49
|
+
:fonts => {
|
50
|
+
:faces => {
|
51
|
+
:light => "Verdana",
|
52
|
+
:regular => "Verdana",
|
53
|
+
:medium => "Verdana",
|
54
|
+
:bold => "Verdana",
|
55
|
+
:xbold => "Verdana"
|
56
|
+
},
|
57
|
+
:sizes => {
|
58
|
+
:small => "12px",
|
59
|
+
:normal => "14px",
|
60
|
+
:huge => "48px",
|
61
|
+
:heading_factor => "4"
|
62
|
+
}
|
63
|
+
},
|
64
|
+
:colors => {
|
65
|
+
:global => {
|
66
|
+
:background => "green",
|
67
|
+
:text => "black",
|
68
|
+
:accent => "hsl(167,51%,30%)"
|
69
|
+
},
|
70
|
+
:header => {
|
71
|
+
:background => "transparent",
|
72
|
+
:text => "white"
|
73
|
+
},
|
74
|
+
:content => {
|
75
|
+
:background => "white",
|
76
|
+
:text => "inherit"
|
77
|
+
},
|
78
|
+
:footer => {
|
79
|
+
:background => "transparent",
|
80
|
+
:text => "white"
|
81
|
+
},
|
82
|
+
:plugins => {
|
83
|
+
:cytoTable => {
|
84
|
+
:background => "#eeeeee",
|
85
|
+
:border => "1px solid #cccccc",
|
86
|
+
:text => "inherit"
|
87
|
+
},
|
88
|
+
:cytoButton => {
|
89
|
+
:background => "linear-gradient(to bottom, yellow, green)",
|
90
|
+
:border => "1px solid green",
|
91
|
+
:text => "inherit"
|
92
|
+
},
|
93
|
+
:cytoSelect => {
|
94
|
+
|
95
|
+
},
|
96
|
+
:cytoRadio => {
|
97
|
+
|
98
|
+
},
|
99
|
+
:cytoSlider => {
|
100
|
+
|
101
|
+
},
|
102
|
+
:cytoUpload => {
|
103
|
+
|
104
|
+
},
|
105
|
+
:cytoColorPicker => {
|
106
|
+
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
}
|
111
|
+
@cssvars = ""
|
112
|
+
|
113
|
+
# Dependencies
|
114
|
+
@dependencies = {
|
115
|
+
:css => [
|
116
|
+
|
117
|
+
],
|
118
|
+
:js => [
|
119
|
+
'less-1.3.1.min.js',
|
120
|
+
'cytoplasm.js',
|
121
|
+
'jquery.ba-throttle-debounce.min.js',
|
122
|
+
'jquery.color.js',
|
123
|
+
'cytoAjax',
|
124
|
+
'cytoSelect',
|
125
|
+
'cytoRadio',
|
126
|
+
'cytoSlider',
|
127
|
+
'cytoUpload',
|
128
|
+
'cytoColorPicker',
|
129
|
+
'cytoTable'
|
130
|
+
]
|
131
|
+
};
|
132
|
+
|
133
|
+
def initialize
|
134
|
+
configure_with("config/initializers/cytoplasm.yml")
|
135
|
+
load_vars_from("config/initializers/cytoplasm.vars.yml")
|
136
|
+
end
|
137
|
+
|
138
|
+
# Configure through hash
|
139
|
+
def self.configure(opts={})
|
140
|
+
opts.each {|k,v| @conf[k.to_sym] = v if @valid_settings.include? k.to_sym}
|
141
|
+
end
|
142
|
+
def self.load_vars(opts={})
|
143
|
+
opts = optsToSym(opts)
|
144
|
+
@vars.deep_merge!(opts)
|
145
|
+
#opts.each {|k,v| @vars[k.to_sym] = v if @valid_vars.include? k.to_sym}
|
146
|
+
end
|
147
|
+
|
148
|
+
def self.optsToSym(opts)
|
149
|
+
fixed = {}
|
150
|
+
unless opts.is_a? Hash
|
151
|
+
return opts
|
152
|
+
else
|
153
|
+
opts.each do |k,v|
|
154
|
+
fixed[k.to_sym] = ((v.is_a?(Hash)) ? optsToSym(v) : v)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
return fixed
|
158
|
+
end
|
159
|
+
|
160
|
+
# Configure through yaml file
|
161
|
+
def self.configure_with(path_to_yaml_file)
|
162
|
+
begin
|
163
|
+
conf = YAML::load(IO.read(path_to_yaml_file))
|
164
|
+
rescue Errno::ENOENT
|
165
|
+
puts "YAML configuration file couldn't be found. Using defaults."; return
|
166
|
+
rescue Psych::SyntaxError
|
167
|
+
puts "YAML configuration file contains invalid syntax. Using defaults."; return
|
168
|
+
end
|
169
|
+
configure(conf)
|
170
|
+
end
|
171
|
+
def self.load_vars_from(path_to_yaml_file)
|
172
|
+
begin
|
173
|
+
vars = YAML::load(IO.read(path_to_yaml_file))
|
174
|
+
rescue Errno::ENOENT
|
175
|
+
puts "YAML configuration file couldn't be found. Using defaults."; return
|
176
|
+
rescue Psych::SyntaxError
|
177
|
+
puts "YAML configuration file contains invalid syntax. Using defaults."; return
|
178
|
+
end
|
179
|
+
load_vars(vars)
|
180
|
+
compile_css()
|
181
|
+
end
|
182
|
+
|
183
|
+
# Getters and setters
|
184
|
+
def self.config(which=nil,value=nil)
|
185
|
+
return @conf if which.nil?
|
186
|
+
if which.is_a? String and which.include? '.'
|
187
|
+
returnvar = @conf
|
188
|
+
levels = []
|
189
|
+
which.split(".").each do |level|
|
190
|
+
levels << level
|
191
|
+
returnvar = returnvar[level.to_sym] unless returnvar[level.to_sym].nil?
|
192
|
+
end
|
193
|
+
else
|
194
|
+
returnvar = @conf[which.to_sym]
|
195
|
+
end
|
196
|
+
|
197
|
+
unless returnvar.nil?
|
198
|
+
if value.nil?
|
199
|
+
return returnvar
|
200
|
+
else
|
201
|
+
@conf[which.to_sym] = value
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
def self.variable(which=nil,value=nil)
|
206
|
+
return @vars if which.nil?
|
207
|
+
if which.is_a? String and which.include? '.'
|
208
|
+
returnvar = @vars
|
209
|
+
levels = []
|
210
|
+
which.split(".").each do |level|
|
211
|
+
levels << level
|
212
|
+
returnvar = returnvar[level.to_sym] unless returnvar[level.to_sym].nil?
|
213
|
+
end
|
214
|
+
else
|
215
|
+
returnvar = @vars[which.to_sym]
|
216
|
+
end
|
217
|
+
|
218
|
+
unless returnvar.nil?
|
219
|
+
if value.nil?
|
220
|
+
return returnvar
|
221
|
+
else
|
222
|
+
@vars[which.to_sym] = value
|
223
|
+
end
|
224
|
+
end
|
225
|
+
end
|
226
|
+
# Shortcuts to the above
|
227
|
+
def self.conf(which=nil,value=nil)
|
228
|
+
return config(which,value)
|
229
|
+
end
|
230
|
+
def self.vars(which=nil,value=nil)
|
231
|
+
return variable(which,value)
|
232
|
+
end
|
233
|
+
|
234
|
+
# Dependency loaders
|
235
|
+
def self.dependencies(type="*")
|
236
|
+
deps = []
|
237
|
+
valid_types = ["*","css","js"]
|
238
|
+
return false unless valid_types.include? type
|
239
|
+
case type
|
240
|
+
when "*"
|
241
|
+
valid_types.each do |t|
|
242
|
+
if t!="*"
|
243
|
+
dependencies(t).each do |d|
|
244
|
+
deps << d
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
248
|
+
when "css"
|
249
|
+
deps << "http://ajax.googleapis.com/ajax/libs/jqueryui/"+conf("jqueryui.version")+"/themes/"+conf("jqueryui.theme")+"/jquery-ui.css"
|
250
|
+
#deps << "cytoplasm/cytoplasm-"+Time.now.to_i.to_s
|
251
|
+
@dependencies[:css].each do |stylesheet|
|
252
|
+
deps << "cytoplasm/"+stylesheet
|
253
|
+
end
|
254
|
+
when "js"
|
255
|
+
@dependencies[:js].each do |plugin|
|
256
|
+
deps << "cytoplasm/"+plugin
|
257
|
+
end
|
258
|
+
end
|
259
|
+
return deps
|
260
|
+
end
|
261
|
+
def self.deps(type="*")
|
262
|
+
return dependencies(type)
|
263
|
+
end
|
264
|
+
def self.css()
|
265
|
+
return dependencies("css")
|
266
|
+
end
|
267
|
+
def self.js()
|
268
|
+
return dependencies("js")
|
269
|
+
end
|
270
|
+
def self.compile_css()
|
271
|
+
varfile = ::Rails.root+"public/cytoplasm/cytoplasm.vars.less"
|
272
|
+
# Check for varfile, create one if it doesn't exist
|
273
|
+
unless File.exists?("public/cytoplasm")
|
274
|
+
Dir.chdir("public")
|
275
|
+
Dir.mkdir("cytoplasm")
|
276
|
+
Dir.chdir("../")
|
277
|
+
end
|
278
|
+
|
279
|
+
File.open(varfile,"wb") do |f|
|
280
|
+
css = ""
|
281
|
+
@vars.each do |k,v|
|
282
|
+
css += hash_to_css(k,v)
|
283
|
+
end
|
284
|
+
f.write(css)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
def self.hash_to_css(k,v,parent="")
|
289
|
+
output = ""
|
290
|
+
if v.is_a? Hash
|
291
|
+
parent += "#{k}_"
|
292
|
+
v.each do |kk,vv|
|
293
|
+
output += hash_to_css(kk,vv,parent)
|
294
|
+
end
|
295
|
+
return output
|
296
|
+
else
|
297
|
+
k = k.to_s
|
298
|
+
v = v.to_s
|
299
|
+
output = ""
|
300
|
+
output += "@#{parent}#{k}:#{v};\n"
|
301
|
+
if k == "background" and v.starts_with? "linear-gradient"
|
302
|
+
args = v[16..-2].split(/,\s*/)
|
303
|
+
direction = args.shift
|
304
|
+
args = direction+", "+args.reverse().join(", ")
|
305
|
+
output += "@#{parent}#{k}_reverse:linear-gradient(#{args});\n"
|
306
|
+
end
|
307
|
+
return output
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# Instantiate engine
|
312
|
+
module Rails
|
313
|
+
class Engine < ::Rails::Engine
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Cytoplasm
|
2
|
+
class Ajax < AbstractController::Base
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
# anything you would want to do in every controller, for example: add a class attribute
|
7
|
+
# class_attribute :class_attribute_available_on_every_controller, instance_writer: false
|
8
|
+
end
|
9
|
+
|
10
|
+
module ClassMethods
|
11
|
+
# notice: no self.method_name here, because this is being extended because ActiveSupport::Concern was extended
|
12
|
+
end
|
13
|
+
|
14
|
+
# instance methods to go on every controller go here
|
15
|
+
def self.ajax_success(message=false,data={})
|
16
|
+
puts "Ajax Success function called!"
|
17
|
+
output = {"status" => "OK"}
|
18
|
+
unless message.is_a? String or message==false
|
19
|
+
data = message
|
20
|
+
message = false
|
21
|
+
end
|
22
|
+
output["message"] = message if message.is_a? String and message!=""
|
23
|
+
data.each {|k,v| output[k] = v if data.key?(k)} unless data.empty?
|
24
|
+
return output.to_json
|
25
|
+
end
|
26
|
+
def self.ajax_error(message=false)
|
27
|
+
puts "Ajax Error function called!"
|
28
|
+
output = {"status" => "Error"}
|
29
|
+
output["message"] = message if message.is_a? String and message != ""
|
30
|
+
return output.to_json
|
31
|
+
abort
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "cytoplasm/ajax"
|
2
|
+
|
3
|
+
module Cytoplasm
|
4
|
+
class Railtie < Rails::Railtie
|
5
|
+
initializer "Cytoplasm.action_controller" do
|
6
|
+
ActiveSupport.on_load(:action_controller) do
|
7
|
+
puts "Extending #{self} with Cytoplasm::Controller"
|
8
|
+
#include Cytoplasm::Ajax
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,261 @@
|
|
1
|
+
== Welcome to Rails
|
2
|
+
|
3
|
+
Rails is a web-application framework that includes everything needed to create
|
4
|
+
database-backed web applications according to the Model-View-Control pattern.
|
5
|
+
|
6
|
+
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
+
templates that are primarily responsible for inserting pre-built data in between
|
8
|
+
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
+
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
+
persist themselves to a database. The controller handles the incoming requests
|
11
|
+
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
+
and directing data to the view.
|
13
|
+
|
14
|
+
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
+
layer entitled Active Record. This layer allows you to present the data from
|
16
|
+
database rows as objects and embellish these data objects with business logic
|
17
|
+
methods. You can read more about Active Record in
|
18
|
+
link:files/vendor/rails/activerecord/README.html.
|
19
|
+
|
20
|
+
The controller and view are handled by the Action Pack, which handles both
|
21
|
+
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
+
are bundled in a single package due to their heavy interdependence. This is
|
23
|
+
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
+
more separate. Each of these packages can be used independently outside of
|
25
|
+
Rails. You can read more about Action Pack in
|
26
|
+
link:files/vendor/rails/actionpack/README.html.
|
27
|
+
|
28
|
+
|
29
|
+
== Getting Started
|
30
|
+
|
31
|
+
1. At the command prompt, create a new Rails application:
|
32
|
+
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
+
|
34
|
+
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
+
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
+
|
37
|
+
3. Go to http://localhost:3000/ and you'll see:
|
38
|
+
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
+
|
40
|
+
4. Follow the guidelines to start developing your application. You can find
|
41
|
+
the following resources handy:
|
42
|
+
|
43
|
+
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
+
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
+
|
46
|
+
|
47
|
+
== Debugging Rails
|
48
|
+
|
49
|
+
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
+
will help you debug it and get it back on the rails.
|
51
|
+
|
52
|
+
First area to check is the application log files. Have "tail -f" commands
|
53
|
+
running on the server.log and development.log. Rails will automatically display
|
54
|
+
debugging and runtime information to these files. Debugging info will also be
|
55
|
+
shown in the browser on requests from 127.0.0.1.
|
56
|
+
|
57
|
+
You can also log your own messages directly into the log file from your code
|
58
|
+
using the Ruby logger class from inside your controllers. Example:
|
59
|
+
|
60
|
+
class WeblogController < ActionController::Base
|
61
|
+
def destroy
|
62
|
+
@weblog = Weblog.find(params[:id])
|
63
|
+
@weblog.destroy
|
64
|
+
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
The result will be a message in your log file along the lines of:
|
69
|
+
|
70
|
+
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
+
|
72
|
+
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
+
|
74
|
+
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
+
several books available online as well:
|
76
|
+
|
77
|
+
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
+
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
+
|
80
|
+
These two books will bring you up to speed on the Ruby language and also on
|
81
|
+
programming in general.
|
82
|
+
|
83
|
+
|
84
|
+
== Debugger
|
85
|
+
|
86
|
+
Debugger support is available through the debugger command when you start your
|
87
|
+
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
+
execution at any point in the code, investigate and change the model, and then,
|
89
|
+
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
+
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
+
|
92
|
+
class WeblogController < ActionController::Base
|
93
|
+
def index
|
94
|
+
@posts = Post.all
|
95
|
+
debugger
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
So the controller will accept the action, run the first line, then present you
|
100
|
+
with a IRB prompt in the server window. Here you can do things like:
|
101
|
+
|
102
|
+
>> @posts.inspect
|
103
|
+
=> "[#<Post:0x14a6be8
|
104
|
+
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
+
#<Post:0x14a6620
|
106
|
+
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
+
>> @posts.first.title = "hello from a debugger"
|
108
|
+
=> "hello from a debugger"
|
109
|
+
|
110
|
+
...and even better, you can examine how your runtime objects actually work:
|
111
|
+
|
112
|
+
>> f = @posts.first
|
113
|
+
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
+
>> f.
|
115
|
+
Display all 152 possibilities? (y or n)
|
116
|
+
|
117
|
+
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
+
|
119
|
+
|
120
|
+
== Console
|
121
|
+
|
122
|
+
The console is a Ruby shell, which allows you to interact with your
|
123
|
+
application's domain model. Here you'll have all parts of the application
|
124
|
+
configured, just like it is when the application is running. You can inspect
|
125
|
+
domain models, change values, and save to the database. Starting the script
|
126
|
+
without arguments will launch it in the development environment.
|
127
|
+
|
128
|
+
To start the console, run <tt>rails console</tt> from the application
|
129
|
+
directory.
|
130
|
+
|
131
|
+
Options:
|
132
|
+
|
133
|
+
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
+
made to the database.
|
135
|
+
* Passing an environment name as an argument will load the corresponding
|
136
|
+
environment. Example: <tt>rails console production</tt>.
|
137
|
+
|
138
|
+
To reload your controllers and models after launching the console run
|
139
|
+
<tt>reload!</tt>
|
140
|
+
|
141
|
+
More information about irb can be found at:
|
142
|
+
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
+
|
144
|
+
|
145
|
+
== dbconsole
|
146
|
+
|
147
|
+
You can go to the command line of your database directly through <tt>rails
|
148
|
+
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
+
defined in database.yml. Starting the script without arguments will connect you
|
150
|
+
to the development database. Passing an argument will connect you to a different
|
151
|
+
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
+
PostgreSQL and SQLite 3.
|
153
|
+
|
154
|
+
== Description of Contents
|
155
|
+
|
156
|
+
The default directory structure of a generated Ruby on Rails application:
|
157
|
+
|
158
|
+
|-- app
|
159
|
+
| |-- assets
|
160
|
+
| |-- images
|
161
|
+
| |-- javascripts
|
162
|
+
| `-- stylesheets
|
163
|
+
| |-- controllers
|
164
|
+
| |-- helpers
|
165
|
+
| |-- mailers
|
166
|
+
| |-- models
|
167
|
+
| `-- views
|
168
|
+
| `-- layouts
|
169
|
+
|-- config
|
170
|
+
| |-- environments
|
171
|
+
| |-- initializers
|
172
|
+
| `-- locales
|
173
|
+
|-- db
|
174
|
+
|-- doc
|
175
|
+
|-- lib
|
176
|
+
| `-- tasks
|
177
|
+
|-- log
|
178
|
+
|-- public
|
179
|
+
|-- script
|
180
|
+
|-- test
|
181
|
+
| |-- fixtures
|
182
|
+
| |-- functional
|
183
|
+
| |-- integration
|
184
|
+
| |-- performance
|
185
|
+
| `-- unit
|
186
|
+
|-- tmp
|
187
|
+
| |-- cache
|
188
|
+
| |-- pids
|
189
|
+
| |-- sessions
|
190
|
+
| `-- sockets
|
191
|
+
`-- vendor
|
192
|
+
|-- assets
|
193
|
+
`-- stylesheets
|
194
|
+
`-- plugins
|
195
|
+
|
196
|
+
app
|
197
|
+
Holds all the code that's specific to this particular application.
|
198
|
+
|
199
|
+
app/assets
|
200
|
+
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
+
|
202
|
+
app/controllers
|
203
|
+
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
+
automated URL mapping. All controllers should descend from
|
205
|
+
ApplicationController which itself descends from ActionController::Base.
|
206
|
+
|
207
|
+
app/models
|
208
|
+
Holds models that should be named like post.rb. Models descend from
|
209
|
+
ActiveRecord::Base by default.
|
210
|
+
|
211
|
+
app/views
|
212
|
+
Holds the template files for the view that should be named like
|
213
|
+
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
+
eRuby syntax by default.
|
215
|
+
|
216
|
+
app/views/layouts
|
217
|
+
Holds the template files for layouts to be used with views. This models the
|
218
|
+
common header/footer method of wrapping views. In your views, define a layout
|
219
|
+
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
+
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
+
layout.
|
222
|
+
|
223
|
+
app/helpers
|
224
|
+
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
+
generated for you automatically when using generators for controllers.
|
226
|
+
Helpers can be used to wrap functionality for your views into methods.
|
227
|
+
|
228
|
+
config
|
229
|
+
Configuration files for the Rails environment, the routing map, the database,
|
230
|
+
and other dependencies.
|
231
|
+
|
232
|
+
db
|
233
|
+
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
+
sequence of Migrations for your schema.
|
235
|
+
|
236
|
+
doc
|
237
|
+
This directory is where your application documentation will be stored when
|
238
|
+
generated using <tt>rake doc:app</tt>
|
239
|
+
|
240
|
+
lib
|
241
|
+
Application specific libraries. Basically, any kind of custom code that
|
242
|
+
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
+
the load path.
|
244
|
+
|
245
|
+
public
|
246
|
+
The directory available for the web server. Also contains the dispatchers and the
|
247
|
+
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
+
server.
|
249
|
+
|
250
|
+
script
|
251
|
+
Helper scripts for automation and generation.
|
252
|
+
|
253
|
+
test
|
254
|
+
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
+
command, template test files will be generated for you and placed in this
|
256
|
+
directory.
|
257
|
+
|
258
|
+
vendor
|
259
|
+
External libraries that the application depends on. Also includes the plugins
|
260
|
+
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
+
vendor/rails/. This directory is in the load path.
|