servuscms / servus

Minimalist social media server
GNU General Public License v3.0
67 stars 0 forks source link

Can servus work with org-mode? #9

Open sch1z00 opened 5 months ago

sch1z00 commented 5 months ago

I'd like to use org-mode to publish my site via servus, as already suggested with jekill

https://orgmode.org/worg/org-tutorials/org-jekyll.html

Unfortunately I am not expert enough to be able to do it myself and even just an example of the structure of a simple site would be useful to me. I've already seen it described in the README, but I can't make it work: I generated a site with jekill, then I tried to adapt it in a "sites" directory... When I launch servus it loads the site, but browsing I can't find the address http://0.0.0.0:4884

tide::log::middleware <-- Request received
    method GET
    path /
tide::log::middleware Client error --> Response sent
    method GET
    path /
    status 404 - Not Found
ibz commented 5 months ago

Would you mind posting the command you are using to run Servus and the filesystem structure (the output of find sites) so I can try to replicate the issue?

To me it seems you are missing an "index", because that is what would be rendered if you access "/". Basically you would need a file named _content/pages/index.md.

This is what I have...

$ cat sites/ibz.me/_content/pages/index.md 
---
title: ''
---

Welcome to {{ site.title }}!
ibz commented 5 months ago

BTW, you will also need to populate _layouts. That is done automatically if you create a site using the admin interface or the REST API, but if you do it manually, you'll need to add some layouts there.

Here is what needs to be present in a site directory, at a very minimum: https://github.com/servuscms/servus/tree/master/themes/default - besides the _config.toml!

sch1z00 commented 5 months ago

tihs is my command

~/bin/servus $ ./target/debug/servus 
Found site: schizo
Loading layouts...
Loaded 4 templates!
Scanning file ./sites/schizo/_content/pages/posts.md...
Resource: url=/posts.
Scanning file ./sites/schizo/_content/pages/index.md...
Resource: url=/index.
Site loaded!
1 sites loaded!
tide::server Server listening on http://0.0.0.0:4884

and this is the output when I try to browse http://0.0.0.0:4884

tide::log::middleware <-- Request received
    method GET
    path /
tide::log::middleware Client error --> Response sent
    method GET
    path /
    status 404 - Not Found
ibz commented 5 months ago

TL/DR: This will solve your problem: mv sites/schizo sites/0.0.0.0:4884.

The reason is that the way to determine what site to serve (you can have multiple) is using the hostname - or, in this case, of running it locally, it is simply the ip:port - so you need to name your site the same as what you will be using to access it.

I agree that for this simple case of running it locally (and/or of having only one site) it is counter-intuitive. I'll come up with some better way for this case, But for now, the above solution should work.

sch1z00 commented 5 months ago

now it seems to work, but I've this error

tide::log::middleware <-- Request received
    method GET
    path /
thread 'async-std/runtime' panicked at src/site.rs:417:37:
called `Result::unwrap()` on an `Err` value: Error { kind: Msg("Failed to render 'page.html' (error happened in 'base.html')."), source: Some(Error { kind: Msg("Variable `site.tagline` not found in context while rendering 'page.html'"), source: None }) }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I guess it's a configuration problem, so I tried to create a site using the admin interface, but I didn't understand how to do it.

If, for example, I run

./target/debug/servus --admin-domain 0.0.0.0

and I browse http://0.0.0.0:4884/api/sites I got

tide::log::middleware <-- Request received
     method GET
     path /api/sites
tide::log::middleware Client error --> Response sent
     method GET
     path /api/sites
     status 400 - Bad Request
ibz commented 5 months ago

Edit your _config.toml and set tagline = "something" under the [site] section. That will pass site.tagline to the layout.

ibz commented 5 months ago

I think the admin interface will not work locally. I have never tried it in this way.

But what you are trying is a very good use-case indeed.

I'll have a look to make everything smoother for running it locally, because it totally makes sense - whether for use with org-mode or simply for having a tool for local note-keeping, that can eventually be synced with other non-local instances.

sch1z00 commented 5 months ago

It works! I thought there might be other configuration problems and therefore having to use the administration interface, but now it's already fine. Now I need to figure out how to use org-capture to populate the site's directories with the correct md files...

Thank you

ibz commented 5 months ago

I think you will encounter one more issue if you do that: you add .md files, but Servus doesn't know about them because it only checks for new files on start. The only way (currently) to add posts when it is running is to post via the Nostr protocol. But I am thinking to make it such that it somehow finds the new files while already running.

sch1z00 commented 5 months ago

Even if I restart servous it scans the new md files but does not publish them (both in pages and in posts)... in any case I await the new changes you will be able to make... Thanks for your work

ibz commented 5 months ago

If you are able to restart it from org-mode, then it should work. On start, it scans all files and they are automatically published! If that doesn't work, let me know...

sch1z00 commented 5 months ago

I do not know how to do; If I do I'll let you know

sch1z00 commented 4 months ago

Now I need to figure out how to use org-capture to populate the site's directories with the correct md files...

DONE exporting org file through pandoc.el (I export titles, dates, etc.)

Now I need to obtain an ssl cert; I've tried your suggestions, with "ssl-acme" option and using "acme.sh", without success

xeruf commented 2 months ago

org mode support would be amazing!