Permalink
Browse files

Import from old repository.

  • Loading branch information...
0 parents commit 374285d51af7e465ea3f0728e76c32a5cb9557a8 @seancribbs seancribbs committed Jun 20, 2008
Showing with 13,581 additions and 0 deletions.
  1. +42 −0 README
  2. +25 −0 Rakefile
  3. +36 −0 app/controllers/sites_controller.rb
  4. +10 −0 app/helpers/sites_helper.rb
  5. +39 −0 app/models/site.rb
  6. +45 −0 app/views/admin/page/_site_subnav.rhtml
  7. +23 −0 app/views/sites/_form.haml
  8. +3 −0 app/views/sites/edit.haml
  9. +20 −0 app/views/sites/index.haml
  10. +3 −0 app/views/sites/new.haml
  11. +13 −0 db/migrate/001_create_sites.rb
  12. +9 −0 db/migrate/002_add_order_to_sites.rb
  13. +11 −0 db/migrate/003_add_base_domain_to_sites.rb
  14. +63 −0 lib/multi_site/page_controller_extensions.rb
  15. +32 −0 lib/multi_site/page_extensions.rb
  16. +14 −0 lib/multi_site/response_cache_extensions.rb
  17. +19 −0 lib/multi_site/site_controller_extensions.rb
  18. +5 −0 lib/slugify.rb
  19. +28 −0 lib/tasks/multi_site_extension_tasks.rake
  20. +38 −0 multi_site_extension.rb
  21. BIN public/images/admin/move_higher.png
  22. BIN public/images/admin/move_lower.png
  23. BIN public/images/admin/move_to_bottom.png
  24. BIN public/images/admin/move_to_top.png
  25. +29 −0 test/fixtures/sites.yml
  26. +16 −0 test/functional/multi_site_extension_test.rb
  27. +50 −0 test/functional/page_controller_extensions_test.rb
  28. +43 −0 test/functional/site_controller_extensions_test.rb
  29. +73 −0 test/functional/sites_controller_test.rb
  30. +19 −0 test/test_helper.rb
  31. +47 −0 test/unit/page_extensions_test.rb
  32. +20 −0 test/unit/response_cache_extensions_test.rb
  33. +61 −0 test/unit/site_test.rb
  34. +23 −0 vendor/plugins/acts_as_list/README
  35. +3 −0 vendor/plugins/acts_as_list/init.rb
  36. +256 −0 vendor/plugins/acts_as_list/lib/active_record/acts/list.rb
  37. +332 −0 vendor/plugins/acts_as_list/test/list_test.rb
  38. +20 −0 vendor/plugins/haml/MIT-LICENSE
  39. +229 −0 vendor/plugins/haml/README
  40. +168 −0 vendor/plugins/haml/Rakefile
  41. +17 −0 vendor/plugins/haml/TODO
  42. +1 −0 vendor/plugins/haml/VERSION
  43. +7 −0 vendor/plugins/haml/bin/css2sass
  44. +8 −0 vendor/plugins/haml/bin/haml
  45. +7 −0 vendor/plugins/haml/bin/html2haml
  46. +8 −0 vendor/plugins/haml/bin/sass
  47. +237 −0 vendor/plugins/haml/extra/haml-mode.el
  48. +155 −0 vendor/plugins/haml/extra/sass-mode.el
  49. +6 −0 vendor/plugins/haml/init.rb
  50. +699 −0 vendor/plugins/haml/lib/haml.rb
  51. +220 −0 vendor/plugins/haml/lib/haml/buffer.rb
  52. +913 −0 vendor/plugins/haml/lib/haml/engine.rb
  53. +43 −0 vendor/plugins/haml/lib/haml/error.rb
  54. +296 −0 vendor/plugins/haml/lib/haml/exec.rb
  55. +119 −0 vendor/plugins/haml/lib/haml/filters.rb
  56. +359 −0 vendor/plugins/haml/lib/haml/helpers.rb
  57. +45 −0 vendor/plugins/haml/lib/haml/helpers/action_view_extensions.rb
  58. +96 −0 vendor/plugins/haml/lib/haml/helpers/action_view_mods.rb
  59. +186 −0 vendor/plugins/haml/lib/haml/html.rb
  60. +99 −0 vendor/plugins/haml/lib/haml/template.rb
  61. +18 −0 vendor/plugins/haml/lib/haml/util.rb
  62. +637 −0 vendor/plugins/haml/lib/sass.rb
  63. +225 −0 vendor/plugins/haml/lib/sass/constant.rb
  64. +101 −0 vendor/plugins/haml/lib/sass/constant/color.rb
  65. +53 −0 vendor/plugins/haml/lib/sass/constant/literal.rb
  66. +87 −0 vendor/plugins/haml/lib/sass/constant/number.rb
  67. +30 −0 vendor/plugins/haml/lib/sass/constant/operation.rb
  68. +22 −0 vendor/plugins/haml/lib/sass/constant/string.rb
  69. +197 −0 vendor/plugins/haml/lib/sass/css.rb
  70. +373 −0 vendor/plugins/haml/lib/sass/engine.rb
  71. +35 −0 vendor/plugins/haml/lib/sass/error.rb
  72. +162 −0 vendor/plugins/haml/lib/sass/plugin.rb
  73. +53 −0 vendor/plugins/haml/lib/sass/tree/attr_node.rb
  74. +16 −0 vendor/plugins/haml/lib/sass/tree/comment_node.rb
  75. +51 −0 vendor/plugins/haml/lib/sass/tree/directive_node.rb
  76. +53 −0 vendor/plugins/haml/lib/sass/tree/node.rb
  77. +81 −0 vendor/plugins/haml/lib/sass/tree/rule_node.rb
  78. +16 −0 vendor/plugins/haml/lib/sass/tree/value_node.rb
  79. +70 −0 vendor/plugins/haml/test/benchmark.rb
  80. +298 −0 vendor/plugins/haml/test/haml/engine_test.rb
  81. +152 −0 vendor/plugins/haml/test/haml/helper_test.rb
  82. +60 −0 vendor/plugins/haml/test/haml/html2haml_test.rb
  83. +53 −0 vendor/plugins/haml/test/haml/markaby/standard.mab
  84. +6 −0 vendor/plugins/haml/test/haml/mocks/article.rb
  85. +16 −0 vendor/plugins/haml/test/haml/results/content_for_layout.xhtml
  86. +8 −0 vendor/plugins/haml/test/haml/results/eval_suppressed.xhtml
  87. +57 −0 vendor/plugins/haml/test/haml/results/filters.xhtml
  88. +87 −0 vendor/plugins/haml/test/haml/results/helpers.xhtml
  89. +10 −0 vendor/plugins/haml/test/haml/results/helpful.xhtml
  90. +61 −0 vendor/plugins/haml/test/haml/results/just_stuff.xhtml
  91. +12 −0 vendor/plugins/haml/test/haml/results/list.xhtml
  92. +24 −0 vendor/plugins/haml/test/haml/results/original_engine.xhtml
  93. +20 −0 vendor/plugins/haml/test/haml/results/partials.xhtml
  94. +74 −0 vendor/plugins/haml/test/haml/results/silent_script.xhtml
  95. +43 −0 vendor/plugins/haml/test/haml/results/standard.xhtml
  96. +28 −0 vendor/plugins/haml/test/haml/results/tag_parsing.xhtml
  97. +7 −0 vendor/plugins/haml/test/haml/results/very_basic.xhtml
  98. +94 −0 vendor/plugins/haml/test/haml/results/whitespace_handling.xhtml
  99. +55 −0 vendor/plugins/haml/test/haml/rhtml/standard.rhtml
  100. +15 −0 vendor/plugins/haml/test/haml/runner.rb
  101. +158 −0 vendor/plugins/haml/test/haml/template_test.rb
  102. +7 −0 vendor/plugins/haml/test/haml/templates/_partial.haml
  103. +3 −0 vendor/plugins/haml/test/haml/templates/_text_area.haml
  104. +8 −0 vendor/plugins/haml/test/haml/templates/breakage.haml
  105. +10 −0 vendor/plugins/haml/test/haml/templates/content_for_layout.haml
  106. +10 −0 vendor/plugins/haml/test/haml/templates/eval_suppressed.haml
  107. +53 −0 vendor/plugins/haml/test/haml/templates/filters.haml
  108. +65 −0 vendor/plugins/haml/test/haml/templates/helpers.haml
  109. +11 −0 vendor/plugins/haml/test/haml/templates/helpful.haml
  110. +71 −0 vendor/plugins/haml/test/haml/templates/just_stuff.haml
  111. +12 −0 vendor/plugins/haml/test/haml/templates/list.haml
  112. +17 −0 vendor/plugins/haml/test/haml/templates/original_engine.haml
  113. +1 −0 vendor/plugins/haml/test/haml/templates/partialize.haml
  114. +12 −0 vendor/plugins/haml/test/haml/templates/partials.haml
  115. +40 −0 vendor/plugins/haml/test/haml/templates/silent_script.haml
  116. +43 −0 vendor/plugins/haml/test/haml/templates/standard.haml
  117. +24 −0 vendor/plugins/haml/test/haml/templates/tag_parsing.haml
  118. +4 −0 vendor/plugins/haml/test/haml/templates/very_basic.haml
  119. +87 −0 vendor/plugins/haml/test/haml/templates/whitespace_handling.haml
  120. +63 −0 vendor/plugins/haml/test/profile.rb
  121. +219 −0 vendor/plugins/haml/test/sass/engine_test.rb
  122. +131 −0 vendor/plugins/haml/test/sass/plugin_test.rb
  123. +4 −0 vendor/plugins/haml/test/sass/results/alt.css
  124. +9 −0 vendor/plugins/haml/test/sass/results/basic.css
  125. +5 −0 vendor/plugins/haml/test/sass/results/compact.css
  126. +87 −0 vendor/plugins/haml/test/sass/results/complex.css
  127. +1 −0 vendor/plugins/haml/test/sass/results/compressed.css
  128. +12 −0 vendor/plugins/haml/test/sass/results/constants.css
  129. +17 −0 vendor/plugins/haml/test/sass/results/expanded.css
  130. +29 −0 vendor/plugins/haml/test/sass/results/import.css
  131. +20 −0 vendor/plugins/haml/test/sass/results/nested.css
  132. +13 −0 vendor/plugins/haml/test/sass/results/parent_ref.css
  133. +1 −0 vendor/plugins/haml/test/sass/results/subdir/nested_subdir/nested_subdir.css
  134. +1 −0 vendor/plugins/haml/test/sass/results/subdir/subdir.css
  135. +2 −0 vendor/plugins/haml/test/sass/templates/_partial.sass
  136. +16 −0 vendor/plugins/haml/test/sass/templates/alt.sass
  137. +23 −0 vendor/plugins/haml/test/sass/templates/basic.sass
  138. +2 −0 vendor/plugins/haml/test/sass/templates/bork.sass
  139. +2 −0 vendor/plugins/haml/test/sass/templates/bork2.sass
  140. +15 −0 vendor/plugins/haml/test/sass/templates/compact.sass
  141. +309 −0 vendor/plugins/haml/test/sass/templates/complex.sass
  142. +15 −0 vendor/plugins/haml/test/sass/templates/compressed.sass
  143. +88 −0 vendor/plugins/haml/test/sass/templates/constants.sass
  144. +15 −0 vendor/plugins/haml/test/sass/templates/expanded.sass
  145. +8 −0 vendor/plugins/haml/test/sass/templates/import.sass
  146. +10 −0 vendor/plugins/haml/test/sass/templates/importee.sass
  147. +23 −0 vendor/plugins/haml/test/sass/templates/nested.sass
  148. +25 −0 vendor/plugins/haml/test/sass/templates/parent_ref.sass
  149. +3 −0 vendor/plugins/haml/test/sass/templates/subdir/nested_subdir/nested_subdir.sass
  150. +6 −0 vendor/plugins/haml/test/sass/templates/subdir/subdir.sass
  151. +7 −0 vendor/plugins/make_resourceful/LICENSE
  152. +17 −0 vendor/plugins/make_resourceful/README
  153. +41 −0 vendor/plugins/make_resourceful/Rakefile
  154. +81 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/resourceful_scaffold_generator.rb
  155. +5 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/controller.rb
  156. +57 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/functional_test.rb
  157. +2 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/helper.rb
  158. +11 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/layout.haml
  159. +3 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/partial.haml
  160. +13 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_edit.haml
  161. +3 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_form.haml
  162. +5 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_index.haml
  163. +11 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_new.haml
  164. +6 −0 vendor/plugins/make_resourceful/generators/resourceful_scaffold/templates/view_show.haml
  165. +3 −0 vendor/plugins/make_resourceful/init.rb
  166. +1 −0 vendor/plugins/make_resourceful/install.rb
  167. +29 −0 vendor/plugins/make_resourceful/lib/resourceful/base.rb
  168. +109 −0 vendor/plugins/make_resourceful/lib/resourceful/builder.rb
  169. +192 −0 vendor/plugins/make_resourceful/lib/resourceful/default/accessors.rb
  170. +73 −0 vendor/plugins/make_resourceful/lib/resourceful/default/actions.rb
  171. +35 −0 vendor/plugins/make_resourceful/lib/resourceful/default/callbacks.rb
  172. +113 −0 vendor/plugins/make_resourceful/lib/resourceful/default/responses.rb
  173. +46 −0 vendor/plugins/make_resourceful/lib/resourceful/default/urls.rb
  174. +35 −0 vendor/plugins/make_resourceful/lib/resourceful/maker.rb
  175. +13 −0 vendor/plugins/make_resourceful/lib/resourceful/response.rb
  176. +85 −0 vendor/plugins/make_resourceful/lib/resourceful/serialize.rb
  177. +10 −0 vendor/plugins/make_resourceful/spec/base_spec.rb
  178. +274 −0 vendor/plugins/make_resourceful/spec/builder_spec.rb
  179. +63 −0 vendor/plugins/make_resourceful/spec/maker_spec.rb
  180. +37 −0 vendor/plugins/make_resourceful/spec/response_spec.rb
  181. +133 −0 vendor/plugins/make_resourceful/spec/serialize_spec.rb
  182. +77 −0 vendor/plugins/make_resourceful/spec/spec_helper.rb
  183. +128 −0 vendor/plugins/make_resourceful/spec/urls_spec.rb
  184. +4 −0 vendor/plugins/make_resourceful/tasks/make_resourceful_tasks.rake
  185. +10 −0 vendor/plugins/make_resourceful/test/Rakefile
  186. +5 −0 vendor/plugins/make_resourceful/test/app/controllers/admin/blog/posts_controller.rb
  187. +16 −0 vendor/plugins/make_resourceful/test/app/controllers/application.rb
  188. +7 −0 vendor/plugins/make_resourceful/test/app/controllers/hat_controller.rb
  189. +7 −0 vendor/plugins/make_resourceful/test/app/controllers/parties_controller.rb
  190. +36 −0 vendor/plugins/make_resourceful/test/app/controllers/people_controller.rb
  191. +6 −0 vendor/plugins/make_resourceful/test/app/controllers/properties_controller.rb
  192. +12 −0 vendor/plugins/make_resourceful/test/app/controllers/things_controller.rb
  193. +9 −0 vendor/plugins/make_resourceful/test/app/controllers/users_controller.rb
  194. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/admin/blog/posts_helper.rb
  195. +3 −0 vendor/plugins/make_resourceful/test/app/helpers/application_helper.rb
  196. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/hat_helper.rb
  197. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/parties_helper.rb
  198. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/people_helper.rb
  199. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/properties_helper.rb
  200. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/things_helper.rb
  201. +2 −0 vendor/plugins/make_resourceful/test/app/helpers/users_helper.rb
  202. +3 −0 vendor/plugins/make_resourceful/test/app/models/hat.rb
  203. +3 −0 vendor/plugins/make_resourceful/test/app/models/party.rb
  204. +5 −0 vendor/plugins/make_resourceful/test/app/models/person.rb
  205. +2 −0 vendor/plugins/make_resourceful/test/app/models/post.rb
  206. +3 −0 vendor/plugins/make_resourceful/test/app/models/property.rb
  207. +7 −0 vendor/plugins/make_resourceful/test/app/models/thing.rb
  208. +14 −0 vendor/plugins/make_resourceful/test/app/models/user.rb
  209. 0 vendor/plugins/make_resourceful/test/app/views/admin/blog/edit.rhtml
  210. 0 vendor/plugins/make_resourceful/test/app/views/admin/blog/index.rhtml
  211. 0 vendor/plugins/make_resourceful/test/app/views/admin/blog/new.rhtml
  212. 0 vendor/plugins/make_resourceful/test/app/views/admin/blog/show.rhtml
  213. +1 −0 vendor/plugins/make_resourceful/test/app/views/hat/show.rhtml
  214. 0 vendor/plugins/make_resourceful/test/app/views/parties/index.rhtml
  215. +1 −0 vendor/plugins/make_resourceful/test/app/views/people/index.rhtml
  216. +6 −0 vendor/plugins/make_resourceful/test/app/views/people/new.rhtml
  217. 0 vendor/plugins/make_resourceful/test/app/views/properties/show.rhtml
  218. +1 −0 vendor/plugins/make_resourceful/test/app/views/things/new.rhtml
  219. +4 −0 vendor/plugins/make_resourceful/test/app/views/things/show.rhtml
  220. +1 −0 vendor/plugins/make_resourceful/test/app/views/things/update.rjs
  221. +3 −0 vendor/plugins/make_resourceful/test/app/views/users/index.rhtml
  222. +1 −0 vendor/plugins/make_resourceful/test/app/views/users/magic.rhtml
  223. +3 −0 vendor/plugins/make_resourceful/test/app/views/users/show.rhtml
  224. +45 −0 vendor/plugins/make_resourceful/test/config/boot.rb
  225. +16 −0 vendor/plugins/make_resourceful/test/config/environment.rb
  226. +21 −0 vendor/plugins/make_resourceful/test/config/environments/development.rb
  227. +18 −0 vendor/plugins/make_resourceful/test/config/environments/production.rb
  228. +19 −0 vendor/plugins/make_resourceful/test/config/environments/test.rb
  229. +25 −0 vendor/plugins/make_resourceful/test/config/routes.rb
  230. +14 −0 vendor/plugins/make_resourceful/test/db/migrate/001_create_users.rb
  231. +12 −0 vendor/plugins/make_resourceful/test/db/migrate/002_create_people.rb
  232. +13 −0 vendor/plugins/make_resourceful/test/db/migrate/003_create_things.rb
  233. +12 −0 vendor/plugins/make_resourceful/test/db/migrate/004_create_properties.rb
  234. +12 −0 vendor/plugins/make_resourceful/test/db/migrate/005_create_posts.rb
  235. +9 −0 vendor/plugins/make_resourceful/test/db/migrate/006_users_own_things.rb
  236. +12 −0 vendor/plugins/make_resourceful/test/db/migrate/007_create_hats.rb
  237. +16 −0 vendor/plugins/make_resourceful/test/db/migrate/008_create_parties.rb
  238. +50 −0 vendor/plugins/make_resourceful/test/db/schema.rb
  239. +3 −0 vendor/plugins/make_resourceful/test/script/about
  240. +3 −0 vendor/plugins/make_resourceful/test/script/breakpointer
  241. +3 −0 vendor/plugins/make_resourceful/test/script/console
  242. +3 −0 vendor/plugins/make_resourceful/test/script/destroy
  243. +3 −0 vendor/plugins/make_resourceful/test/script/generate
  244. +3 −0 vendor/plugins/make_resourceful/test/script/performance/benchmarker
  245. +3 −0 vendor/plugins/make_resourceful/test/script/performance/profiler
  246. +3 −0 vendor/plugins/make_resourceful/test/script/plugin
  247. +3 −0 vendor/plugins/make_resourceful/test/script/runner
  248. +9 −0 vendor/plugins/make_resourceful/test/test/fixtures/hats.yml
  249. +4 −0 vendor/plugins/make_resourceful/test/test/fixtures/parties.yml
  250. +6 −0 vendor/plugins/make_resourceful/test/test/fixtures/parties_people.yml
  251. +7 −0 vendor/plugins/make_resourceful/test/test/fixtures/people.yml
  252. +8 −0 vendor/plugins/make_resourceful/test/test/fixtures/posts.yml
  253. +8 −0 vendor/plugins/make_resourceful/test/test/fixtures/properties.yml
  254. +15 −0 vendor/plugins/make_resourceful/test/test/fixtures/things.yml
  255. +26 −0 vendor/plugins/make_resourceful/test/test/fixtures/users.yml
  256. +43 −0 vendor/plugins/make_resourceful/test/test/functional/admin/blog/posts_controller_test.rb
  257. +31 −0 vendor/plugins/make_resourceful/test/test/functional/hat_controller_test.rb
  258. +48 −0 vendor/plugins/make_resourceful/test/test/functional/parties_controller_test.rb
  259. +155 −0 vendor/plugins/make_resourceful/test/test/functional/people_controller_test.rb
  260. +79 −0 vendor/plugins/make_resourceful/test/test/functional/properties_controller_test.rb
  261. +95 −0 vendor/plugins/make_resourceful/test/test/functional/things_controller_test.rb
  262. +62 −0 vendor/plugins/make_resourceful/test/test/functional/users_controller_test.rb
  263. +33 −0 vendor/plugins/make_resourceful/test/test/test_helper.rb
  264. +10 −0 vendor/plugins/make_resourceful/test/test/unit/hat_test.rb
  265. +10 −0 vendor/plugins/make_resourceful/test/test/unit/person_test.rb
  266. +10 −0 vendor/plugins/make_resourceful/test/test/unit/property_test.rb
  267. +16 −0 vendor/plugins/make_resourceful/test/test/unit/serialize_test.rb
  268. +10 −0 vendor/plugins/make_resourceful/test/test/unit/thing_test.rb
  269. +10 −0 vendor/plugins/make_resourceful/test/test/unit/user_test.rb
  270. +1 −0 vendor/plugins/make_resourceful/test/vendor/plugins/make_resourceful
  271. +1 −0 vendor/plugins/make_resourceful/uninstall.rb
