milk 0.0.9 → 0.1.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.
Files changed (79) hide show
  1. data/README.rdoc +1 -1
  2. data/Rakefile +1 -1
  3. data/VERSION +1 -1
  4. data/lib/milk.rb +64 -40
  5. data/lib/milk/application.rb +37 -16
  6. data/lib/milk/component.rb +23 -28
  7. data/lib/milk/field.rb +7 -18
  8. data/lib/milk/page.rb +19 -25
  9. data/lib/milk/tasks.rb +6 -7
  10. data/milk.gemspec +56 -45
  11. data/site_template/Rakefile +5 -0
  12. data/site_template/bootstrap.rb +71 -0
  13. data/site_template/config.ru +1 -3
  14. data/site_template/{config → data/global}/foot.yaml +0 -0
  15. data/site_template/{config → data/global}/head.yaml +4 -4
  16. data/site_template/{pages → data/pages}/About.yaml +3 -3
  17. data/site_template/{pages → data/pages}/Home.yaml +4 -3
  18. data/site_template/{pages → data/pages}/News.yaml +3 -3
  19. data/site_template/{pages → data/pages}/NotFound.yaml +3 -3
  20. data/site_template/{pages → data/pages}/Products.yaml +3 -3
  21. data/site_template/lib/components/body.rb +6 -0
  22. data/site_template/lib/components/button.rb +19 -0
  23. data/site_template/lib/components/foot.rb +6 -0
  24. data/site_template/lib/components/head.rb +6 -0
  25. data/site_template/lib/fields/checkbox_field.rb +4 -0
  26. data/{lib/milk → site_template/lib}/fields/component_array.rb +0 -0
  27. data/site_template/lib/fields/dropdown_field.rb +4 -0
  28. data/{lib/milk → site_template/lib}/fields/image_chooser.rb +0 -0
  29. data/{lib/milk → site_template/lib}/fields/markdown_field.rb +0 -0
  30. data/{lib/milk → site_template/lib}/fields/page_chooser.rb +1 -1
  31. data/{lib/milk → site_template/lib}/fields/sprite_chooser.rb +1 -1
  32. data/{lib/milk → site_template/lib}/fields/text_field.rb +0 -0
  33. data/site_template/public/js/edit.js +121 -0
  34. data/site_template/public/js/form_validate.js +51 -0
  35. data/site_template/public/js/login.js +9 -0
  36. data/site_template/public/style/960.css +96 -0
  37. data/site_template/public/style/edit.css +29 -0
  38. data/site_template/public/style/login.css +12 -0
  39. data/site_template/public/style/reset.css +33 -0
  40. data/site_template/public/style/text.css +25 -0
  41. data/site_template/public/style/view.css +10 -0
  42. data/site_template/{design → templates}/960.sass +0 -0
  43. data/site_template/{design → templates/components}/body.haml +0 -0
  44. data/site_template/{design → templates/components}/button.haml +0 -0
  45. data/site_template/{design → templates/components}/foot.haml +0 -0
  46. data/site_template/{design → templates/components}/head.haml +0 -0
  47. data/site_template/templates/dependencies.haml +8 -0
  48. data/{lib/milk/fields/component.haml → site_template/templates/edit.component.haml} +0 -0
  49. data/site_template/templates/edit.haml +38 -0
  50. data/site_template/templates/edit.sass +91 -0
  51. data/site_template/templates/fields/checkbox_field.haml +1 -0
  52. data/{lib/milk → site_template/templates}/fields/component_array.haml +0 -0
  53. data/site_template/templates/fields/dropdown_field.haml +3 -0
  54. data/{lib/milk → site_template/templates}/fields/image_chooser.haml +0 -0
  55. data/{lib/milk → site_template/templates}/fields/markdown_field.haml +0 -0
  56. data/site_template/templates/fields/page_chooser.haml +3 -0
  57. data/{lib/milk → site_template/templates}/fields/sprite_chooser.haml +0 -0
  58. data/{lib/milk → site_template/templates}/fields/text_field.haml +0 -0
  59. data/site_template/templates/login.haml +37 -0
  60. data/site_template/templates/login.sass +35 -0
  61. data/site_template/{design/0-reset.sass → templates/reset.sass} +0 -0
  62. data/site_template/{design/1-text.sass → templates/text.sass} +0 -0
  63. data/site_template/{design/xhtml.haml → templates/view.haml} +2 -3
  64. data/site_template/{design/page.haml → templates/view.page.haml} +0 -0
  65. data/site_template/{design/head.sass → templates/view.sass} +10 -0
  66. metadata +56 -45
  67. data/lib/milk/fields/login.haml +0 -90
  68. data/lib/milk/fields/page_chooser.haml +0 -3
  69. data/lib/milk/fields/xhtml.haml +0 -253
  70. data/lib/milk/haxe.rb +0 -139
  71. data/site_template/config/config.yaml +0 -31
  72. data/site_template/config/users.yaml +0 -18
  73. data/site_template/design/body.rb +0 -4
  74. data/site_template/design/button.rb +0 -16
  75. data/site_template/design/foot.rb +0 -4
  76. data/site_template/design/foot.sass +0 -3
  77. data/site_template/design/head.rb +0 -4
  78. data/site_template/design/page.sass +0 -7
  79. data/site_template/design/sprites.sass +0 -0
