One-Click S5 Template

Make it yet-easier to create
S5 slideshows.
This commit is contained in:
Jacques Distler 2010-01-28 23:37:10 -06:00
parent 675df6b6c5
commit 5506f87f17
4 changed files with 36 additions and 1 deletions

View file

@ -80,7 +80,17 @@ class WikiReference < ActiveRecord::Base
row = connection.select_one(sanitize_sql([query, page_name]))
row['name'].as_utf8 if row
end
def self.page_categories(web, page_name)
query =
"SELECT referenced_name FROM wiki_references JOIN pages " +
"ON wiki_references.page_id = pages.id " +
"WHERE pages.name = ? " +
"AND wiki_references.link_type = '#{CATEGORY}' " +
"AND pages.web_id = '#{web.id}'"
names = connection.select_all(sanitize_sql([query, page_name])).map { |row| row['referenced_name'].as_utf8 }
end
def self.pages_in_category(web, category)
query =
"SELECT name FROM pages JOIN wiki_references " +

View file

@ -69,5 +69,9 @@ function cleanAuthorName() {
}
document.forms["editForm"].elements["content"].focus();
<%- if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) and
!WikiReference.page_categories(@web, @page.name).include?('S5-slideshow') -%>
addS5button('<%= CGI.escapeHTML(@page.name) %>');
<%- end -%>
//--><!]]>
</script>

View file

@ -31,4 +31,7 @@ function cleanAuthorName() {
}
}
document.forms["editForm"].elements["content"].focus();
<%- if [:markdownMML, :markdownPNG, :markdown].include?(@web.markup) -%>
addS5button('<%= CGI.escapeHTML(@page_name) %>');
<%- end -%>
</script>

View file

@ -53,6 +53,24 @@ function mactionWorkarounds() {
});
}
function addS5button(page_name) {
var f = $('MarkupHelp');
if (f) {
var s5button = new Element('input', {id:'S5button', type:'button', value: 'Make this page an S5 slideshow'});
f.insert({top: s5button});
Event.observe(s5button, 'click', function(){
var preamble = "author: " + document.getElementById('author').value +
"\ncompany: \ntitle: " + page_name +
"\nsubtitle: \nslide_theme: default\nslide_footer: \nslide_subfooter: " +
"\n\n:category: S5-slideshow\n\n" + page_name +
"\n==============\n\nMy First Slide\n-----------------\n\n";
var content = document.getElementById('content');
content.value = preamble + content.value;
document.getElementById('S5button').hide();
});
}
}
function updateSize(elt, w, h) {
// adjust to the size of the user's browser area.
// w and h are the original, unadjusted, width and height per row/column