Giter VIP home page Giter VIP logo

try-pollen's Introduction

“Secretary of Foreign Relations”

(A test Pollen site: version 0.25)

I’ve created this site to experiment with making websites that are also printed books using Pollen, as well as to help explain Pollen to people who might be interested in using it for themselves. The official Pollen documentation is well done and improving all the time, and you should really start by reading it thoroughly. But a quasi-guided tour through a simple working site might help put the pieces together, and illustrate the benefits of the Pollen system.

You can see the site live at https://thelocalyarn.com/excursus/secretary. While browsing there, be sure to click on the “◊ Pollen Source” links at the top of the individual pages to see the Pollen markup that was used to generate that page.

Thanks to Matthew Butterick and Malcolm Still for their help with my Racket and Pollen questions.

Support

If you find this project helpful, consider chipping a few bucks towards the author!

Buy Me a Coffee at ko-fi.com

Setup

  1. Install Pollen (instructions)
  2. (Optional) To be able to generate PDFs as well as HTML, you should have a working installation of LaTeX (specifically xelatex) and the Tufte-Latex classes installed. If you're on a Mac, installing MacTeX will satisfy both of these. (Note, if your shell is something other than bash, you'll need to take steps to ensure /Library/TeX/texbin is on your PATH.) Also see the note in the LaTeX/PDF section (further down) on specifying fonts that you have installed on your system, otherwise PDF builds may fail.
  3. Clone or download this repo
  4. raco pollen start from the main folder, then point your browser to http://localhost:8080

If you have GNU Make installed (Mac or Linux) you can run make all from the main project folder. Run make spritz to clean up various working directories, or make zap to delete all the output files and start fresh. See the makefile for more info (it’s pretty well commented), and of course see the docs on raco pollen for more on generating the files in Pollen.

Points of interest

A brief and incomplete self-guided tour of the code follows. I add new things from time to time, so check back.

  • Look at pollen.rkt to see the definitions for the markup I use in this project, and the code that glues everything together.
  • feed.xml.pp is where the RSS feed is generated.
  • The two files flatland-book.pdf.pp and flatland-book.ltx.pp generate a complete PDF book of Flatland using the same .poly.pm source files in the flatland/ subfolder. This PDF file can be sent right to CreateSpace or any other print-on-demand service; as a demonstration, I’ve made the print book available for order at CreateSpace.
  • Look through the .pm files to see what writing in Pollen markup looks like. (Another way to do this is to click the “Pollen source” links on sub-pages at the live site.)

Custom markup

So far I’ve added two minor markup innovations to this project:

  1. A ◊verse tag for poetry: This is one example of an area that Markdown does not (and likely will never) address properly. By using this tag I can output the exact HTML markup I need, which I can then style with CSS to center based on the width of the longest line. In LaTeX/PDF, this tag also automatically replaces double-spaces with \vin to indent lines.

  2. An ◊index-entry tag: Intended to mark passages of text for inclusion in a book-style index. A separate page, bookindex.html, iterates through the pagetree, gathers up all of these entries and displays them in alphabetical order, grouped by heading. (Basically just like the index at the back of any serious book you have on your shelf.) This is another example of something that would be impossible in Markdown. Of course, on the web, this is something of an anachronism: it would probably be better for the reader to have a normal search form to use. However, besides serving as an illustration, this tag will allow for effortless inclusion of an index when I add support for this in LaTeX/PDF.

    You can see the code used to generate the index at the bottom of pollen.rkt and in the template-bookindex.html file.

LaTeX/PDF support

Any file with the .poly.pm extension can be generated as a pretty darn nice-looking PDF file as well as HTML. My LaTeX templates make use of the Tufte-LaTeX document classes, to match the Tufte-CSS in use on the web side.

In addition, the preprocessor files flatland/flatland-book.ltx.pp and flatland/flatland-book.pdf.pp generate a complete PDF of the entire Flatland book.