@@ -1,20 +1,19 @@
1
1
 
2
2
  desc "Loads the Milk environment, mainly used as a dependency"
3
3
  task :environment do |t|
4
- MILK_ROOT ||= t.application.original_dir
4
+ SITE_DIR ||= t.application.original_dir
5
5
  require "milk"
6
6
  end
7
7
 
8
8
  desc "Compile all the sass files in the component dir and merge into style.css"
9
9
  task :sass => :environment do
10
- style_file = Milk::PUBLIC_DIR + "/style/style.css"
11
- puts "Updating #{style_file}..."
12
10
  require 'haml'
13
- open(style_file, "w") do |style|
14
- Dir.glob(Milk::COMPONENTS_DIR + "/*.sass").sort.each do |c|
15
- puts "Adding #{c}"
11
+ Dir.glob(Milk::TEMPLATE_DIR + "/*.sass").sort.each do |c|
12
+ target_file = Milk::PUBLIC_DIR+"/style/"+(c.gsub(/.*\/([^\/]*)\.sass/) { |m| $1 })+".css"
13
+ puts "Generating #{target_file}"
14
+ open(target_file, "w") do |style|
16
15
  open(c, "r") do |file|
17
- style.write Sass::Engine.new(file.read, :filename=>c, :style=>:compact, :load_paths => [Milk::COMPONENTS_DIR]).render.strip
16
+ style.write Sass::Engine.new(file.read, :filename=>c, :style=>:compact, :load_paths => [Milk::TEMPLATE_DIR]).render.strip
18
17
  end
19
18
  end
20
19
  end
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{milk}
5
- s.version = "0.0.9"
5
+ s.version = "0.1.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Tim Caswell"]
9
- s.date = %q{2009-06-25}
9
+ s.date = %q{2009-06-28}
10
10
  s.default_executable = %q{milk}
11
11
  s.email = %q{tim@creationix.com}
12
12
  s.executables = ["milk"]
@@ -26,62 +26,43 @@ Gem::Specification.new do |s|
26
26
  "lib/milk/application.rb",
27
27
  "lib/milk/component.rb",
28
28
  "lib/milk/field.rb",
29
- "lib/milk/fields/component.haml",
30
- "lib/milk/fields/component_array.haml",
31
- "lib/milk/fields/component_array.rb",
32
- "lib/milk/fields/image_chooser.haml",
33
- "lib/milk/fields/image_chooser.rb",
34
- "lib/milk/fields/login.haml",
35
- "lib/milk/fields/markdown_field.haml",
36
- "lib/milk/fields/markdown_field.rb",
37
- "lib/milk/fields/page_chooser.haml",
38
- "lib/milk/fields/page_chooser.rb",
39
- "lib/milk/fields/sprite_chooser.haml",
40
- "lib/milk/fields/sprite_chooser.rb",
41
- "lib/milk/fields/text_field.haml",
42
- "lib/milk/fields/text_field.rb",
43
- "lib/milk/fields/xhtml.haml",
44
- "lib/milk/haxe.rb",
45
29
  "lib/milk/page.rb",
