Thank you... it works great for my purposes! (I used first method you
described).
-Peter
On Wed, Sep 10, 2008 at 9:42 AM, Thomas Leitner <t_leitner at gmx.at>
wrote:
> Am Tue, 9 Sep 2008 22:01:02 +0200
> schrieb "Peter Stibrany" <pstibrany at gmail.com>:
>
> > Hello,
> >
> > I would like to integrate one subdomain with my main web page, so that
> > all links from subdomains page would point to my main website. For
> > example let''s suppose I have my main website at:
> >
> > http://www.example.com/
> >
> > This is fully generated by Webgen. I''d like to create one
extra page,
> > with menu from main website, which will be placed at
> >
> > http://sub.example.com/index.html
> >
> > For this to work, this extra page needs to have absolute links which
> > point to http://www.example.com/... but links on all other pages
> > (placed in http://www.example.com) should be still relative. Is it
> > possible to generate such page?
>
> This is currently not possible but would be easy to add since all
> internally generated links are generated by Node#link_to. Adding an
> option to generate an absolute link and then doing it there would be
> sufficient.
>
> You could try the following for the time being: Put the following code
> snippet into ext/init.rb:
>
> class Webgen::Node
>
> alias_method :old_route_to, :route_to
>
> def route_to(other)
> path = old_route_to(other)
> if self[''site_url'']
> path = File.join(self[''site_url''],
(self.class.url(@path) +
> path).path)
> end
> path
> end
>
> end
>
> Then you can add a meta information called `site_url` in each page file
> that should contain absolute links when rendered. Be aware that ALL
> generated routes are absolute, for example, also the output of the
> relocatable tag! This means, for example, that the CSS is used from the
> site_url and not the local URL (ie. if site_url is like your example,
> the css file from http://www.example.com/ will be used instead of the
> one from http://sub.example.com/).
>
> If you just want to make links absolute, you can put the following into
> your ext/init.rb file:
>
> class Webgen::Node
>
> def link_to(node, attr = {})
> attr = node[''link_attrs''].merge(attr) if
> node[''link_attrs''].kind_of?(Hash)
> rnode = node.routing_node(attr[:lang] || @lang)
> link_text = attr[:link_text] || (rnode != node &&
rnode[''routed_title''])
> || node[''title'']
> attr.delete_if {|k,v| k.kind_of?(Symbol)}
>
> use_link = (rnode != self ||
> website.config[''website.link_to_current_page''])
> if use_link && self[''site_url'']
> attr[''href''] =
File.join(self[''site_url''], (self.class.url(@path) +
> self.route_to(node)).path)
> elsif use_link
> attr[''href''] = self.route_to(rnode)
> end
> attrs = attr.collect {|name,value|
"#{name.to_s}=\"#{value}\""
> }.sort.unshift('''').join('' '')
> (use_link ? "<a#{attrs}>#{link_text}</a>" :
> "<span#{attrs}>#{link_text}</span>")
> end
>
> end
>
> This will make only generated links absolute (used, for example, by the
> menu and breadcrumb_trail tags).
>
> -- Thomas
> _______________________________________________
> webgen-users mailing list
> webgen-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/webgen-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/webgen-users/attachments/20080910/e68f1453/attachment.html>