Guest User

Untitled

a guest
Apr 25th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. module AbsoluteUrlHelper
  2. def abs_url( input, dir )
  3. return input unless SITE.base
  4. return SITE.base + input if input[0,1] == '/'
  5.  
  6. rgxp = %r/(src|href)="([^"]*)"/
  7.  
  8. input.gsub!(rgxp) do
  9. path = $2
  10. path = URI.join(SITE.base, "/#{dir}/" ,path)
  11. %Q(#{$1}="#{path}")
  12. end
  13.  
  14. return input
  15. end
  16. end
  17.  
  18. Webby::Helpers.register(AbsoluteUrlHelper)
Add Comment
Please, Sign In to add comment