46
30
  "lib/milk/tasks.rb",
47
31
  "milk.gemspec",
48
32
  "site_template/Rakefile",
33
+ "site_template/bootstrap.rb",
49
34
  "site_template/config.ru",
50
- "site_template/config/config.yaml",
51
- "site_template/config/foot.yaml",
52
- "site_template/config/head.yaml",
53
- "site_template/config/users.yaml",
54
- "site_template/design/0-reset.sass",
55
- "site_template/design/1-text.sass",
56
- "site_template/design/960.sass",
57
- "site_template/design/body.haml",
58
- "site_template/design/body.rb",
59
- "site_template/design/button.haml",
60
- "site_template/design/button.rb",
61
- "site_template/design/foot.haml",
62
- "site_template/design/foot.rb",
63
- "site_template/design/foot.sass",
64
- "site_template/design/head.haml",
65
- "site_template/design/head.rb",
66
- "site_template/design/head.sass",
67
- "site_template/design/page.haml",
68
- "site_template/design/page.sass",
69
- "site_template/design/sprites.sass",
70
- "site_template/design/xhtml.haml",
71
- "site_template/pages/About.yaml",
72
- "site_template/pages/Home.yaml",
73
- "site_template/pages/News.yaml",
74
- "site_template/pages/NotFound.yaml",
75
- "site_template/pages/Products.yaml",
35
+ "site_template/data/global/foot.yaml",
36
+ "site_template/data/global/head.yaml",
37
+ "site_template/data/pages/About.yaml",
38
+ "site_template/data/pages/Home.yaml",
39
+ "site_template/data/pages/News.yaml",
40
+ "site_template/data/pages/NotFound.yaml",
41
+ "site_template/data/pages/Products.yaml",
42
+ "site_template/lib/components/body.rb",
43
+ "site_template/lib/components/button.rb",
44
+ "site_template/lib/components/foot.rb",
45
+ "site_template/lib/components/head.rb",
46
+ "site_template/lib/fields/checkbox_field.rb",
47
+ "site_template/lib/fields/component_array.rb",
48
+ "site_template/lib/fields/dropdown_field.rb",
49
+ "site_template/lib/fields/image_chooser.rb",
50
+ "site_template/lib/fields/markdown_field.rb",
51
+ "site_template/lib/fields/page_chooser.rb",
52
+ "site_template/lib/fields/sprite_chooser.rb",
53
+ "site_template/lib/fields/text_field.rb",
76
54
  "site_template/public/cache/About/index.html",
77
55
  "site_template/public/cache/Home/index.html",
78
56
  "site_template/public/cache/News/index.html",
79
57
  "site_template/public/cache/Products/index.html",
80
58
  "site_template/public/favicon.ico",
81
59
  "site_template/public/images/README.txt",
60
+ "site_template/public/js/edit.js",
61
+ "site_template/public/js/form_validate.js",
82
62
  "site_template/public/js/jquery-1.3.2.min.js",
83
63
  "site_template/public/js/jquery-ui-1.7.2.custom.min.js",
84
64
  "site_template/public/js/jquery.json-1.3.min.js",
65
+ "site_template/public/js/login.js",
85
66
  "site_template/public/robots.txt",
86
67
  "site_template/public/skin/images/ui-bg_diagonals-thick_18_b81900_40x40.png",
87
68
  "site_template/public/skin/images/ui-bg_diagonals-thick_20_666666_40x40.png",
@@ -98,7 +79,37 @@ Gem::Specification.new do |s|
98
79
  "site_template/public/skin/images/ui-icons_ffd27a_256x240.png",
99
80
  "site_template/public/skin/images/ui-icons_ffffff_256x240.png",
100
81
  "site_template/public/skin/jquery-ui-1.7.2.custom.css",
