Coder Social home page Coder Social logo

rcarmo / sushy Goto Github PK

View Code? Open in Web Editor NEW
84.0 5.0 9.0 1.77 MB

A wiki/blogging engine with a static file back-end

License: MIT License

Makefile 0.73% JavaScript 7.95% Hy 18.54% Python 32.08% CSS 11.42% HTML 6.68% Jupyter Notebook 22.59% Procfile 0.02%

sushy's Introduction

Sushy

A wiki/blogging engine with a static file back-end, full-text indexing and multiple markup support.

This was formerly the site engine for taoofmac.com circa 2015 until I decided to switch back to pure Python for maintainability.

Status

Many years later, I've decided to at least clean up the legacy codebase and bring it up to date. Once done, it should again be deployable to piku/Dokku-alt/Dokku/Heroku.

The goal is to make it run on the 2023 version of Hylang.

Roadmap

  • Fix all the various breaking syntax changes that the Hy project has gone through in the past few years
  • A little more documentation (there's never enough)
  • Blog archive and partial feature parity with the current taoofmac.com site engine
  • End-to-end syntax and linting checks
  • Fix link and image handling, which require some tweaks
  • Working decorators and HTTP serving with the 2023 versions of Hy
  • Removed *earmuffs* in favor of standard Python constants, because Hy now handles those differently
  • (Mostly) working indexing with the 2023 versions of Hy
  • Page aliasing (i.e., multiple URLs for a page)
  • Image thumbnailing
  • Friendlier search results
  • More CSS tweaks
  • Atom feeds
  • piku deployment
  • Blog homepage/prev-next navigation
  • Preliminary support for rendering IPython notebooks
  • Closest-match URLs (i.e., fix typos) (removed for performance concerns on large sites)
  • HTTP caching (Etag, Last-Modified, HEAD support, etc.)
  • Sitemap
  • OpenSearch support (search directly from the omnibar on some browsers)
  • CSS inlining for Atom feeds
  • multiprocessing-based indexer (in feature/multiprocessing, disabled for ease of profiling)
  • SSE (Server-Sent Events) support (in feature/server-events) for notifying visitors a page has changed
  • New Relic Support
  • Internal link tracking (SeeAlso functionality, as seen on Yaki)
  • Multiple theme support (only the one theme for now)
  • Automatic insertion of image sizes in img tags
  • Deployable under Dokku-alt
  • Run under uWSGI using gevent workers
  • Full-text indexing and search
  • Syntax highlighting for inline code samples
  • Ink-based site layout and templates (replaced by a new layout in the feature/blog branch)
  • Baseline markup rendering (Textile, Markdown and ReST)

Stuff that will never happen:

  • Site thumbnailing (for taking screenshots of external links) - moved to a separate app
  • Web-based UI for editing pages (you're supposed to do this out-of-band)
  • Revision history (you're supposed to manage your content with Dropbox or git)
  • Comment support

Principles of Operation

  • All your Textile, Markdown or ReStructured Text content lives in a filesystem tree, with a folder per page
  • Sushy grabs and renders those on demand with fine-tuned HTTP headers (this is independently of whether or not you put Varnish or CloudFlare in front for caching)
  • It also maintains a SQLite database with a full-text index of all your content - updated live as you add/edit content.

Markup Support

Sushy supports plaintext, HTML and Textile for legacy reasons, and Markdown as its preferred format. ReStructured Text is also supported, but since I don't use it for anything (and find it rather a pain to read, let alone write), I can't make any guarantees as to its reliability. Work is ongoing for supporting Jupyter notebooks (which have no metadata/frontmatter conventions).

All markup formats MUST be preceded by "front matter" handled like RFC2822 headers (see the pages folder for examples and test cases). Sushy uses the file extension to determine a suitable renderer, but that can be overriden if you specify a Content-Type header (see config.hy for the mappings).

FAQ

Why?

I've been running a classical, object-oriented Python Wiki (called Yaki) for the better part of a decade. It works, but is comparatively big and has become unwieldy and cumbersome to tweak. So I decided to rewrite it. Again. And again.

And I eventually decided to make it smaller -- my intention is for the core to stop at around 1000 lines of code excluding templates, so this is also an exercise in building tight, readable (and functional) code.

Why Hy?

Because I've been doing a lot of Clojure lately for my other personal projects, and both the LISP syntax and functional programming style are quite natural to me.

I thought long and hard about doing this in Clojure instead (and in fact have been poking at an implementation for almost a year now), but the Java libraries for Markdown and Textile have a bunch of irritating little corner cases and I wanted to make sure all my content would render fine the first time, plus Python has an absolutely fantastic ecosystem that I am deeply into.

Then Hy came along, and I realized I could have my cake and eat it too.

Can this do static sites?

I've used a fair amount of static site generators, and they all come up short on a number of things (namely trivially easy updates that don't involve re-generating hundreds of tiny files and trashing the filesystem) -- which, incidentally, is one of the reasons why Sushy relies on a single SQLite file for temporary data.

But there's no reason why this can't be easily modified to pre-render and save the HTML content after indexing runs -- pull requests to do that are welcome.

Requirements

Thanks to Hy, this should run just as well under Python 2 and Python 3. My target environment is 2.7.8/PyPy, though, so your mileage may vary. Check the requirements.txt file - I've taken pains to make sure dependencies are there for a reason and not just because they're trendy.


Deployment

This repository should be deployable on piku (my featherweight version of Heroku), and also used to be deployable to Dokku -- this was removed in the 2023 refactoring since I don't use it anymore.

As is (for development) the content ships with the code repo. Changing things to work off a separate mount point (or a shared container volume) is trivial.

Configuration

In accordance with the 12 Factor approach, runtime configuration is taken from environment variables:

  • DEBUG - Enable debug logs
  • PROFILER - Enable cProfile statistics (will slow down things appreciatively)
  • CONTENT_PATH - the folder your documents live in
  • THEME_PATH - path under which static assets (JS/CSS/etc.) and templates/views are stored
  • BIND_ADDRESS - IP address to bind the development server to
  • PORT - TCP port to bind the server to

These are set in the Makefile (which I use for a variety of purposes).


Trying it out

Make sure you have libxml and libxslt headers, as well as the JPEG library - the following is for Ubuntu 14.04:

sudo apt-get install libxml2-dev libxslt1-dev libjpeg-dev
# install dependencies
make deps
# run the indexing daemon (updates upon file changes)
make index-watch &
# run the standalone server (or uwsgi)
make serve

sushy's People

Contributors

rcarmo avatar jneves avatar dependabot[bot] avatar

Stargazers

 avatar Jonathan Simpson avatar Bruno Amaral avatar ELI JOSEPH BRADLEY avatar  avatar Charisma Riley avatar Tao Hansen avatar Filippo Giunchedi avatar Mukunda Modell avatar Simon Willison avatar Jummit avatar Dmytro Piliugin avatar Tim Kersey avatar Cais avatar Ricardo Chavez avatar  avatar Justin Wong avatar Mihai avatar Marcus Rohrmoser avatar Ben Zwick avatar  avatar Patrick H. Mullins avatar Alessandro Balzano avatar Tobi Schäfer avatar Walter Rafelsberger avatar Sam Havron avatar Noah Wagner avatar Berkus Decker avatar Martin Contento avatar Jim Hobbs avatar Rob Fairley avatar Pavel avatar  avatar  avatar  avatar Fabrício Soares avatar  avatar Casey Strouse avatar  avatar Eduardo Ferreira avatar Adam Porter avatar Nikolay Kolev avatar Jose Humberto Oliveros Magaña avatar Jeyan Burns-Oorjitham avatar Markus Zapke-Gründemann avatar Christoph Polcin avatar Alexander Ko avatar  avatar Aidan Harris avatar Pascal Jürgens avatar Stefan Thon avatar Kevin Coughlin avatar Anqur avatar vindarel avatar  avatar  avatar Sarfaraz Nawaz avatar Ashish Shrestha avatar Robb Fitzsimmons avatar Miguel Laginha avatar KJ avatar Nazeeruddin Ikram avatar Stefaney Roberts avatar Michael Whalen avatar Nicholas Chaimov avatar Filipe Uva avatar Chris Watson avatar Nicolas Mäkelä avatar Will Fife avatar John Duprey avatar David Larlet avatar Rick Cogley avatar Bruno Lopes avatar Fred Oliveira avatar Miguel Nogueira avatar Rogério Vicente avatar Ryan Campbell avatar  avatar Jon Schoning avatar Keryn Knight avatar Carlos Lisboa avatar Randall Leeds avatar John H avatar Paul Tagliamonte avatar

Watchers

Paul Tagliamonte avatar  avatar James Cloos avatar Nuno Ferro avatar  avatar

sushy's Issues

Twitter cards and Opengraph

{% if site.owner.twitter %}
{% if page.image.feature %}

{% else %}
{% endif %}


{% endif %}

<!-- Open Graph -->
<meta property="og:locale" content="en_US">
<meta property="og:type" content="article">
<meta property="og:image" content="{% if page.image.thumb %}{{ site.url }}/images/posts/{{ page.image.thumb }}{% else %}{{ site.url }}/images/{{ site.logo }}{% endif %}">
<meta property="og:title" content="{% if page.title %}{{ page.title }}{% else %}{{ site.title }}{% endif %}">
<meta property="og:description" content="{% if page.description %}{{ page.description }}{% else %}{{ site.description }}{% endif %}">
<meta property="og:url" content="{{ site.url }}{{ page.url }}">
<meta property="og:site_name" content="{{ site.title }}">

Date parsing in templates

File "/app/themes/blog/views/wiki.tpl", line 55, in
post_date = utc_date(headers["date"], "")
File "/app/sushy/utils.hy", line 156, in utc_date
(defn utc-date [string fallback]
File "/app/sushy/utils.hy", line 417, in _hy_anon_fn_32
AttributeError: 'str' object has no attribute 'tzinfo'

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.