Coder Social home page Coder Social logo

srid / rib Goto Github PK

View Code? Open in Web Editor NEW
118.0 7.0 12.0 13.29 MB

Haskell static site generator based on Shake (superseded by https://github.com/srid/ema)

Home Page: https://rib.srid.ca

License: BSD 3-Clause "New" or "Revised" License

Nix 5.78% Haskell 92.99% Dhall 0.93% Shell 0.30%
haskell static-site-generator shake lucid clay

rib's Introduction

rib

BSD3 Hackage built with nix Zulip chat

Rib is a Haskell static site generator based on Shake, with a delightful workflow.

See https://rib.srid.ca for full documentation.

UPDATE (Apr, 2021): Rib is superceded by Ema

Developing rib

Use ghcid for quicker compilation cycles:

nix-shell --run "cd rib-core && ghcid"

To test your changes, clone rib-sample and run it using your local rib checkout:

cd ..
git clone https://github.com/srid/rib-sample.git
cd rib-sample
nix-shell --arg rib ../rib --run 'ghcid -T ":main -wS"'

rib's People

Contributors

djanatyn avatar mx-psi avatar nimor111 avatar prikhi avatar shalokshalom avatar srid avatar wagdav 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

rib's Issues

When using buildHtml, sourceUrl is incorrect

To fix it, make readSource set a custom source URL.

More generally, perhaps sourceUrl should not be computed automatically especially as the target HTML path can be changed by the user.

Finish documentation guide/tutorials

Currently WIP at rib.srid.ca

Concepts

  • Rib.Shake combinators (explain using Rib.Simple)
  • Rib.Pandoc functions
  • Metadata files (non-md formats)

Tips & tricks

  • isDraft

Blogging support

@wagdav wrote here:

One thing I want to solve is the structure of the generated URLs: I'd like the final HTMLs to be accessible as example.com/yyyy/mm/dd/my-great-post. This is to keep the old URLs working after the migration. I have some ideas, but it's not working yet.

Currently rib does not have any blogging-specific functionality. If rib is to gain such explicit capabilities (be it as a built-in feature or as an extension), what is the list of things it should support? Here's a tentative list, for initial brainstorming:

  • Date in post permalinks (see above)
  • RSS feed generation
  • Archive of posts by year / month (and even maybe tag / category)
  • ... what else ?

Add a generator for Keybase Pages

This would be same as Rib.Simple except, the URLs would end in .html - unless the generation happens in a directory-per-page level (eg: ./foo/index.html for every foo.md).

Explain that nix is not required

From @rkaippully

  • Is nix required? The doc is worded to suggest that way, but I suspect it’s not mandatory. There are a lot of haskellers that do not use nix, so this might be a barrier to entry.

Dhall support

Allow content and its metadata to be specified in Dhall configuration language.

Add a new source parser that does this, while making sure that a predefined subset of the Dhall field is parsed using existing LML parser (eg: mmark).

Add getting-started guide to Haddock

From @ChrisPenner

I don't see any links to the hackage docs, nor could I find it on hackage; if I can't see hackage docs then using a package is basically a no-go for me 😬; my advice would be to focus your documentation around existing flows; put your getting started tutorial directly in the readme so it's copied to your hackage packages front page. Best to use the "de-facto" patterns for docs for at least the "first glance" stuff or the barrier to entry gets too high IMHO

And then [ ] upload to hackage.

Process locking

Rib should lock the directory when watching for changes, so that a second instance is prohibited at the beginning.

This should behave similar to Shake's locking, which reports as follows (when two instances of rib process is running at the same time, and a source file gets changed):

[Rib] Watching a/ for changes
# a/tidbits.dhall
[Rib] Shake error: Shake failed to acquire a file lock on .shake/.shake.lock
Shake process ID 30041 is using this lock.
setLock: resource exhausted (Resource temporarily unavailable)
CallStack (from HasCallStack):
  errorIO, called at src/General/FileLock.hs:67:9 in shake-0.18.4-5VRu9yKqXOY
JrfQmbOPO6w:General.FileLock

Nicer error reporting

Errors from parsing of markup and its metadata are thrown as exceptions (using fail), and Shake presents them with the traceback as follows:

image

We should present a nicer error message instead, possibly in a single line.

Add reflex-dom support

Provide reflex-dom as an alternative renderer to Lucid.

Pandoc and MMark renderer should support reflex-dom (including syntax highlighting). They can do it via lucid, by converting the resulting HTML into reflex-dom nodes.

URL redirects

If I move /notes/foo.html to /blog/2020/foo.html, I'd like the former location to redirect to the newer one.

Since this is a static site with no dynamic server, we would implement this using the http-equiv="Refresh" property of the meta tag in HTML. And as long as delay is zero, search engines will update their index.

This may not even need code change, and could simply be documented with example under FAQ.

Allow users to use their own markup type

[@joelmccracken has expressed interest in working on this]

Currently to add a custom markup, the user will have to do two things:

  1. Write an IsMarkup type class instance for their markup doc type
  2. Modify rib's Markup doc type to add a constructor corresponding to their markup

Step 2 in particular involves forking and modifying rib. We should aim to avoid that.

One way is perhaps to make buildHtmlMulti work on the IsMarkup constraint, and have the user explicit specify the markup type using TypeApplication.

Table of contents

Add a function that returns a tree of section headers that user's Main.hs can use to render a personalized table of contents.

Change `a` and `b` nomenclature

Use src and dest as default.

  • Allow the corresponding vars in Rib.App overridable by the user.
  • Ensure that this does not complicate the functions in Rib.Shake.

Suggested by @joelmccracken

I personally am not a fan of it, but some users seem to feel strongly about needing to use specific names for directories. I will accept changes that does not complicate the current implementation.

Complete org-mode support

Pandoc's org-mode parser is very limited. Alternatively we can extract the structure of the document as JSON using elisp: https://github.com/ludios/org-to-json and then convert the JSON to HTML.

Requires emacs with org-mode installed.

Primary tasks:

  • create the Haskell types and JSON decoders for the rather verbose JSON that org-to-json spits out.
  • render org structure to Lucid HTML

Add MMark.parseWith

Like parse but takes a custom list of mmark extensions to use.

Also add parsePureWith.

Rib site theme

Use an unique theme for rib.srid.ca. Don't overuse semantic-ui segments.

AsciiDoc support

AsciiDoc seems like a fantastic markup language that is more feature-rich than Markdown whilst remaining simpler than XML.

No complete Haskell parser seems to exist for it, so we may have to shell out to asciidoctor.

Shake spends predominant time reading its database

With shakeTimings = True:

Function shake                    0.000s    0%
Database read                     0.894s   73%  =========================
With database                     0.072s    5%  ==
Running rules                     0.246s   20%  ======
Pool finished (1 threads, 1 max)  0.000s    0%
Cleanup                           0.000s    0%
Total                             1.212s  100%

Size of the database for this report:

$ du -sh .shake/
28M     .shake/
$

Shake error: AsyncCancelled

When the Haskell file is changed, this can occur just before ghcid has the chance to reload:

Error when reading Shake database .shake/.shake.database
  AsyncCancelled
All files will be rebuilt

Add dynamism through GHCJS

An otherwise "static" site might gain from being parts of the site being a bit dynamic.

For example, using highlight.js to highlight syntax on the fly. Or do some custom JS eval on the page.

Rib already allows the use of Haskell DSL to define the HTML and CSS of the site. It could do the same for JavaScript as well, through GHCJS.

And it might be worth considering replacing Lucid with (or adding support for) Reflex-DOM, and use the reflex library to implement this feature.

Is it possible to have directories?

I was hoping that the directory structure of the source area would be replicated in the target, that is, a/some/path/index.md would end up at b/some/path/index.html. Is there a way to get this to work that I'm missing?

Thanks! Great static site generator, by the way.

Support all Pandoc (text) readers

We currently only support a small subset of Pandoc reader formats. This is specified in the Rib.Markup.Pandoc.detectReader function.

We should ideally make use of the Text.Pandoc.Readers.readers list, but filtering only for readers of type TextReader. We would also need a map between readers and their file extensions.

Prevent ribInputDir = `.`

And remove this from the Haddock of run:

NOTE: This should ideally not be "." as our use of watchTree (of runWith) can interfere with Shake's file scaning.

Shake "resource busy"

Seeing a lot of these if the source files updated very frequently.

[Rib] Shake error: .shake/.shake.database: openFile: resource busy (file is locked)

Rib does not create intermediate directories when generating post HTML

Viz.:

[Rib] Serving at http://localhost:8080                               
# a/static/README.md                                                 
# a/2019/12/26.md                                                    
*** Exception: Error when running Shake build system:                
  at action, called at src/Development/Shake/Forward.hs:111:5 in shak
e-0.18.3-94gZtzt3YtDAYX9Ox6TYrO:Development.Shake.Forward            
* Raised the exception:                                              
b/2019/12/26.html: openFile: does not exist (No such file or directory)    

Add Slug type

To be spec'ed out.

For references, see

  • Need for customizing target file pattern in buildHtmlMulti #77 (comment)
  • index.html stripping: #81

Gracefully handle errors

To reproduce, add draft: True (without double quotes around the True) to metadata of a document. Expect to see either nothing or this:

image

Subsequent save of file (after fixing it) has no effect.

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.