Skip to content

Commit

Permalink
Tweaking flipbook slightly:
Browse files Browse the repository at this point in the history
Now with 100% more expandable/collapse DIVs!!!!
  • Loading branch information
judofyr committed Nov 2, 2009
1 parent c40ee52 commit a74e56c
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 40 deletions.
18 changes: 15 additions & 3 deletions extras/rdoc/generator/singledarkfish.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class RDoc::Generator::SingleDarkfish < RDoc::Generator::Darkfish
org = instance_method(:http_url)
define_method(:http_url) do |prefix|
if RDoc::Generator::SingleDarkfish.current?
prefix + full_name
prefix + full_name.gsub("::", '-')
else
org.bind(self).call(prefix)
end
Expand All @@ -74,7 +74,7 @@ class RDoc::Generator::SingleDarkfish < RDoc::Generator::Darkfish
org = instance_method(:path)
define_method(:path) do
if RDoc::Generator::SingleDarkfish.current?
"##{@aref}"
"/api.html##{@aref}"
else
org.bind(self).call
end
Expand Down Expand Up @@ -115,7 +115,7 @@ def initialize( options )
######

def class_dir
'#class-'
'/api.html#class-'
end

def template(name)
Expand Down Expand Up @@ -164,6 +164,18 @@ def generate_thing(name, to)
render_template(templatefile, binding, outfile)
end

def methods_for(klass)
klass.methods_by_type.each do |type, visibilities|
next if visibilities.empty?
visibilities.each do |visibility, methods|
next if methods.empty?
methods.each do |method|
yield method, type, visibility
end
end
end
end

## For book.rhtml