82
+ "site_template/public/style/960.css",
83
+ "site_template/public/style/edit.css",
84
+ "site_template/public/style/login.css",
85
+ "site_template/public/style/reset.css",
101
86
  "site_template/public/style/style.css",
87
+ "site_template/public/style/text.css",
88
+ "site_template/public/style/view.css",
89
+ "site_template/templates/960.sass",
90
+ "site_template/templates/components/body.haml",
91
+ "site_template/templates/components/button.haml",
92
+ "site_template/templates/components/foot.haml",
93
+ "site_template/templates/components/head.haml",
94
+ "site_template/templates/dependencies.haml",
95
+ "site_template/templates/edit.component.haml",
96
+ "site_template/templates/edit.haml",
97
+ "site_template/templates/edit.sass",
98
+ "site_template/templates/fields/checkbox_field.haml",
99
+ "site_template/templates/fields/component_array.haml",
100
+ "site_template/templates/fields/dropdown_field.haml",
101
+ "site_template/templates/fields/image_chooser.haml",
102
+ "site_template/templates/fields/markdown_field.haml",
103
+ "site_template/templates/fields/page_chooser.haml",
104
+ "site_template/templates/fields/sprite_chooser.haml",
105
+ "site_template/templates/fields/text_field.haml",
106
+ "site_template/templates/login.haml",
107
+ "site_template/templates/login.sass",
108
+ "site_template/templates/reset.sass",
109
+ "site_template/templates/text.sass",
110
+ "site_template/templates/view.haml",
111
+ "site_template/templates/view.page.haml",
112
+ "site_template/templates/view.sass",
102
113
  "site_template/tmp/restart.txt",
103
114
  "test/milk_test.rb",
104
115
  "test/test_helper.rb"
