Skip to content

Commit

Permalink
Merge pull request #367 from jywarren/relative-email-links
Browse files Browse the repository at this point in the history
email relative link fixes, deep link header scrolling, fixes #156
  • Loading branch information
jywarren committed Feb 22, 2016
2 parents f017f09 + 1e63cee commit 2356db6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 5 additions & 5 deletions app/assets/javascripts/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ $('.dropdown-toggle').click(function(e) {
});

/* window scroll trick for header */
function adjust_anchor_for_banner() {
var banner_offset = 50; // how much to scroll to account for the banner
function adjust_anchor_for_banner(offset) {
offset = offset || 50; // how much to scroll to account for the banner
var scroll_pos = $(document).scrollTop()
if (scroll_pos > banner_offset) {
$(document).scrollTop( scroll_pos - banner_offset );
if (scroll_pos > offset) {
$(document).scrollTop( scroll_pos - offset );
}
}
$(document).ready(adjust_anchor_for_banner)
$(window).load(function() { adjust_anchor_for_banner(); })
$(window).on('hashchange', adjust_anchor_for_banner)

/* google analytics */
Expand Down
6 changes: 5 additions & 1 deletion app/models/drupal_node_revision.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,12 @@ def render_body
end

# filtered version additionally appending http/https protocol to protocol-relative URLs like "//publiclab.org/foo"
# render_body plus making all relative links absolute
def render_body_email
self.render_body.gsub(/([\s|"|'|\[|\(])(\/\/)([\w]?\.?publiclab.org)/, '\1https://\3')
body = self.render_body.gsub("href='/","href='https://publiclab.org/")
body = body.gsub('href="/','href="https://publiclab.org/')
body = body.gsub(/([\s|"|'|\[|\(])(\/\/)([\w]?\.?publiclab.org)/, '\1https://\3')
body
end

end

0 comments on commit 2356db6

Please sign in to comment.