jekylldown 0.3.4: add_feed() and use_r_bloggers() - #1
Merged
Merged
Conversation
Render the site's Atom feeds from a site-level copy of jekyll-feed's template, patched so al-folio's `title: blank` convention yields the author's full name as the feed title (the plugin alone prints the literal word "blank"), plus optional per-category full-text feeds -- the kind of feed R-Bloggers requires. - R/feed.R: add_feed(category, dir, force) and use_r_bloggers(category, dir). The template is taken from the jekyll-feed gem installed for the site (Gemfile.lock version; isolated GEM_HOME first, then `bundle show`), then that version's tag on GitHub, then the copy shipped in inst/jekyll-feed/. The patch replaces one anchor line and aborts with a clear message if upstream moves it; the include records its provenance so a gem upgrade regenerates it, and hand-written files are never touched. - new_site(theme = "al-folio") (and migrate_hugo() through it) call add_feed() so fresh sites never publish a feed titled "blank". - tests/testthat/test-feed.R: patch, sources, idempotence, upgrades, user files, lockfile parsing, a drift detector against the installed gem, and use_r_bloggers on al-folio and other themes. - NEWS, README, getting-started vignette.
RoxygenNote gives way to Config/roxygen2/version, the package Rd gains the Authors block, and two cross-package links now point at the topic alias (knitr::render_jekyll, servr::httw).
On Windows runners the session tempdir comes back in 8.3 short form (RUNNER~1) while site_root() returns the long form, so the equality on the include path failed there. Normalise both sides, as the page paths already are.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two new exported functions,
add_feed()anduse_r_bloggers(), plus a hook innew_site(). Version bumped to 0.3.4.The bug. al-folio uses
title: blankin_config.ymlto mean "build the site title fromfirst_name/middle_name/last_name". The theme's layouts understand that; the jekyll-feed plugin does not, so every stock al-folio site publishes an Atom feed titled, literally,blank(andblank | Rfor category feeds). Changingtitleis not an option: al-folio also usestitle != 'blank'to addjournal = {<title>}to the BibTeX it generates for posts.The feature. R users on jekylldown will want R-Bloggers, which requires a full-text feed with R posts only. jekyll-feed can generate per-category feeds, but they inherit the same title bug.
How it works
add_feed()writes_includes/atom-feed.xml, a copy of jekyll-feed's own template with one change (the title assignment becomes asite.title == 'blank'check that falls back to the plugin's original line), plus one-line feed pages that render it:feed.xmland, per category,feed/<category>.xml. jekyll-feed skips generating any feed whose file already exists, so the pages replace the plugin's output without disabling it ({% feed_meta %}still works). The template needs only core Liquid filters, so the pages also work on sites without the plugin.Where the template comes from, in order, so it follows jekyll-feed's development instead of freezing a copy inside the package:
Gemfile.lock, which is what the local build and the deploy workflow render with. Looked up under jekylldown's isolatedGEM_HOMEfirst (locked version, else the newest), then viabundle show jekyll-feedfor gems installed elsewhere.raw.githubusercontent.com/jekyll/jekyll-feed/v<version>/...) when the gem is not installed yet — never the default branch, which may be ahead of what the site runs. Network failures fall through silently.inst/jekyll-feed/feed-0.17.0.xml, with a message saying to re-run afterbundle_install().Safety rails:
{% assign title = site.title | default: site.name %}). If the template does not contain exactly that line,add_feed()aborts with a message pointing at the issue tracker instead of writing a broken feed.jekylldown: rendered from jekyll-feed 0.17.0 (gem)), placed after the XML declaration (anything before<?xml ?>makes the document ill-formed — that bit me while doing this by hand). Re-runningadd_feed()after a gem upgrade regenerates it;force = TRUEregenerates unconditionally.atom-feed.xml,feed.xmlorfeed/<cat>.xmlwithout the marker / not rendering the include is the user's own and is never touched.use_r_bloggers(category = "R")does the site side of an R-Bloggers submission in one call:add_feed("R"), the link back to R-Bloggers that they require (a marker-delimited block under the header bar of_pages/blog.mdon al-folio, replaced on re-runs; the snippet is printed on other themes), and the public feed URL to submit, built fromurl+baseurl.new_site(theme = "al-folio")— andmigrate_hugo()through it — now callsadd_feed()(silently, like the footer credit) so fresh sites never ship a feed titled "blank".Tests
tests/testthat/test-feed.R(no Ruby, no network — a fake gem is planted under a redirectedR_USER_DATA_DIR):add_feed()writes the include from the installed gem and both pages with the expected front matter;force;jekyll-feed (~> 0.9)dependency lines;use_r_bloggers()on al-folio (feed, link placement after the header-barendif, URL, idempotence), on other themes (snippet, no link), and argument validation.Full suite green;
R CMD check --no-manual: 0 errors, 0 warnings, 2 pre-existing environment NOTEs (archivenot installed for checking; "unable to verify current time").Verified on a real site
Ran
use_r_bloggers()on a copy of allanvc.github.io (al-folio,title: blank, jekyll-feed 0.17.0 installed → sourcegem), thenbuild_site():feed.xmltitle:Allan Quadros;feed/R.xmltitle:Allan Quadros | R(wasblank/blank | R);feed/R.xmlhas the 7 posts withcategories: R, full<content>, nothing else;The same fix was applied by hand to that site in allanvc/allanvc.github.io@5c0a0d7; this PR is the generalisation.
Notes for review
RoxygenNoteasConfig/roxygen2/versionand touches three unrelated.Rdfiles; that regeneration is its own commit so the feature diff stays readable."R"≠"r"), same as jekyll-feed's ownwhere: "categories"filter; the path keeps the case too (/feed/R.xml), consistent with what the plugin would generate./blog/category/<slug>/archive URL; other themes only get the plain snippet, on purpose — I did not want to guess where each theme lists posts.