Giter Site home page Giter Site logo

sake92 / hepek Goto Github PK

View Code? Open in Web Editor NEW
104.0 5.0 10.0 1.41 MB

Typesafe HTML templates and static site generator in pure Scala

Home Page: https://sake92.github.io/hepek/

License: Apache License 2.0

Scala 99.83% JavaScript 0.03% CSS 0.15%
scala static-site-generator website html hepek playframework bootstrap katex template-library template-engine

hepek's People

Contributors

alexjbush avatar danielbe1 avatar gitter-badger avatar sake92 avatar scala-steward avatar ubaldop 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

hepek's Issues

Generator for resources/public static files

A very cool feature would be to have a macro that reads from src/main/public path and builds a tree of Resources.
E.g. if you have this tree:

site
    ├───images
    │       favicon.ico
    ├───scripts
    │       main.js
    └───styles
            main.css

it would generate this:

object resources {
  object site {
    object images {
      val favicon_ico = resource("favicon.ico")
    }
// ... etc
  }
}

Then you could say just resources.site.image.favicon_ico.ref to get the path to favicon.ico. 😃
Since .ref returns a relative path, this would be very helpful.

Support for ZStream (or any other stream library)

I created an abstraction on top of scala.xml to serve content using ZIO.ZStream, so I can stream results from server instead of loading all content in memory and then flush to the client.

It would be really good to have a feature like that on your library.

Separate themes package

For now, there is only one theme for blogs, one used for sake.ba, bootstrap3 theme.
We should probably separate this to a theme package so users can find them more easily.

Reveal JS helpers

Would be cool to have helpers for Reveal JS presentation tool.
It should be rather easy since it is a closed world. 😄

Its markdown support isn't needed, since Hepek has it already.
Configuration should have corresponding case class and have sensible defaults.

Improve markdown support

There is basic support for markdown, with md method here.

I wouldn't include these:

  • headers, since that already exists with blogging support and templates
  • tables, ugly as hell
  • links, already exists hyperlink method
  • code, already exists with PrismJS, more powerful, typesafe -> extendable...
  • blockquotes, unnecessary?

Maybe:

  • lists, nesting looks nice, more readable than ul-li etc
  • line breaks (hr tag)

Support for HTMX attributes

HTMX is a library to give the best UX using plain HTML following principles of hyper media
https://htmx.org/

I plan to use Hepek in combination with HTMX and Alpine, having direct DSL support will save lot of time, have better code and avoid errors at compilation

Write tests

Some unit tests wouldn't hurt, especially for components.
We should also consider Selenium or whatever HTML inspection tool is useful and simple.
For now we can try with String.contains or something like that. 😄

Remove implicits package object

The implicits package object originally had some implicits in it.
Now it only has aliases for commonly used classes and objects.

Its content could/should be moved to StaticBundle.
Also, then we could move HepekAliases also to Bundle definition... 🙂

That would leave user with just importing the Imports._ object, implicits not needed at all!

Integrate with Playframework

Hepek components shouldn't be limited to static pages only.
We should introduce an equivalent to StaticPage, DynamicPage.
With same abstractions, it should be possible to use all the goodies from hepek in a Play project.

Consider other layout frameworks and CSS layout/grid techniques

There is an implementation for Bootstrap 3 grid layout.
It is nice and typesafe enough for this:
https://github.com/sake92/sake-ba-source/blob/c960161f7d377433b3ad9ea3dda2390b825b5479/sake-ba/src/main/scala/site/Index.scala#L90-L97

This approach is ratio-based i.e. ~percentage like behavior.
W3-CSS also looks nice.

There are other approaches also, for example fixed-pixels : stretch...
If someone is willing to implement CSS grid layout that would be a-awesome!!! 😄

Support for AlpineJS

AlpineJS is a super lightweight JS framework tied to the DOM
https://alpinejs.dev/

I plan to use Hepek in combination with HTMX and Alpine, having direct DSL support will save lot of time, have better code and avoid errors at compilation

Unify dependency declaration

Different CDNs provide different package names, folder layout, i.e. format:

unpkg

Uses unpkg.com/:package@:version/:file
Works for all npm packages.

cdnjs

Uses cdnjs.cloudflare.com/ajax/libs/:package/:version/:file

That's all nice and dandy, but the packages and file paths aren't same, let's see bootstrap 4 for example:
https://unpkg.com/[email protected]/dist/js/bootstrap.js
https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.js

Wow, just... WOW! 😢
"bootstrap" vs "twitter-bootstrap"
"/dist/js/bootstrap.js" vs "js/bootstrap.js"

Also, some npm packages aren't contained in "/dist" folder, so it's not a rule...
Anyone has an idea how to generalize this stuff? I guess it's not possible at all for now... 😄

Regarding Webjars it should be fairly easy. If they are consistent.

Here is my first attempt to generalize this.

Multi-page StaticPage

An advanced feature that would be useful is to generate multiple files from one object.
A use-case is when you have multiple languages, multiple versions of "same" page.

IDK how that would look like, but I think we could pull it out with macros.
We need a class on which we should ~multiplex these pages/files.

Suppose we have a case class MyData(lang: String, version: String, content: Frag).
Then we could make an annotation macro @multipage and use it on an object that extends Renderable:

@multipage(MyMultipageParams)
object MyPage extends MyTemplate {

  // data would be defined by @multipage macro

  override def relPath = s"site/${data .lang}/bla/${data .version}/my-page.html"

  override def pageContent = data .content
}

object MyMultipageParams extends MultipageParams[MyData] {
  override def datas = List(
    MyData("en", "1", "sup?"),
    MyData("bs", "1", "ša mai?")
  )
}

This would render 2 pages:

  • site/en/bla/1/my-page.html
  • site/bs/bla/1/my-page.html

with corresponding contents.

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.