 |
Forums |
Admin Discussion Forums: help Start New Thread
By: Kai Thöne
RE: Create pages / directories [ reply ] 2011-10-12 16:26
|
Thank you for answering.
Now I wrote a method to create such pages:
def create_page_from_memory(website_p, context_p, path_p, content_p)
memory_handler = website_p.cache.instance('Webgen::SourceHandler::Memory')
return website_p.blackboard.invoke(:create_nodes, Webgen::Path.new(path_p, '/'), memory_handler) do |node_path|
memory_handler.create_node(node_path, context_p.ref_node.alcn) do |pic_node|
(content_p.nil? ? nil : Webgen::Path::SourceIO.new { StringIO.new(content_p) })
end
end.first
end
Used in the 'call' method of a tag:
def call(tag, body, context)
website = Webgen::WebsiteAccess.website
...
create_page_from_memory(website, context, '/002.page', "---\ntitle: 002\n---\n\ncontent")
...
end
Very fine, but how to render such content and write a html-file?
Greets Kai.
|
By: Kai Thöne
Create pages / directories [ reply ] 2011-10-11 14:53
|
I wrote an extension to create a gallery. How it is possible to create pages and directories inside the processing of a tag.
Tag (example): {gallery: {dir: "img/galerie-001"}} based on an extension. How it is possible to create new pages and directories inside the 'call' method of the tag?
Started with:
website = Webgen::WebsiteAccess.website
root = website.tree.root
website.blackboard.invoke(:create_directories, root, '/__generated_content/', '/')
Don't how if this correct. And I don't know how to create pages just from code. A possible (unclean) solution would be to create all needed files in the src-directory. This requires multiple runs of webgen :-(
Greets Kai.
|
|
 |