@@ -107,7 +118,7 @@ Gem::Specification.new do |s|
107
118
  s.homepage = %q{http://github.com/creationix/milk}
108
119
  s.rdoc_options = ["--charset=UTF-8"]
109
120
  s.require_paths = ["lib"]
110
- s.required_ruby_version = Gem::Requirement.new(">= 1.9")
121
+ s.required_ruby_version = Gem::Requirement.new(">= 1.8")
111
122
  s.rubyforge_project = %q{milk}
112
123
  s.rubygems_version = %q{1.3.1}
113
124
  s.summary = %q{Milk is a rack based content management system built for ease of use and simplicity. Milk tastes great with and without cookies.}
@@ -1,3 +1,8 @@
1
+ # This allows for local gems to be used if they exist
2
+ Dir.glob(File.absolute_path(File.dirname(__FILE__)) + "/vendor/*/lib").each do |path|
3
+ puts "Using local gem at #{path}"
4
+ $LOAD_PATH.unshift(path)
5
+ end
1
6
  require 'rake'
2
7
  load 'milk/tasks.rb'
3
8
 
@@ -0,0 +1,71 @@
1
+ # This section is the milk configs for this local app
2
+ module Milk
3
+
4
+ SITE_DIR = File.absolute_path(File.dirname(__FILE__))
5
+
6
+ # SECRET is the site specific key used to encrypt the cookies sent for authentication.
7
+ #
8
+ # It is very important that this key be both long and unique to each site you build.
9
+ #
10
+ # My method is to pick two secret passphrases and concatenating the md5 of them together
11
+ #
12
+ # >> require 'digest/md5'
13
+ # => true
14
+ # >> Digest::MD5.hexdigest("Milk") + Digest::MD5.hexdigest("Rocks")
15
+ # => "e89b2cbb7d11825a67459af2249064de5cdfbc0ea6e85d2cc3dd5ddec72ffe1a"
16
+ SECRET = "098f6bcd4621d373cade4e832627b4f6ad0234829205b9033196ba818f7a872b"
17
+
18
+ # USE_CACHE is an advanced option for sites that need super high performance. When
19
+ # this option is set to true, then every time a page is saved, a static html file is
20
+ # created and saved to [MILK_ROOT]/public/cache/[pagename]/index.html
21
+ #
22
+ # In order to use these cache files your apache or nginx server needs to have a rewrite
23
+ # rule that looks here first and uses the static files if they exist.
24
+ #
25
+ # As an example, here is the relevent part of my nginx config:
26
+ #
27
+ # # Enable loading page cache files directly
28
+ # rewrite ^/$ /cache/Home/index.html;
29
+ # rewrite ^((/[A-Z][A-Za-z]*)+)$ /cache/$1/index.html;
30
+ USE_CACHE = false
31
+
32
+ # This determines what resources depend on what. That way a page can specify only what it
33
+ # needs and the rest will be pulled in automatically.
34
+ # Full paths mean to include a file, module name means that module is a dependency.
35
+ DEPENDENCY_TREE = {
36
+ :view => ["/favicon.ico", "/style/reset.css", "/style/text.css", "/style/960.css", "/style/view.css"],
37
+ :jquery => ["/js/jquery-1.3.2.min.js"],
38
+ :jquery_ui => [:jquery, "/js/jquery-ui-1.7.2.custom.min.js", "/skin/jquery-ui-1.7.2.custom.css"],
39
+ :jquery_json => [:jquery, "/js/jquery.json-1.3.min.js"],
40
+ :form_validate => [:jquery, "/js/form_validate.js"],
41
+ :edit => [:view, :jquery_json, :jquery_ui, "/js/edit.js", "/style/edit.css"],
42
+ :login_form => [:view, :jquery_ui, "/js/login.js", "/style/login.css"]
43
+ }
44
+
45
+ # This sets the authorized users to the site. When we implement an interface to change these
46
+ # settings through the web, then we will move these to a seperate file.
47
+ #
48
+ # Hash is a simple md5 of the password for now, future versions of
49
+ # Milk may use something more secure.
50
+ #
51
+ # To create the md5 hash in irb do the following:
52
+ #
53
+ # >> require 'digest/md5'
54
+ # => true
55
+ # >> Digest::MD5.hexdigest("test")
56
+ # => "098f6bcd4621d373cade4e832627b4f6"
57
+ #
58
+ # Note the default login is admin@example.com/test
59
+ USERS = {
60
+ "admin@example.com" => { :name => "Sample Admin", :hash => "098f6bcd4621d373cade4e832627b4f6" }
61
+ }
62
+
63
+ end
64
+
65
+ # This allows for local gems to be used if they exist
66
+ Dir.glob(Milk::SITE_DIR+"/vendor/*/lib").each do |path|
67
+ puts "Using local gem at #{path}"
68
+ $LOAD_PATH.unshift(path)
69
+ end
70
+ require 'milk'
71
+
@@ -1,6 +1,5 @@
1
- require 'milk'
1
+ require 'bootstrap'
2
2
 
3
- # use Lock
4
3
  if %w{rackup thin}.member?($0.rpartition('/').last)
5
4
  puts "Running in development mode"
6
5
  use ContentLength
@@ -10,7 +9,6 @@ if %w{rackup thin}.member?($0.rpartition('/').last)
10
9
  Milk::Application.new
11
10
  ])
12
11
  else
13
- # When using passenger, require secure cookies and don't bother with static files
14
12
  run Milk::Application.new(true)
15
13
  end
16
14
 
@@ -1,18 +1,18 @@
1
1
  ---
2
2
  buttons:
3
- - !ruby/object:Button
3
+ - !ruby/object:Milk::Components::Button
4
4
  href: /Home
5
5
  title: Home
6
6
  description: Description of home page
7
- - !ruby/object:Button
7
+ - !ruby/object:Milk::Components::Button
8
8
  href: /News
9
9
  title: News
10
10
  description: Description of news page
11
- - !ruby/object:Button
11
+ - !ruby/object:Milk::Components::Button
12
12
  href: /Products
13
13
  title: Products
14
14
  description: Description of products page
15
- - !ruby/object:Button
15
+ - !ruby/object:Milk::Components::Button
16
16
  href: /About
17
17
  title: About Us
18
18
  description: Description of about page
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Milk::Page
2
2
  components:
