Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stringify config["url"] and config["baseurl"] #106

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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