From 496e249fd5f701491afac4ce516487d886cbf041 Mon Sep 17 00:00:00 2001 From: indranil-m Date: Tue, 17 Jul 2012 23:48:35 +0530 Subject: [PATCH] Creating a new page with custom template (task 1) and having menu partial automatically populated from the sitemap (task 2) --- config.rb | 21 ++++++++++++++++++++- source/layouts/template.html.erb | 14 ++++++++++++++ source/new.html | 3 +++ source/partials/_footer.html.erb | 1 + source/partials/_header.html.erb | 1 + source/partials/_menu.html.erb | 1 + 6 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 source/layouts/template.html.erb create mode 100644 source/new.html create mode 100644 source/partials/_footer.html.erb create mode 100644 source/partials/_header.html.erb create mode 100644 source/partials/_menu.html.erb diff --git a/config.rb b/config.rb index a0633d7..676b169 100644 --- a/config.rb +++ b/config.rb @@ -41,6 +41,25 @@ # @which_fake_page = "Rendering a fake page with a variable" # end + +page "/source/new.html", :layout => "template" + + +### +#Sitemaps +### + + +ready do + sitemap.pages.group_by {|p| p.data["source"] }.each do |source, pages| + page "/source/#{source}.html", :proxy => "new.html" do + @source = source + @pages = pages + end + end +end + + ### # Helpers ### @@ -82,4 +101,4 @@ # Or use a different image path # set :http_path, "/Content/images/" -end \ No newline at end of file +end diff --git a/source/layouts/template.html.erb b/source/layouts/template.html.erb new file mode 100644 index 0000000..893c922 --- /dev/null +++ b/source/layouts/template.html.erb @@ -0,0 +1,14 @@ + + + + Sample Template + + +
<%= render "partials/header" %>
+ <%= render :partial => "partials/menu" %> + + <%= yeild %> + + + + diff --git a/source/new.html b/source/new.html new file mode 100644 index 0000000..01c284e --- /dev/null +++ b/source/new.html @@ -0,0 +1,3 @@ +

Welcome to EntIO LLC

+ +

This is a sample page which uses a custom template

diff --git a/source/partials/_footer.html.erb b/source/partials/_footer.html.erb new file mode 100644 index 0000000..cf5c074 --- /dev/null +++ b/source/partials/_footer.html.erb @@ -0,0 +1 @@ +

this is sample footer

diff --git a/source/partials/_header.html.erb b/source/partials/_header.html.erb new file mode 100644 index 0000000..9a87695 --- /dev/null +++ b/source/partials/_header.html.erb @@ -0,0 +1 @@ +

This is sample header

diff --git a/source/partials/_menu.html.erb b/source/partials/_menu.html.erb new file mode 100644 index 0000000..283c02c --- /dev/null +++ b/source/partials/_menu.html.erb @@ -0,0 +1 @@ +<%= current_resource %>