Thomas Danckaert
2009-Mar-29 20:38 UTC
[webgen-users] 2 questions: printable version / labels
Hi, I''m thinking of using webgen to make website containing restaurant reviews. I''ve been playing around with webgen and reading the docs, but it''s not quite clear to me yet, whether the following things are already possible and if not, how difficult it would be to implement them: - I''d like to automatically create a version intended for printing (i.e. without site navigation and with minimal markup) of certain pages. Is there already a standard way of doing this? If not, would the solution be to write an extra content processor which does this? (Maybe someone else here has already written an extension for this?) - Is there a way of indexing articles by different properties? E.g. labeling restaurants per ''genre'' and per price range? I''m thinking I could use the tags from the blogging functionality for this, but that would only give me one index (e.g. I could use tags to allocate genres, but then I wouldn''t have another label for the price range). Would it be complicated to duplicate the tags functionality in order to have multiple indexes? (by the way: How do I actually use the blogging features? :) ) thanks for any advice! Thomas
Thomas Leitner
2009-Mar-30 14:58 UTC
[webgen-users] 2 questions: printable version / labels
> - I''d like to automatically create a version intended for printing > (i.e. without site navigation and with minimal markup) of certain > pages. Is there already a standard way of doing this? If not, would > the solution be to write an extra content processor which does this? > (Maybe someone else here has already written an extension for this?)If you mean creating PDF documents for your page files, I don''t know of any extension that can do that right now. However, the standard way of doing this, I believe, is using CSS and providing separate stylesheets for print and screen environments. It is easy to disable/hide certain parts of web site with CSS and CSS also provides options for inserting page breaks and the like.> - Is there a way of indexing articles by different properties? E.g. > labeling restaurants per ''genre'' and per price range? I''m thinking I > could use the tags from the blogging functionality for this, but that > would only give me one index (e.g. I could use tags to allocate > genres, but then I wouldn''t have another label for the price range). > Would it be complicated to duplicate the tags functionality in order > to have multiple indexes? (by the way: How do I actually use the > blogging features? :) )There is currently nothing implemented regarding tags or blog support, the only thing existing is automatic generation of feeds. Complete blog support is planned (since a long time actually :-( ) but not implemented currently. By the way: what exactly do you mean by indexing? If you want to list pages according to certain meta information, this should be doable by using some ERB fragments in your page/template files. Naturally, this would mean that you need a basic knowledge of the Ruby programming language. However, if you tell me enough of what you want to do, I should be able to jumpstart your coding. -- Thomas
Thomas Danckaert
2009-Mar-30 22:18 UTC
[webgen-users] 2 questions: printable version / labels
On Mar 30, 4:58?pm, Thomas Leitner <t_leit... at gmx.at> wrote:> > - I''d like to automatically create a version intended for printing > > (i.e. without site navigation and with minimal markup) of certain > > pages. Is there already a standard way of doing this? If not, would > > the solution be to write an extra content processor which does this? > > (Maybe someone else here has already written an extension for this?) > > If you mean creating PDF documents for your page files, I don''t know of > any extension that can do that right now. However, the standard way of > doing this, I believe, is using CSS and providing separate stylesheets > for print and screen environments. It is easy to disable/hide certain > parts of web site with CSS and CSS also provides options for inserting > page breaks and the like. >Doing it using CSS is what I meant. I''d like to make webgen generate the normal webpage and the html-file intended for printing (which would, indeed, use some different and sobre css) from a single .page file. I just don''t know what would be the most elegant and efficient way to do it.> > - Is there a way of indexing articles by different properties? E.g. > > labeling restaurants per ''genre'' and per price range? I''m thinking I > > could use the tags from the blogging functionality for this, but that > > would only give me one index (e.g. I could use tags to allocate > > genres, but then I wouldn''t have another label for the price range). > > Would it be complicated to duplicate the tags functionality in order > > to have multiple indexes? (by the way: How do I actually use the > > blogging features? :) ) > > There is currently nothing implemented regarding tags or blog support, > the only thing existing is automatic generation of feeds. Complete blog > support is planned (since a long time actually :-( ) but not > implemented currently. > > By the way: what exactly do you mean by indexing? If you want to list > pages according to certain meta information, this should be doable by > using some ERB fragments in your page/template files. Naturally, this > would mean that you need a basic knowledge of the Ruby programming > language. However, if you tell me enough of what you want to do, I > should be able to jumpstart your coding.This is also what I meant. It just wasn''t clear to me to what extent the blogging support was already implemented :) I''d like to add meta-information to certain .page files and then list these on overview pages. Sticking with the restaurant page, such .page file would contain a section like --- style: thai food pricerange: expensive --- and there would be an overview page listing all styles and all price ranges, and a page for each style, listing all restaurants in that style. I don''t want to ask you to do the coding, but if you could give me some pointers as to how this would fit best into the webgen framework, I''d sure be grateful :) I''ve toyed with php scripted pages before, so I guess I should be able to pull this off when I learn some ruby...> > -- Thomas > _______________________________________________ > webgen-users mailing list > webgen-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users
Thomas Leitner
2009-Apr-01 04:47 UTC
[webgen-users] 2 questions: printable version / labels
> Doing it using CSS is what I meant. I''d like to make webgen generate > the normal webpage and the html-file intended for printing (which > would, indeed, use some different and sobre css) from a single .page > file. I just don''t know what would be the most elegant and efficient > way to do it.Okay, then just use the page files as they were mainly intended to, namely to generate one HTML file from one page file and specify two different CSS files in your default.template: one for the screen version and one for the print version. This can be done like this: <link rel="stylesheet" href="{relocatable: screen.css}" type="text/css" media="screen" /> <link rel="stylesheet" href="{relocatable: print.css}" type="text/css" media="print" />> > By the way: what exactly do you mean by indexing? If you want to > > list pages according to certain meta information, this should be > > doable by using some ERB fragments in your page/template files. > > Naturally, this would mean that you need a basic knowledge of the > > Ruby programming language. However, if you tell me enough of what > > you want to do, I should be able to jumpstart your coding. > This is also what I meant. It just wasn''t clear to me to what extent > the blogging support was already implemented :) > I''d like to add meta-information to certain .page files and then list > these on overview pages. Sticking with the restaurant page, such .page > file would contain a section like > --- > style: thai food > pricerange: expensive > --- > and there would be an overview page listing all styles and all price > ranges, and a page for each style, listing all restaurants in that > style. I don''t want to ask you to do the coding, but if you could give > me some pointers as to how this would fit best into the webgen > framework, I''d sure be grateful :) > I''ve toyed with php scripted pages before, so I guess I should be able > to pull this off when I learn some ruby...I assume that you have the following files under src/: /overview.page /restaurants/rest1.page /restaurants/rest2.page Then you can start with the following fragment for listing the styles for the overview page: Listing all styles: <% context.content_node.tree[''/restaurants''].children.select {|c| c[''kind''] == ''page''}. collect {|c| c[''style'']}.uniq.sort.each do |style| style_node = ''/style_'' + style.tr('' '', ''_'') + ''.html'' %> <%= context.dest_node.link_to(style_node) %> <% end %> It works exactly the same for the price range listing but you have to replace the word ''style'' for ''pricerange'' in the code above. The code searches for all page files under the ''/restaurants'' directory and collects all style meta informations (`.uniq.sort` removes duplicates and sorts the entries by name). Since each style has its own page file, the canoncial name for the style node is constructed and finally a link to the style node is put into the page file. So, this is the easy part. What''s more difficult, is to generate a style/price range file for each style/price range. Generating files is normally done using source handlers. However, this is not needed here since the file that would be used the source handler, would be empty. Also, since the overview page lists alls styles and price ranges it would be the ideal page to generate the other ones since every page listed here would definitely be needed. This can be done by either creating a specific tag which, for example, lists all styles and creates the style page (or the price range equivalents) or by a small helper function. I would go for the tag! The tikz tag does something similar: it generates image nodes when called so you may have a look at source code for it in lib/webgen/tag/tikz.rb. -- Thomas
Thomas Danckaert
2009-Apr-05 14:38 UTC
[webgen-users] 2 questions: printable version / labels
> I assume that you have the following files under src/: > > ? ? /overview.page > ? ? /restaurants/rest1.page > ? ? /restaurants/rest2.page > > Then you can start with the following fragment for listing the styles > for the overview page: > > ? ? Listing all styles: > ? ? <% > ? ? context.content_node.tree[''/restaurants''].children.select {|c| c[''kind''] == ''page''}. > ? ? ? ? ? ? collect {|c| c[''style'']}.uniq.sort.each do |style| > ? ? ? style_node = ''/style_'' + style.tr('' '', ''_'') + ''.html'' > ? ? %> > ? ? <%= context.dest_node.link_to(style_node) %> > ? ? <% end %>First of all: thanks for the advice I''ve been trying to get this to work, but I''m running into some trouble. For testing, I created 2 .page files under /restaurants, one with the meta-information ''style: Thai'' and one with ''style: Dutch''. Then I created ''styleoverview.page'' with the above code, and manually added ''style_Dutch.page'' and ''style_Thai.page'' to the root directory. (Creating these pages programmatically with a tag will be the next step). I ran into the following error: "An error has occurred: Erb processing failed in </ styleoverview.en.html>: undefined method `routing_node'' for "/ style_Dutch.html":String" I browsed the API, and I think for the method call ''link_to (style_node)'' to work, the variable style_node should contain a node, instead of a string, as in the example code you gave? I tried solving this by changing the code into <% context.content_node.tree[''/restaurants''].children.select {|c| c [''kind''] == ''page''}. collect {|c| c[''style'']}.uniq.sort.each do |style| style_node = context.content_node.resolve(''/style_'' + style.tr ('' '', ''_'') + ''.html'') %> <%= context.dest_node.link_to(style_node) %> <% end %> (I manually created nodes with the appropriate page files) but this gives me the error "An error has occurred: Erb processing failed in </ styleoverview.en.html>: undefined method `[]'' for nil:NilClass" I''m a bit lost here...
Thomas Leitner
2009-Apr-13 08:03 UTC
[webgen-users] 2 questions: printable version / labels
> I ran into the following error: > "An error has occurred: Erb processing failed in </ > styleoverview.en.html>: undefined method `routing_node'' for "/ > style_Dutch.html":String"Sorry, my mistake, the Node#link_to method takes a node as you already found out.> I browsed the API, and I think for the method call ''link_to > (style_node)'' to work, the variable style_node should contain a node, > instead of a string, as in the example code you gave? I tried solving > this by changing the code into > > <% > context.content_node.tree[''/restaurants''].children.select {|c| c > [''kind''] == ''page''}. > collect {|c| c[''style'']}.uniq.sort.each do |style| > style_node = context.content_node.resolve(''/style_'' + style.tr > ('' '', ''_'') + ''.html'') > %> > <%= context.dest_node.link_to(style_node) %> > <% end %> > (I manually created nodes with the appropriate page files) > > but this gives me the error > "An error has occurred: Erb processing failed in </ > styleoverview.en.html>: undefined method `[]'' for nil:NilClass"Try this: Listing all styles: <% context.content_node.tree[''/restaurants''].children.select {|c| c[''kind''] == ''page''}. collect {|c| c[''style'']}.uniq.sort.each do |style| style_path = ''/style_'' + style.downcase.tr('' '', ''_'') + ''.html'' style_node = context.ref_node.resolve(style_path, context.content_node.lang) %> <%= context.dest_node.link_to(style_node) %> <% end %> The problem was that the call to Node#resolve tried to resolve the path without a language which naturally failed. After adding the needed language as second parameter it works. -- Thomas ps. Sorry for the late answer, been on vacation the last week.
Thomas Danckaert
2009-Apr-15 20:22 UTC
[webgen-users] 2 questions: printable version / labels
Yes, that works fine. I somehow missed that resolve() takes 2 arguments, though its written there quite clearly. On Apr 13, 10:03?am, Thomas Leitner <t_leit... at gmx.at> wrote:> > I ran into the following error: > > "An error has occurred: ? Erb processing failed in </ > > styleoverview.en.html>: undefined method `routing_node'' for "/ > > style_Dutch.html":String" > > Sorry, my mistake, the Node#link_to method takes a node as you already > found out. > > > > > I browsed the API, and I think for the method call ''link_to > > (style_node)'' to work, the variable style_node should contain a node, > > instead of a string, as in the example code you gave? I tried solving > > this by changing the code into > > > <% > > context.content_node.tree[''/restaurants''].children.select {|c| c > > [''kind''] == ''page''}. > > collect {|c| c[''style'']}.uniq.sort.each do |style| > > ? ? ? ?style_node = context.content_node.resolve(''/style_'' + style.tr > > ('' '', ''_'') + ''.html'') > > %> > > <%= context.dest_node.link_to(style_node) %> > > <% end %> > > (I manually created nodes with the appropriate page files) > > > but this gives me the error > > "An error has occurred: ? Erb processing failed in </ > > styleoverview.en.html>: undefined method `[]'' for nil:NilClass" > > Try this: > > ? ? Listing all styles: > ? ? <% > ? ? context.content_node.tree[''/restaurants''].children.select {|c| c[''kind''] == ''page''}. > ? ? ? ? ? ? collect {|c| c[''style'']}.uniq.sort.each do |style| > ? ? ? style_path = ''/style_'' + style.downcase.tr('' '', ''_'') + ''.html'' > ? ? ? style_node = context.ref_node.resolve(style_path, context.content_node.lang) > ? ? %> > ? ? <%= context.dest_node.link_to(style_node) %> > ? ? <% end %> > > The problem was that the call to Node#resolve tried to resolve the path > without a language which naturally failed. After adding the needed > language as second parameter it works. > > -- Thomas > > ps. Sorry for the late answer, been on vacation the last week. > _______________________________________________ > webgen-users mailing list > webgen-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/webgen-users