def chapters
Expand Down
65 changes: 65 additions & 0 deletions extras/rdoc/generator/template/flipbook/js/camping.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// I know, I know.
$(function() {
$('.source-link a').click(function() {
var link = $(this);
Expand All @@ -11,4 +12,68 @@ $(function() {
}
return false;
});

if ($('.ref')[0]) {

$('.mod').hide();
$('.method').hide();

var hash = window.location.hash.replace(/--$/, '');

if (hash.substring(0, 2) == "#M") {
// Show the method and the section
m(hash).show();
} else if (hash.substring(0, 7) == "#class-") {
// Show the section.
s(hash).show();
} else {
// Show the first section.
s("h2:first").show();
}

// We need to scroll!
if (hash != window.location.hash) {
window.location.hash = hash;
}

$('a[href*="#class-"]').click(function() {
var link = this.href;
var id = link.substring(link.indexOf("#"));
if ($(this).parent().is("h2")) {
// We're in a headline
s(id).toggle();
window.location.hash = id + "--";
return false;
} else {
// A normal link
s(id).show();
}
});

$('a[href*="#M"]').click(function() {
var link = this.href;
var id = link.substring(link.indexOf("#"));
if ($(this).parent().is("h4")) {
// We're in a headline
window.location.hash = id + "--";
s(id).toggle();
return false;
} else {
// Normal link
m(id).show();
}
});

// #M0001 -> $(the section + the method body)
function m(name) {
var base = $(name);
return base.parent().add(base.next());
}

// #class-something -> $(the section below)
function s(name) {
return $(name).next();
}
}

});
4 changes: 2 additions & 2 deletions extras/rdoc/generator/template/flipbook/page.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<li><a href="<%= rel_prefix %>/index.html">front</a> | </li>
<li><a href="<%= rel_prefix %>/book.html">ToC</a> | </li>
<li><a href="<%= rel_prefix %>/api.html">reference</a> | </li>
<li><a href="http://wiki.github.com/why/camping">wiki</a> | </li>
<li><a href="http://github.com/why/camping">code</a></li>
<li><a href="http://wiki.github.com/camping/camping">wiki</a> | </li>
<li><a href="http://github.com/camping/camping">code</a></li>
</ul>
<p id="version">Camping <%= VERS %></p>
</div>
Expand Down
32 changes: 25 additions & 7 deletions extras/rdoc/generator/template/flipbook/rdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ h1 { font-size: 36px; margin: 1em; }
h2 { font-size: 24px }
h3, p#version { font-size: 19px }
h4 { font-size: 17px; font-weight: normal; }
h4.ruled { border-bottom: solid 1px #CC9; }
h2.ruled { padding-top: 35px; border-top: solid 1px #AA5; }

/* Link styles */
Expand Down Expand Up @@ -71,14 +70,33 @@ h2.ruled { padding-top: 35px; border-top: solid 1px #AA5; }
text-align: center;
}

.permalink {
background-image: url(images/permalink.gif);
text-indent: -1000px;
height: 11px;
width: 11px;
display: inline-block;
.ref h2 a {
background-color: #eee;
color: black;
display: block;
text-align: left;
text-decoration: none;
padding: 0.5em 1em;
}

.ref h2 a:hover {
text-decoration: underline;
}

.ref h4 a {
border-bottom: solid 1px #CC9;
color: #000;
display: block;
text-decoration: none;
}

.ref h4 a:hover {
border-color: #694;
}

.ref .mod {
padding: 0 2em;
}

pre { font-weight: bold; color: #730; }
tt { color: #703; font-size: 12pt; }
Expand Down
4 changes: 2 additions & 2 deletions extras/rdoc/generator/template/flipbook/readme.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<ul id="links">
<li><a href="<%= rel_prefix %>/book.html">book</a> | </li>
<li><a href="<%= rel_prefix %>/api.html">reference</a> | </li>
<li><a href="http://wiki.github.com/why/camping">wiki</a> | </li>
<li><a href="http://github.com/why/camping">code</a></li>
<li><a href="http://wiki.github.com/camping/camping">wiki</a> | </li>
<li><a href="http://github.com/camping/camping">code</a></li>
</ul>
<p id="version">Camping <%= VERS %></p>
</div>
Expand Down
55 changes: 31 additions & 24 deletions extras/rdoc/generator/template/flipbook/reference.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,60 @@
<ul id="links">
<li><a href="<%= rel_prefix %>/index.html">front</a> | </li>
<li><a href="<%= rel_prefix %>/book.html">book</a> | </li>
<li><a href="http://wiki.github.com/why/camping">wiki</a> | </li>
<li><a href="http://github.com/why/camping">code</a></li>
<li><a href="http://wiki.github.com/camping/camping">wiki</a> | </li>
<li><a href="http://github.com/camping/camping">code</a></li>
</ul>
<p id="version">Camping <%= VERS %></p>
</div>

<div id="fullpage">
<div class="page_shade">
<div class="page">
<div class="page ref">
<p class="header"><%= Time.now %></p>
<h1>Camping, the Reference</h1>

<% @modsort.each do |klass| %>
<h2 class="ruled" id="class-<%= klass.full_name %>">
<% @modsort.each_with_index do |klass, index| %>
<h2 id="<%= klass.path[/#(.*)$/, 1] %>">
<a href="<%= klass.path[/#(.*)$/] %>">
<%= klass.type.capitalize %>
<%= klass.full_name %>
<% if klass.type == 'class' %>
&lt;
<% unless String === klass.superclass %>
<%= klass.superclass.full_name %>
<% else %>
<%= klass.superclass %>
<% end %>
<% end %>
</a>
</h2>

<%= klass.description %>

<h3>Methods</h3>
<% klass.methods_by_type.each do |type, visibilities|
next if visibilities.empty?
visibilities.each do |visibility, methods|
next if methods.empty?
methods.each do |method| %>
<h4 class="ruled" id="<%= method.aref %>">
<%= visibility.to_s.capitalize %> <%= type.capitalize %> method:
<strong><%= method.pretty_name %><%= method.params%></strong>
<a href="<%= method.path %>" class="permalink">[permalink]</a>
</h4>
<%= method.description %>
<p class="source-link">[ <a href="#">show source</a> ]</p>
<div class="mod">
<%= klass.description.gsub(/<(\/?)h(\d)>/) do
# replace <h2> with <h3> and so.
"<#{$1}h#{$2.to_i + 1}>"
end %>

<h3>Methods</h3>
<% methods_for(klass) do |method, type, visibility| %>
<h4 class="ruled" id="<%= method.aref %>">
<a href="#<%= method.aref %>">
<%= visibility.to_s.capitalize %> <%= type.capitalize %> method:
<strong><%= method.pretty_name %><%= method.params %></strong>
<img src="<%= rel_prefix %>/images/permalink.gif">
</a>
</h4>
<div class="method">
<%= method.description %>
<p class="source-link">[ <a href="#">show source</a> ]</p>
<pre class="sourcecode">
<%= method.markup_code %>
</pre>
<% end
end
end
end %>
</div>
<% end %>
</div>
<% end %>
</div>
</div>
</div>
</body>
Expand Down
4 changes: 2 additions & 2 deletions extras/rdoc/generator/template/flipbook/toc.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<ul id="links">
<li><a href="<%= rel_prefix %>/index.html">front</a> | </li>
<li><a href="<%= rel_prefix %>/api.html">reference</a> | </li>
<li><a href="http://wiki.github.com/why/camping">wiki</a> | </li>
<li><a href="http://github.com/why/camping">code</a></li>
<li><a href="http://wiki.github.com/camping/camping">wiki</a> | </li>
<li><a href="http://github.com/camping/camping">code</a></li>
</ul>
<p id="version">Camping <%= VERS %></p>
</div>
Expand Down

0 comments on commit a74e56c

Please sign in to comment.