sake92 / hepek Goto Github PK
View Code? Open in Web Editor NEWTypesafe HTML templates and static site generator in pure Scala
Home Page: https://sake92.github.io/hepek/
License: Apache License 2.0
Typesafe HTML templates and static site generator in pure Scala
Home Page: https://sake92.github.io/hepek/
License: Apache License 2.0
A very cool feature would be to have a macro that reads from src/main/public
path and builds a tree of Resource
s.
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.
We could get a performance benefit from not-loading all those prismjs mini scripts.
Prismjs supports server-side rendering, see "Usage with Node" section: https://prismjs.com/
We could feed the code through Nashorn or something: https://winterbe.com/posts/2014/04/05/java8-nashorn-tutorial/
Katex also supports it: https://katex.org/docs/api.html#server-side-rendering-or-rendering-to-a-string
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.
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.
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.
There is basic support for markdown, with md
method here.
I wouldn't include these:
hyperlink
methodMaybe:
hr
tag)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
Play now supports scala 3 so I should revert removing it..
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. 😄
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!
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.
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!!! 😄
Flyingsaucer looks promising.
Haven't tried it yet.
This should be an easy bug to fix, here is the code.
As suggested on Gitter channel Bulma components should:
h1.title
, subtitle p.subtitle
, quarter column;List
component;While playing with https://github.com/sake92/ReScala-todomvc I realized it would indeed be useful to compile "hepek-components" to ScalaJS also... :)
As opposed to Bootstrap, in PureCSS, children of pure-g
(Bootstrap's row
) must be columns pure-u-*
, see https://purecss.io/grids/
We should remove the row
method that accepts arbitrary HTML.
I guess it can be added per-framework as desired...
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
Different CDNs provide different package names, folder layout, i.e. format:
Uses unpkg.com/:package@:version/:file
Works for all npm packages.
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.
It's faster and more reliable, AFAIK.
Should be trivial to integrate:
http://plantuml.com/api
Seems like it can generate SVG and PNG. 😃 NEAT!
Soooo, we could use it to inline an SVG, or render it and call it by path, WOW! 😲
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:
with corresponding contents.
In hepek, of course. 😛
This one is easy. Default to None, of course. https://github.com/sake92/hepek/blob/master/src/main/scala/ba/sake/hepek/html/structure/StaticPage.scala#L64
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.