You may want to edit the fonts specified in the \setromanfont and \setmonofont commands in template.ltx.p, template.pdf.p and flatland/flatland-book.ltx.pp; I have them set to Adobe Caslon Pro and Triplicate, respectively, so if you don't have those fonts installed you will get errors.

The official Pollen docs describe the basic method for LaTeX and PDF targets, but my method differs somewhat due to the need for additional cleverness.

In my LaTeX template, any hyperlinks also get auto-converted to numbered side-notes. Unfortunately, this niftiness also means that when targeting LaTeX, you can't have a hyperlink inside a side-note since that would equate to a side-note within a side-note, which causes Problems. I could simply stipulate "don't put hyperlinks in margin notes" but I wanted a more elegant solution. Solving this problem meant departing from the methods in the official tutorial. The details are in this post at the Pollen mailing list.

RSS feed

The site now generates an RSS feed in Atom 1.0 format (tested at the Feed Validator, of course). The feed.xml.pp file is heavily commented and explains how this works.

Grouping pages by series

I implemented a simple system for grouping pages according to a “series” — think of a series of articles in a journal or magazine (or maybe what you’d call categories in a blog).

As specified in index.ptree all posts sit together in one big pool in the posts subfolder. Each post can optionally specify a series:

◊(define-meta series "series/poems.html")

I opted to specify the series by the Pollen target filename, but it could just as easily be the human-friendly name of the series (doing it this way allows me to change that name without affecting the posts that refer to it).

Then for every series, I create a Pollen file in the series subfolder which serves as a brief introduction to the series, and manually add that to index.ptree.

The file template-index.html (the template specified in index.html.pm) includes code that iterates over all the pages in the series subfolder, prints out its contents, then lists all the posts that specify that series in their metadata (using the list-posts-in-series function defined in pollen.rkt).

Converting Markdown to Pollen

I’ve created a basic custom writer for pandoc that allows you to convert Markdown files (or anything, really) into Pollen markup. I’d see three appropriate uses for this. One is for banging out first drafts that consist of long stretches of simple prose. In those cases there's not a lot of structure or metadata to be concerned with at the very outset, and you can take advantage of editors and tools that recognize Markdown syntax. Second, it allows you to more easily accept drafts in other formats from other people who aren't familiar with Pollen concepts. Third (the big one for me) it can help a lot with automating the process of mass-importing old material into a Pollen publication.

The code is in util/pandoc-pollen.lua, and the template file is in util/pandoc-pollen-template.pm. You can use it like so from within the project root folder:

pandoc -t util/pandoc-pollen.lua -o YOUR-OUTPUT.poly.pm --template=util/pandoc-pollen-template.pm SOURCEFILE.md

Or to convert a bunch of Markdown files at once, run this Bash script:

#!/bin/bash

for f in *.md; do \
 pandoc --template=util/pandoc-pollen-template.pm -t pandoc-pollen.lua "$f" > "$f.poly.pm"
done

You should open up util/pandoc-pollen.lua and util/pandoc-pollen-template.pm and customize the code to match the Pollen markup for your project. You’ll likely still need to clean up the resulting files once they’ve been sent through the wringer, but this will do a lot of the tedious work for you.

Other good examples

Besides getting answers to my inane newbie questions in the discussion group (which I try my best to keep to a minimum), I’m greatly assisted by being able to peruse the code of a couple of other Pollen creations.

Matthew Butterick's article Making a dual typed/untyped Racket library was created with Pollen and is a good learning resource. I initially missed the links at the bottom to the Pollen source code for the article, which is very well commented.

Malcolm Still also has the code for his blog in a public repository.

Matthew Butterick also keeps a list of other Pollen projects and guides in the official Pollen documentation.

try-pollen's People

Contributors

bandali0 avatar ilnarselimcan avatar jiffygist avatar nathanal avatar otherjoel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

try-pollen's Issues

make flatland/flatland-book.ltx requires flatland/children.pm

