Skip to content

Commit

Permalink
Merge pull request #106 from ashmaroli/stringify-url-baseurl-config
Browse files Browse the repository at this point in the history
Stringify config["url"] and config["baseurl"]
  • Loading branch information
aarongustafson authored Sep 14, 2018
2 parents 6071ddb + b35b77c commit 43fe387
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions lib/jekyll/generators/gather_webmentions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ class GatherWebmentions < Generator

def generate(site)
@site = site
@site_url = site.config["url"].to_s

if @site.config["url"].to_s.include? "localhost"
WebmentionIO.log "msg", "Webmentions won’t be gathered on localhost."
if @site_url.include? "localhost"
Jekyll::WebmentionIO.log "msg", "Webmentions won’t be gathered on localhost."
return
end

Expand Down Expand Up @@ -90,8 +91,7 @@ def check_for_webmentions(post)

def get_webmention_target_urls(post)
targets = []
base_uri = @site.config["url"].chomp("/")
uri = "#{base_uri}#{post.url}"
uri = File.join(@site_url, post.url)
targets.push(uri)

# Redirection?
Expand Down Expand Up @@ -122,7 +122,7 @@ def gather_legacy_targets(uri, targets)
if WebmentionIO.config.key? "legacy_domains"
WebmentionIO.log "info", "adding legacy URIs"
WebmentionIO.config["legacy_domains"].each do |domain|
legacy = uri.sub @site.config["url"], domain
legacy = uri.sub(@site_url, domain)
WebmentionIO.log "info", "adding URI #{legacy}"
targets.push(legacy)
end
Expand Down
7 changes: 3 additions & 4 deletions lib/jekyll/generators/queue_webmentions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ class QueueWebmentions < Generator

def generate(site)
@site = site
@site_url = site.config["url"].to_s

if @site.config["url"].to_s.include? "localhost"
if @site_url.include? "localhost"
WebmentionIO.log "msg", "Webmentions lookups are not run on localhost."
return
end
Expand All @@ -39,10 +40,8 @@ def generate(site)
def gather_webmentions(posts)
webmentions = WebmentionIO.read_cached_webmentions "outgoing"

base_uri = @site.config["url"].to_s.chomp("/")

posts.each do |post|
uri = "#{base_uri}#{post.url}"
uri = File.join(@site_url, post.url)
mentions = get_mentioned_uris(post)
if webmentions.key? uri
mentions.each do |mentioned_uri, response|
Expand Down
5 changes: 3 additions & 2 deletions lib/jekyll/tags/webmentions_head.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ def render(context)

page = context["page"]
site = context.registers[:site]
site_url = site.config["url"].to_s
if page["redirect_from"]
if page["redirect_from"].is_a? String
redirect = site.config["url"] + page["redirect_from"]
redirect = site_url + page["redirect_from"]
elsif page["redirect_from"].is_a? Array
redirect = site.config["url"] + page["redirect_from"].join(",#{site.config["url"]}")
redirect = site_url + page["redirect_from"].join(",#{site_url}")
end
head << "<meta property=\"webmention:redirected_from\" content=\"#{redirect}\">"
end
Expand Down
2 changes: 1 addition & 1 deletion lib/jekyll/webmention_io/js_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def initialize(site)
@deploy, @uglify, @source, @destination = js_config.values_at("deploy", "uglify", "source", "destination")
@resource_name = "JekyllWebmentionIO.js"
@resource_url = File.join(
"", site.config["baseurl"], @destination, @resource_name
"", site.config["baseurl"].to_s, @destination, @resource_name
)
end

Expand Down

0 comments on commit 43fe387

Please sign in to comment.