3
- - !ruby/object:Head {}
3
+ - !ruby/object:Milk::Components::Head {}
4
4
 
5
- - !ruby/object:Body
5
+ - !ruby/object:Milk::Components::Body
6
6
  markdown: |-
7
7
  # About Us
8
8
 
9
9
  Description of about page
10
- - !ruby/object:Foot {}
10
+ - !ruby/object:Milk::Components::Foot {}
11
11
 
12
12
  title: About Us
13
13
  keywords: ""
@@ -1,13 +1,14 @@
1
1
  --- !ruby/object:Milk::Page
2
+ #comment
2
3
  components:
3
- - !ruby/object:Head {}
4
+ - !ruby/object:Milk::Components::Head {}
4
5
 
5
- - !ruby/object:Body
6
+ - !ruby/object:Milk::Components::Body
6
7
  markdown: |-
7
8
  # Home
8
9
 
9
10
  Description of home page
10
- - !ruby/object:Foot {}
11
+ - !ruby/object:Milk::Components::Foot {}
11
12
 
12
13
  title: Home
13
14
  keywords: keywords, that, are, relevent, to, search, engines
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Milk::Page
2
2
  components:
3
- - !ruby/object:Head {}
3
+ - !ruby/object:Milk::Components::Head {}
4
4
 
5
- - !ruby/object:Body
5
+ - !ruby/object:Milk::Components::Body
6
6
  markdown: |-
7
7
  # News
8
8
 
9
9
  Description of news page
10
- - !ruby/object:Foot {}
10
+ - !ruby/object:Milk::Components::Foot {}
11
11
 
12
12
  title: News
13
13
  keywords: ""
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Milk::Page
2
2
  components:
3
- - !ruby/object:Head {}
3
+ - !ruby/object:Milk::Components::Head {}
4
4
 
5
- - !ruby/object:Body
5
+ - !ruby/object:Milk::Components::Body
6
6
  markdown: |-
7
7
  # 404 - Page not found
8
8
 
9
9
  The page you were looking for was not found
10
- - !ruby/object:Foot {}
10
+ - !ruby/object:Milk::Components::Foot {}
11
11
 
12
12
  title: 404 - Page not found
13
13
  keywords: ""
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Milk::Page
2
2
  components:
3
- - !ruby/object:Head {}
3
+ - !ruby/object:Milk::Components::Head {}
4
4
 
5
- - !ruby/object:Body
5
+ - !ruby/object:Milk::Components::Body
6
6
  markdown: |-
7
7
  # Products
8
8
 
9
9
  Description of products page
10
- - !ruby/object:Foot {}
10
+ - !ruby/object:Milk::Components::Foot {}
11
11
 
12
12
  title: Products
13
13
  keywords: ""
@@ -0,0 +1,6 @@
1
+ module Milk::Components
2
+ class Body < Milk::Component
3
+ local_properties :markdown
4
+ markdown_field :markdown, "Content"
5
+ end
6
+ end
@@ -0,0 +1,19 @@
1
+ module Milk::Components
2
+ class Button < Milk::Component
3
+ local_properties :href, :icon, :title, :description
4
+
5
+ page_chooser :href, "Link target"
6
+ text_field :title, "Label text"
7
+ text_field :description, "Tooltip"
8
+
9
+ def name
10
+ @title + " button"
11
+ end
12
+
13
+ # highlight if current page shares base folder with target of link
14
+ def css_class
15
+ (page.link_to.split('/')[1] == @href.split('/')[1] || page.link_to?(@href)) && "active"
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,6 @@
1
+ module Milk::Components
2
+ class Foot < Milk::Component
3
+ global_properties :markdown
4
+ markdown_field :markdown, "Footer Text"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Milk::Components
2
+ class Head < Milk::Component
3
+ global_properties :buttons
4
+ component_array :buttons, "Navigation buttons", :com_class => "Button"
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module Milk::Fields
2
+ class CheckboxField < Milk::Field
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Milk::Fields
2
+ class DropdownField < Milk::Field
3
+ end
4
+ end