modular layouts, some steps towards blog layout

master
muflax 2012-04-16 18:03:46 +02:00
parent 1f9922805e
commit 194502a425
13 changed files with 176 additions and 103 deletions

21
layouts/blog.erb Normal file
View File

@ -0,0 +1,21 @@
<%= render 'header' %>
<%= render 'main-header', :toc => true %>
<%= render 'title' %>
<%= render 'mindkiller' %>
<%= render 'episteme' %>
<% render 'content' do %>
<%= yield %>
<% end %>
<%= render 'comments' %>
<%= render 'main-footer', :toc => true %>
<%= render 'breadcrumb' %>
<%= render 'footer' %>

6
layouts/breadcrumb.erb Normal file
View File

@ -0,0 +1,6 @@
<!-- breadcrumb navigation -->
<div id="crumb">
<%= breadcrumbs.map do |crumb|
"<a class='crumb' href='#{crumb[:link]}'>#{crumb[:title].downcase}</a>"
end.join(" » ") %>
</div>

25
layouts/comments.erb Normal file
View File

@ -0,0 +1,25 @@
<!-- comments -->
<% unless @item[:no_comments] or @item[:is_category] %>
<div id="disqus">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = '<%= disqus_site %>';
var disqus_identifier = '<%= @item.identifier %>';
var disqus_url = '<%= disqus_url @item %>';
(function() {
var dsq = document.createElement('script')
dsq.type = 'text/javascript'
dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the
<a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>
</noscript>
<a href="http://disqus.com" class="dsq-brlink">
blog comments powered by <span class="logo-disqus">Disqus</span>
</a>
</div>
<% end %>

6
layouts/content.erb Normal file
View File

@ -0,0 +1,6 @@
<!-- actual content (not indented to protect markdown) -->
<div id="content">
<%= yield %>
</div>

View File

@ -1,111 +1,21 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><%= @item[:title] %></title>
<link rel="stylesheet" type="text/css" href="/styles/default.css"/>
<meta name="generator" content="nanoc"/>
<link rel="alternate" href="/rss.xml" type="application/rss+xml" title="lies and wonderland"/>
<!-- google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25523509-1']);
_gaq.push(['_trackPageview']);
<%= render 'header' %>
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="<%= @item[:toc] ? "body-toc" : "body" %>">
<!-- main part -->
<div id="main">
<!-- page title -->
<% if @item[:title] %>
<div id="title"><h1 class="title">
<a class="title" href="/">
<%= @item[:is_category] ? "Category Index" : @item[:title] %>
</a>
</h1></div>
<% end %>
<%= render 'main-header', :toc => true %>
<% if @item.mindkiller? %>
<div id="mindkiller">
<p><strong>Warning</strong>: this page contains mind-killing content. Proceed with caution. The <a href="/tl;dr/">author</a> does not endorse any of the views expressed here, even when they may look convincing. If you feel offended, consider that the author might be trolling you and whether you want to encourage them even further.</p>
</div>
<% end %>
<!-- epistemic and technical state -->
<% if @item.epistemic? %>
<div id="episteme">
<p><span class="align_left">
Last modified:
<a class='episteme' href='/changelog/'>
<%= @item[:date] %>
</a> (<%= techne @item[:techne] %>).
</span>
<span class="align_right">
Epistemic state:
<a class='episteme' href='/episteme/'>
<%= episteme @item[:episteme] %></a>.
</span>
</p>
</div>
<% end %>
<%= render 'title' %>
<!-- actual content (not indented to protect markdown) -->
<div id="content">
<%= render 'mindkiller' %>
<%= yield %>
<%= render 'episteme' %>
</div>
<!-- comments -->
<% unless @item[:no_comments] or @item[:is_category] %>
<div id="disqus">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_shortname = 'muflax';
var disqus_identifier = '<%= @item.identifier %>';
var disqus_url = 'http://muflax.com<%= @item.identifier %>';
<% render 'content' do %>
<%= yield %>
<% end %>
(function() {
var dsq = document.createElement('script')
dsq.type = 'text/javascript'
dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the
<a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a>
</noscript>
<a href="http://disqus.com" class="dsq-brlink">
blog comments powered by <span class="logo-disqus">Disqus</span>
</a>
</div>
<% end %>
</div>
<%= render 'comments' %>
<% if @item[:toc] %>
<!-- navigation sidebar with toc -->
<div id="nav">
<div id="toc">
<%= toc %>
</div>
</div>
<% end %>
<%= render 'main-footer', :toc => true %>
</div>
<!-- breadcrumb navigation -->
<div id="crumb">
<%= breadcrumbs.map do |crumb|
"<a class='crumb' href='#{crumb[:link]}'>#{crumb[:title].downcase}</a>"
end.join(" » ") %>
</div>
</body>
</html>
<%= render 'breadcrumb' %>
<%= render 'footer' %>

14
layouts/episteme.erb Normal file
View File

@ -0,0 +1,14 @@
<!-- epistemic and technical state -->
<% if @item.epistemic? %>
<div id="episteme">
<p><span class="align_left">
Last modified: <%= @item[:date] %> (<%= techne @item[:techne] %>).
</span>
<span class="align_right">
Epistemic state:
<a class='episteme' href='/episteme/'>
<%= episteme @item[:episteme] %></a>.
</span>
</p>
</div>
<% end %>

2
layouts/footer.erb Normal file
View File

@ -0,0 +1,2 @@
</body>
</html>

22
layouts/header.erb Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title><%= @item[:title] %></title>
<link rel="stylesheet" type="text/css" href="/styles/default.css"/>
<meta name="generator" content="nanoc"/>
<link rel="alternate" href="/rss.xml" type="application/rss+xml" title="<%= site_title %>"/>
<!-- google analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-25523509-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>

13
layouts/main-footer.erb Normal file
View File

@ -0,0 +1,13 @@
</div>
<% if @toc %>
<% if @item[:toc] %>
<!-- navigation sidebar with toc -->
<div id="nav">
<div id="toc">
<%= toc %>
</div>
</div>
<% end %>
</div>
<% end %>

6
layouts/main-header.erb Normal file
View File

@ -0,0 +1,6 @@
<% if @toc %>
<div id="<%= @item[:toc] ? "body-toc" : "body" %>">
<% end %>
<!-- main part -->
<div id="main">

5
layouts/mindkiller.erb Normal file
View File

@ -0,0 +1,5 @@
<% if @item.mindkiller? %>
<div id="mindkiller">
<p><strong>Warning</strong>: this page contains mind-killing content. Proceed with caution. The <a href="/contact/">author</a> does not endorse any of the views expressed here, even when they may look convincing. If you feel offended, consider that the author might be trolling you and whether you want to encourage them even further.</p>
</div>
<% end %>

8
layouts/title.erb Normal file
View File

@ -0,0 +1,8 @@
<!-- page title -->
<% if @item[:title] %>
<div id="title"><h1 class="title">
<a class="title" href="/">
<%= @item[:is_category] ? "Category Index" : @item[:title] %>
</a>
</h1></div>
<% end %>

View File

@ -10,3 +10,38 @@ def sites
Dir['content_*'].map{|d| d.gsub(/^content_/, '')}
end
def disqus_site
# TODO merge them all?
# site -> disqus shortname
case $site
when "muflax"
"muflax"
when "sutra"
"muflaxsutra"
when "daily"
"dailymuflax"
when "blog"
"muflaxblog"
else # put 'em on the main site
"muflax"
end
end
def disqus_url item
"http://#{main_site? ? "" : "#{$site}."}muflax.com#{item.identifier}"
end
def site_title
case $site
when "muflax"
"lies and wonderland"
when "sutra"
"Blogchen"
when "daily"
"muflax becomes a saint"
when "blog"
"muflax' mindstream"
else # placeholder
"muflaxia"
end
end