42 README
@@ -0,0 +1,42 @@
+= Multi Site
+
+Created by Sean Cribbs, November 2007. Inspired by the original virtual_domain
+behavior.
+
+Multi Site allows you to host multiple websites on a single Radiant
+installation.
+
+Each site has its own independent sitemap/page-tree and these attributes:
+
+ name: Whatever you want to call the site
+ domain: A Ruby regular expression (without the //) to match the request
+ against
+ base_domain: A canonical domain name for doing quicker matches and for
+ generating absolute URLs against
+ homepage_id: The numerical database ID of the root page (usually
+ you can just leave this alone).
+
+Included images are slightly modified from FamFamFam Silk Icons by Mark James:
+http://www.famfamfam.com/lab/icons/silk/
+
+*** THIS EXTENSION REQUIRES THE 'SHARDS' EXTENSION TO BE INSTALLED ***
+
+== Installation
+
+1) Unpack/checkout/export the extension into vendor/extensions of your
+ project.
+
+2) Run the extension migrations.
+
+ $ rake production db:migrate:extensions
+
+3) Run the extension update task.
+
+ $ rake radiant:extensions:multi_site:update
+
+4) Restart your server
+
+== Acknowledgments
+
+Thanks to Digital Pulp, Inc. for funding the initial development of this
+extension as part of the Redken.com project.
@@ -0,0 +1,25 @@
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+desc 'Default: run unit tests.'
+task :default => :test
+
+desc 'Test the multi_site extension.'
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
+end
+
+desc 'Generate documentation for the multi_site extension.'
+Rake::RDocTask.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'MultiSiteExtension'
+ rdoc.options << '--line-numbers' << '--inline-source'
+ rdoc.rdoc_files.include('README')
+ rdoc.rdoc_files.include('lib/**/*.rb')
+end
+
+# Load any custom rakefiles for extension
+Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
@@ -0,0 +1,36 @@
+class SitesController < ApplicationController
+ # A hack, but the only way it works in something other than dev mode
+ write_inheritable_attribute :resourceful_callbacks, {}
+ write_inheritable_attribute :resourceful_responses, {}
+ write_inheritable_attribute :parents, []
+
+ only_allow_access_to :index, :new, :create, :edit, :update, :destroy,
+ :move_higher, :move_lower, :move_to_top, :move_to_bottom,
+ :when => [:admin], :denied_url => { :controller => 'page', :action => 'index' },
+ :denied_message => 'You must have admin privileges to perform this action.'
+
+ make_resourceful do
+ actions :index, :new, :create, :edit, :update, :destroy
+
+ response_for :create, :update, :destroy do |format|
+ format.html { redirect_to objects_path }
+ end
+ end
+
+ %w{move_higher move_lower move_to_top move_to_bottom}.each do |action|
+ define_method action do
+ load_object
+ current_object.send(action)
+ respond_to do |format|
+ format.html { redirect_to objects_path }
+ format.js do
+ id = "#{current_model_name.underscore}_#{current_object.id}"
+ render :update do |page|
+ page[id].__send__(action)
+ page.visual_effect(:highlight, id)
+ end
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,10 @@
+module SitesHelper
+ def order_links(site)
+ returning String.new do |output|
+ output << link_to(image("move_to_top.png", :alt => "Move to top"), move_to_top_site_path(site), :method => :put)
+ output << link_to(image("move_higher.png", :alt => "Move up"), move_higher_site_path(site), :method => :post)
+ output << link_to(image("move_lower.png", :alt => "Move down"), move_lower_site_path(site), :method => :post)
+ output << link_to(image("move_to_bottom.png", :alt => "Move to bottom"), move_to_bottom_site_path(site), :method => :put)
+ end
+ end
+end
@@ -0,0 +1,39 @@
+class Site < ActiveRecord::Base
+ acts_as_list
+ order_by "position ASC"
+ class << self
+ def find_for_host(hostname = '')
+ default, normal = find(:all).partition {|s| s.domain.blank? }
+ matching = normal.find do |site|
+ hostname == site.base_domain || hostname =~ Regexp.compile(site.domain)
+ end
+ matching || default.first
+ end
+ end
+
+ belongs_to :homepage, :class_name => "Page", :foreign_key => "homepage_id"
+ validates_presence_of :name, :base_domain
+ validates_uniqueness_of :domain
+
+ after_create :create_homepage
+
+ def url(path = "/")
+ uri = URI.join("http://#{self.base_domain}", path)
+ uri.to_s
+ end
+
+ def dev_url(path = "/")
+ uri = URI.join("http://#{Radiant::Config['dev.host']|| 'dev'}.#{self.base_domain}", path)
+ uri.to_s
+ end
+
+ def create_homepage
+ if self.homepage_id.blank?
+ self.homepage = self.build_homepage(:title => "#{self.name} Homepage",
+ :slug => "#{self.name.slugify}", :breadcrumb => "Home",
+ :status => Status[:draft])
+ self.homepage.parts << PagePart.new(:name => "body", :content => "")
+ save
+ end
+ end
+end
@@ -0,0 +1,45 @@
+<% content_for :page_css do %>
+ #content { padding-top: 2.25em; position: relative; }
+ #sites {
+ position: absolute;
+ top: 0;
+ left: 0;
+ font-size: 80%;
+ line-height: 2em;
+ padding-left: 1.5em;
+ padding-top: 0.25em;
+ }
+ #sites a, #sites a:visited {
+ color: black;
+ margin-right: 10px;
+ }
+<% end %>
+<div id="sites">
+ <% Site.find(:all).each do |site| %>
+ <% name = (@site == site) ? "<strong>#{site.name}</strong>" : site.name -%>
+ <%= link_to name, page_index_path(:root => site.homepage) %>
+ <% end %>
+</div>
+
+<% if Radiant::Config['multi_site.scoped?'] %>
+ <% content_for :page_scripts do %>
+ // Override so the expander causes it to be rescoped
+ SiteMap.prototype.toggleBranch = function(row, img) {
+ this.expandedRows = [];
+ this.saveExpandedCookie();
+ var id = row.id.split("-").last();
+ window.location = <%= page_index_url.to_json %> + "?root=" + id;
+ };
+ <% end %>
+ <% if @homepage %>
+ <p id="breadcrumbs">
+ <% [@homepage, @homepage.ancestors].flatten.reverse.each do |page| %>
+ <% unless page == @homepage %>
+ <%= link_to page.title, page_index_path(:root => page.id) %> &gt;
+ <% else %>
+ <em><%= page.title %></em>
+ <% end %>
+ <% end %>
+ </p>
+ <% end %>
+<% end %>
@@ -0,0 +1,23 @@
+.form-area
+ %p
+ %label{:for => "site_name"} Name
+ %br/
+ = f.text_field :name
+ %p
+ %label{:for => "site_domain"} Domain pattern
+ %br/
+ = f.text_field :domain
+ %p
+ %label{:for => "site_base_domain"} Base domain name
+ %br/
+ = f.text_field :base_domain
+ %p
+ %label{:for => "site_homepage_id"} Homepage ID
+ = f.text_field :homepage_id
+ %br/
+ - if f.object.new_record?
+ (A new homepage will automatically be created if not specified.)
+%p
+ = submit_tag "Save"
+ or
+ = link_to "cancel", sites_path
@@ -0,0 +1,3 @@
+%h1 Edit Site
+- form_for :site, @site, :url => site_path(@site), :html => {:method => :put} do |f|
+ = render :partial => "form", :locals => {:f => f}
@@ -0,0 +1,20 @@
+%h1 Sites
+
+%table{:class => "index", :cellspacing => "0"}
+ %thead
+ %tr
+ %th Name
+ %th Domain match
+ %th Base domain
+ %th Modify
+ %th Order
+ %tbody
+ - @sites.each do |site|
+ %tr[site]
+ %td= link_to site.name, edit_site_path(site)
+ %td= h(site.domain)
+ %td= h(site.base_domain)
+ %td= link_to image("remove.png", :alt => "Remove"), object_path(site), :method => :delete
+ %td= order_links(site)
+%p
+ = link_to "New Site", new_site_path
@@ -0,0 +1,3 @@
+%h1 New Site
+- form_for :site, @site, :url => sites_path do |f|
+ = render :partial => "form", :locals => {:f => f}
@@ -0,0 +1,13 @@
+class CreateSites < ActiveRecord::Migration
+ def self.up
+ create_table :sites do |t|
+ t.column :name, :string
+ t.column :domain, :string
+ t.column :homepage_id, :integer
+ end
+ end
+
+ def self.down
+ drop_table :sites
+ end
+end
@@ -0,0 +1,9 @@
+class AddOrderToSites < ActiveRecord::Migration
+ def self.up
+ add_column :sites, :position, :integer, :default => 0
+ end
+
+ def self.down
+ remove_column :sites, :position
+ end
+end
@@ -0,0 +1,11 @@
+class AddBaseDomainToSites < ActiveRecord::Migration
+ def self.up
+ add_column :sites, :base_domain, :string
+ Site.reset_column_information
+ Site.update_all "base_domain = 'tempdomain'"
+ end
+
+ def self.down
+ remove_column :sites, :base_domain
+ end
+end
@@ -0,0 +1,63 @@
+module MultiSite::PageControllerExtensions
+ def self.included(base)
+ base.class_eval {
+ alias_method_chain :index, :root
+ alias_method_chain :clear_model_cache, :site
+ alias_method_chain :continue_url, :site
+ %w{remove clear_cache}.each do |m|
+ alias_method_chain m.to_sym, :back
+ end
+ }
+ end
+
+ def index_with_root
+ if params[:root] # If a root page is specified
+ @homepage = Page.find(params[:root])
+ @site = @homepage.root.site
+ elsif @site = Site.find(:first, :order => "position ASC") # If there is a site defined
+ if @site.homepage
+ @homepage = @site.homepage
+ else
+ index_without_root
+ end
+ else # Just do the default
+ index_without_root
+ end
+ end
+
+ def remove_with_back
+ @page = Page.find(params[:id])
+ if request.post?
+ announce_pages_removed(@page.children.count + 1)
+ @page.destroy
+ return_url = session[:came_from]
+ session[:came_from] = nil
+ if return_url && return_url != page_index_url(:root => @page)
+ redirect_to return_url
+ else
+ redirect_to page_index_url(:page => @page.parent)
+ end
+ else
+ session[:came_from] = request.env["HTTP_REFERER"]
+ end
+ end
+
+ def clear_cache_with_back
+ if request.post?
+ @cache.clear
+ announce_cache_cleared
+ redirect_to :back
+ else
+ render :text => 'Do not access this URL directly.'
+ end
+ end
+
+ def clear_model_cache_with_site
+ Page.current_site ||= @site || @page.root.site
+ clear_model_cache_without_site
+ end
+
+ def continue_url_with_site(options={})
+ options[:redirect_to] || (params[:continue] ? page_edit_url(:id => model.id) : page_index_url(:root => model.root.id))
+ end
+end
@@ -0,0 +1,32 @@
+module MultiSite::PageExtensions
+ def self.included(base)
+ base.class_eval {
+ alias_method_chain :url, :sites
+ mattr_accessor :current_site
+ has_one :site, :foreign_key => "homepage_id", :dependent => :nullify
+ }
+ base.extend ClassMethods
+ class << base
+ alias_method_chain :find_by_url, :sites
+ end
+ end
+
+ module ClassMethods
+ def find_by_url_with_sites(url, live=true)
+ root = find_by_parent_id(nil)
+ if self.current_site.is_a?(Site)
+ root = self.current_site.homepage
+ end
+ raise Page::MissingRootPageError unless root
+ root.find_by_url(url, live)
+ end
+ end
+
+ def url_with_sites
+ if parent
+ parent.child_url(self)
+ else
+ "/"
+ end
+ end
+end
Oops, something went wrong.

0 comments on commit 374285d

Please sign in to comment.