Hello!

I really love this project, and am currently exploring it in my quest to build a pollen pipeline for my own written works. =)

I am trying to get a working make all going, and keep running into this failure when the project tries to build the full flatland-book.ltx.

Screenshot from 2019-07-15 18-43-14

(I have the xetex LaTeX engine installed and have successfully built the individual pages leading up to here, albeit I have changed the fonts to Ubuntu and Ubuntu Mono.)

Does this error look familiar? Do you know what the children.pm that it is looking for is? I have not been able to find any reference to it in the repo.

libuuid not available on Windows

It appears that libuuid is not available on Windows, as the install raco pkg install libuuid fails, because ffi-lib: couldn't open "libuuid-1.dll" (the module does not exist).

Is there a way to fix this?

License?

I'm remaking my blog in pollen, and went looking for a RSS impl. Found yours. I dont see a licsense anywhere in this. Do you mind if I copy/modify the RSS feed code you have?

This goes for other code, if you don't mind. Of course I won't touch any prose/design.

Or not -- Just let me know. TY!

Too many decoders

For certain Pollen tags which need to return a list of X-expressions instead of a single one, I use the “decoder function” approach (described by MB). This is sort of ungainly, since my tags are now being handled by two different types of functions at two different stages of processing. Better to use the splice-me approach as seen in this example pollen.rkt file.

Implement LaTeX & PDF targets

Want to be able to demonstrate Pollen's multiple output target capability by creating a print-ready PDF version of the site via LaTeX.

  1. Add code to tag functions to distinguish between output target types
  2. Create LaTeX templates
  3. Change all .html.pm to .poly.pm

Error compiling feed.xml.pp after a Pollen/Racket upgrade

Hi,

I updated my system (Arch Linux, using pacman -Syu). As a part of the process, Racket was upgraded to version 7.7 and I had to re-install Pollen. After that, compiling this repository (make all) seems to work fine until it produces this error message upon compiling feed.xml.pp and then halts:

[truncated]

raco pollen render feed.xml.pp
pollen: rendering feed.xml.pp
pollen: rendering /feed.xml.pp
path->complete-path: second argument is not a complete path
  first argument: #<path:pollen.rkt>
  second argument: #<path:posts/>
  context...:
   /home/me/.racket/7.7/pkgs/pollen/pollen/setup.rkt:21:0: get-path-to-override
   /home/me/.racket/7.7/pkgs/pollen/pollen/setup.rkt:48:11: poly-targets
   /home/me/.racket/7.7/pkgs/pollen/pollen/private/file-utils.rkt:176:11: ->markup-source-path
   /home/me/documents/www/sandbox/digitalwords.net/try-pollen/feed.xml.pp:135:0: syndicate?
   /usr/share/racket/collects/racket/private/list.rkt:256:2: filter
   "/home/me/documents/www/sandbox/digitalwords.net/try-pollen/feed.xml.pp": [running body]
   temp35_0
   for-loop
   run-module-instance!
   do-dynamic-require
   /home/me/.racket/7.7/pkgs/pollen/pollen/private/cache-utils.rkt:67:0: path->hash
   /home/me/.racket/7.7/pkgs/pollen/pollen/private/cache-utils.rkt:124:2: generate-dest-file
   /usr/share/racket/collects/file/cache.rkt:63:2: fetch-and-continue
   /usr/share/racket/collects/racket/contract/private/arrow-val-first.rkt:555:3
   /home/me/.racket/7.7/pkgs/pollen/pollen/private/cache-utils.rkt:114:0: cache-ref!
   /usr/share/racket/collects/racket/private/more-scheme.rkt:376:2: hash-ref!
   ...
make: *** [makefile:84: feed.xml] Error 1

I’m not sure how to fix this and where the problem actually lies.

I came accross the problem trying to compile my own Pollen website, as I based my feed.xml.pp on yours (thanks! 💐).

Júda

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.