From 7edd3c5fe98743a3b79e40b0088221d6f99853b1 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 17 Sep 2012 18:13:16 +0100 Subject: [PATCH 1/4] cleaned up interaction of HAML and foundation, broke out a new header fragment --- app/views/home/index.html.erb | 30 -------------------- app/views/layouts/_footer.html.haml | 29 +++++++++++-------- app/views/layouts/_header.html.haml | 37 +++++++++++++++++++++++++ app/views/layouts/application.html.haml | 28 ++++++------------- 4 files changed, 64 insertions(+), 60 deletions(-) delete mode 100644 app/views/home/index.html.erb create mode 100644 app/views/layouts/_header.html.haml diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb deleted file mode 100644 index 98bfd7da6..000000000 --- a/app/views/home/index.html.erb +++ /dev/null @@ -1,30 +0,0 @@ -<% content_for :title, "Growstuff dev site" %> - -
-
- -
-
-
-
-

Growstuff dev site

-

We're a community of gardeners

-
-
-
- -
- - diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index 68d3351d4..26979a2e3 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -1,11 +1,18 @@ -%ul - %li - = link_to "About", "https://github.com/Growstuff/project/wiki/About%20Growstuff" - %li - = link_to "License", "https://github.com/Growstuff/growstuff/blob/dev/LICENSE.txt" - %li - = link_to "Github", "https://github.com/Growstuff/" - %li - = link_to "Mailing list", "http://lists.growstuff.org/mailman/listinfo/discuss" - %li - = link_to "Community Guidelines", "https://github.com/Growstuff/policy/blob/master/community-guidelines.md" + + +.row + .ten.columns + %ul.link-list + %li + = link_to "About", "https://github.com/Growstuff/project/wiki/About%20Growstuff" + %li + = link_to "License", "https://github.com/Growstuff/growstuff/blob/dev/LICENSE.txt" + %li + = link_to "Github", "https://github.com/Growstuff/" + %li + = link_to "Mailing list", "http://lists.growstuff.org/mailman/listinfo/discuss" + %li + = link_to "Community Guidelines", "https://github.com/Growstuff/policy/blob/master/community-guidelines.md" + + + diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml new file mode 100644 index 000000000..567b1a143 --- /dev/null +++ b/app/views/layouts/_header.html.haml @@ -0,0 +1,37 @@ + + +%head + + + + %title + = content_for?(:title) ? yield(:title) : "Growstuff" + = stylesheet_link_tag "application", :media => "all" + = javascript_include_tag "application" + = csrf_meta_tags + + + +.row + .ten.columns + - if user_signed_in? + %ul.link-list + %li + You are signed in as + = current_user.email + "." + %li + = link_to("Log out", destroy_user_session_path) + - else + %ul.link-list + %li + = link_to('Sign up', new_user_registration_path) + %li + = link_to('Log in', new_user_session_path) + +.row + .ten.columns + %h1 + = link_to('Growstuff', root_path) + + +
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index fa238c607..119cb0e26 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,19 +1,9 @@ -%html - %head - - - - %title - = content_for?(:title) ? yield(:title) : "Growstuff" - = stylesheet_link_tag "application", :media => "all" - = javascript_include_tag "application" - = csrf_meta_tags - %body - - if notice - %p.notice - = notice - - if alert - %p.alert - = alert - = yield - = render :partial => "layouts/footer" += render :partial => "layouts/header" +- if notice + %p.notice + = notice +- if alert + %p.alert + = alert += yield += render :partial => "layouts/footer" From e2f035265ab9a0068830c21561071aaffba55a12 Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 17 Sep 2012 18:13:44 +0100 Subject: [PATCH 2/4] oops, don't need that HTML comment there --- app/views/layouts/_header.html.haml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 567b1a143..84733ad19 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -33,5 +33,4 @@ %h1 = link_to('Growstuff', root_path) -
From a959d491e80a089a5100fe571ce8febe2f44e70d Mon Sep 17 00:00:00 2001 From: Skud Date: Mon, 17 Sep 2012 18:24:49 +0100 Subject: [PATCH 3/4] added comments to explain mix of HTML and HAML in header/footer fragments --- app/views/layouts/_footer.html.haml | 1 + app/views/layouts/_header.html.haml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index 26979a2e3..a92d8777c 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -1,4 +1,5 @@
+- # There are some tags here, such as these close div tags and the close body and html tags below, which were opened in the header fragment. HAML can't handle this, so they're done in HTML instead. .row .ten.columns diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 84733ad19..0ed4e4aa2 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,4 +1,5 @@ +- # There are some tags here, such as html, body, etc, which are opened in this file and closed in the footer fragment. HAML can't handle this, so they're left as HTML. If you were wondering. %head From ea3067ff36c3beba69f4d788949b36939bb01e26 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Tue, 18 Sep 2012 18:52:37 +0100 Subject: [PATCH 4/4] Replace most of the HTML-in-HAML - We do this by moving code between files such that every tag starts and ends within a single file. This seems like a good invariant to maintain from a robustness point-of-view. - One consequence is that I had to split _header into _meta (metadata - the HTML head tag) and _header (the visible page header). These probably aren't the best names. - I've left some HTML in _meta, on the grounds that it maintains the file-contains-whole-tag invariant and the HTML code is fractionally shorter than the HAML required to generate it. --- app/views/layouts/_footer.html.haml | 6 ------ app/views/layouts/_header.html.haml | 16 ---------------- app/views/layouts/_meta.html.haml | 10 ++++++++++ app/views/layouts/application.html.haml | 23 ++++++++++++++--------- 4 files changed, 24 insertions(+), 31 deletions(-) create mode 100644 app/views/layouts/_meta.html.haml diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index a92d8777c..5e728baaf 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -1,6 +1,3 @@ -
-- # There are some tags here, such as these close div tags and the close body and html tags below, which were opened in the header fragment. HAML can't handle this, so they're done in HTML instead. - .row .ten.columns %ul.link-list @@ -14,6 +11,3 @@ = link_to "Mailing list", "http://lists.growstuff.org/mailman/listinfo/discuss" %li = link_to "Community Guidelines", "https://github.com/Growstuff/policy/blob/master/community-guidelines.md" - - - diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 0ed4e4aa2..ef413ee18 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,18 +1,3 @@ - -- # There are some tags here, such as html, body, etc, which are opened in this file and closed in the footer fragment. HAML can't handle this, so they're left as HTML. If you were wondering. - -%head - - - - %title - = content_for?(:title) ? yield(:title) : "Growstuff" - = stylesheet_link_tag "application", :media => "all" - = javascript_include_tag "application" - = csrf_meta_tags - - - .row .ten.columns - if user_signed_in? @@ -34,4 +19,3 @@ %h1 = link_to('Growstuff', root_path) -
diff --git a/app/views/layouts/_meta.html.haml b/app/views/layouts/_meta.html.haml new file mode 100644 index 000000000..89ca1c3d8 --- /dev/null +++ b/app/views/layouts/_meta.html.haml @@ -0,0 +1,10 @@ +%head + + + + %title + = content_for?(:title) ? yield(:title) : "Growstuff" + = stylesheet_link_tag "application", :media => "all" + = javascript_include_tag "application" + = csrf_meta_tags + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 119cb0e26..01c9e37ad 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,9 +1,14 @@ -= render :partial => "layouts/header" -- if notice - %p.notice - = notice -- if alert - %p.alert - = alert -= yield -= render :partial => "layouts/footer" +%html + = render :partial => "layouts/meta" + %body + = render :partial => "layouts/header" + .row + .ten.columns + - if notice + %p.notice + = notice + - if alert + %p.alert + = alert + = yield + = render :partial => "layouts/footer"