Closed notakoder closed 3 weeks ago
You did everything right. My bad. Thanks for pointing out this error.
I deleted the symbolic link. Latest version for saaze-example is v1.3.
It should work now.
Thanks for letting me know.
Regards,
Elmar Klausmeier.
Noted. I am continuing with the installation. I am using FFI so I am ignoring step 6. In step 7, this is my line. I'm including the ending array delimter );
too.
'global_ffi' => \FFI::cdef("char *md4c_toHtml(const char*);","/var/www/saaze-example/vendor/eklausme/saaze/php_md4c_toHtml.so"),
);
Assuming that the syntax is right, this it the output for php saaze
.
$ php saaze
PHP Warning: Module "FFI" is already loaded in Unknown on line 0
Building static site in /var/www/saaze-example/build...
PHP Fatal error: Uncaught Error: Call to undefined function Saaze\md4c_toHtml() in /var/www/saaze-example/vendor/eklausme/saaze/MarkdownContentParser.php:649
Stack trace:
#0 /var/www/saaze-example/vendor/eklausme/saaze/Entry.php(89): Saaze\MarkdownContentParser->toHtml()
#1 /var/www/saaze-example/vendor/eklausme/saaze/Collection.php(93): Saaze\Entry->getContentAndExcerpt()
#2 /var/www/saaze-example/vendor/eklausme/saaze/Collection.php(80): Saaze\Collection->loadEntry()
#3 /var/www/saaze-example/vendor/eklausme/saaze/Collection.php(77): Saaze\Collection->loadMkdwnRecursive()
#4 /var/www/saaze-example/vendor/eklausme/saaze/Collection.php(68): Saaze\Collection->loadMkdwnRecursive()
#5 /var/www/saaze-example/vendor/eklausme/saaze/Collection.php(42): Saaze\Collection->loadEntries()
#6 /var/www/saaze-example/vendor/eklausme/saaze/BuildCommand.php(42): Saaze\Collection->getEntries()
#7 /var/www/saaze-example/vendor/eklausme/saaze/SaazeCli.php(98): Saaze\BuildCommand->buildAllStatic()
#8 /var/www/saaze-example/saaze(6): Saaze\SaazeCli->run()
#9 {main}
thrown in /var/www/saaze-example/vendor/eklausme/saaze/MarkdownContentParser.php on line 649
The PHP fatal error seems concerning to me. In step 4, I installed the md4c library as follows:
sudo apt install libmd4c-dev libmd4c-html0 libmd4c-html0-dev libmd4c0
Hello,
again my bad, sorry again.
The most recent version of Simplified Saaze uses a MD4C extension by default. In your case, though, you are using FFI, which is just fine and still works.
You can fix that so: In file vendor/eklausme/saaze/MarkdownContentParser.php, line 648 uncomment, comment line 649. Explanation for that: Line 648 is the FFI method, line 649 is the extension method.
I should make this distinction a configuration flag, but haven't so far.
Haven't seen your note earlier, so I am replying quite late.
Regards,
Elmar Klausmeier.
Alright, that worked.
I should make this distinction a configuration flag, but haven't so far.
Well there are quite a few misses, but it's a young project. So no complaints.
Haven't seen your note earlier, so I am replying quite late.
That's fine too.
I face two more issues as I continued.
First: after php saaze
the build
folder has the /blog
and /music
directories, each with their own posts and index.html
files. However, the build
directory itself did not have an index.html
file. So, the root of the website was basically a directory listing.
Parent directory
- blog
- music
Clicking on blog
or music
rendered their respective pages though. I then realised that the content
folder didn't contain the index.md
file. So I created it, but that alone wasn't enough.
I then realised that there is no index.yml
file as there are blog.yml
and music.yml
. Should I make one, and if so, what should be in it?
Ideally, the root page should already be there out of the box like in any CMS. It is then easier to tinker around and learn the software. But I am sure it's a miss.
Secondly, the link to the CSS file is broken. The source for /build/blog
has this line:
<link href=/blogklm.css rel=stylesheet>
But the style sheet is located in the public
folder. I am sure this is just a matter of editing another file, I just don't know which one.
Hello,
all your comments are correct. Thanks.
As the saaze-example should address newcomers to Simplified Saaze, it really should be easier to set up. Expect a modified version in the next weeks
If you want one or more pages at the top directory, one simple approach is to create another yaml aux.yml
file like so:
sort_field: date
sort_direction: desc
index_route: /
entry_route: /{slug}
Then in content/aux
create an index.md file which shows the user a choice between blog and music.
In my case I use NGINX as a web-server and configure any redirects to whatever is required. I use something like this:
rewrite "^/(saaze-example)/(.*)(\.ico|\.css)" "/rewrite/$1/public/$2$3" last;
Another approach: Use a simple index.html
with something like this:
<title>Redirect</title>
<body>
<h2>Please visit <a href="https://eklausmeier.goip.de/blog/">eklausmeier.goip.de/blog</a></h2>
</body>
</html>
The blogklm.css
file in the public
directory is correct in so far, as public
is used in case you use the dynamic mode of Simplified Saaze. In your particular case, you started with the static file approach, which is all good, you must copy blogklm.css
to your web-server document root. The current template files in template
expect that file there. Though, you can put it anywhere, but then must change top-layout.php
accordingly.
For my website I use the dynamic mode of Simplified Saaze, as I change Markdown files all the time, read: multiple times a day. Some time ago I used the static file approach. In that case you need some deployment script, which takes care of copying CSS files, images, HTML files, etc. to your web-server root.
Here is an excerpt of a deployment script:
SAAZEROOT=/home/klm/php/saaze-xyz
DOCROOT=/srv/http/xyz
errorExit() {
echo $1
exit 1
}
[ -d $DOCROOT ] && rm -rf $DOCROOT
[ -d /tmp/build ] || errorExit "No build directory in /tmp"
cd /tmp
mv /tmp/build $DOCROOT
cd $DOCROOT
ln -s $SAAZEROOT/public/jscss
As you can see, the build
directory is /tmp
. It can be anywhere. For above, I build like so:
php saaze -b /tmp/build
Regards,
Elmar Klausmeier.
If you want one or more pages at the top directory, one simple approach is to create another yaml aux.yml... Then in content/aux create an index.md file which shows the user a choice between blog and music.
This actually seems a bit odd and as a workaround. And a bad design too. In the upcoming update, will it be possible to use content/index.md
as the root web page?
The blogklm.css file in the public directory is correct in so far, as public is used in case you use the dynamic mode of Simplified Saaze. In your particular case, you started with the static file approach, which is all good, you must copy blogklm.css to your web-server document root.
Understood. I should have thought of that earlier. Thanks.
Hello,
regarding the index.md
directly below content
: Though that may seem natural if you only have a single blog, but saaze-example already shows an example of a multi-blog, i.e., two entirely separate blogs, which have their own date ordering or any other ordering, routing, etc.
If you want to make blog
the main blog at the root, then change index_route
and entry_route
in blog.yml
to /
.
Nevertheless, I should have provided an index.html
at the top, which shows in HTML form all the available blogs. By the way, for my blog I use a redirect from root to /blog
, because in this case I consider blog
to be my main blog, while aux, music, and gallery are considered less "relevant". I fully agree that saaze-example was scary for the first-timer. So thanks for persisting and staying ;-)
If there would be a stray index.md
directly beneath content
and blog.yml
says index_route
is /
, which one wins?
The initial design done by Gilbert Pellegrom says:
One of the core concepts of Saaze is that everything is a collection of entries. From pages, blog posts, navigation menus, users, everything.
Collections are defined by Yaml files in the content directory of your site. A collection will define not only the ID and title of the collection, but also the routes for the collection and how entries are sorted in the collection.
I generally think that this was a pretty neat idea. For example, in wendt I make heavy use of 19 collections, i.e., yaml-files. See Example Theme for Simplified Saaze: Wendt.
Thanks.
Regards,
Elmar Klausmeier.
I am thinking about a default yaml file, having its Markdown files directly under content
. That might solve your requirement.
regarding the index.md directly below content: Though that may seem natural if you only have a single blog, but saaze-example already shows an example of a multi-blog, i.e., two entirely separate blogs, which have their own date ordering or any other ordering, routing, etc.
Design wise, even for a multi-blog or a content website with multiple categories, it makes sense to have a home page (that is either a special landing page, or listing of all posts, or a listing of a particular blog like in your case), about page, contact page, etc. Although you can play around with the urls, it is easier to manage the entire website if the same hierarchy is maintained in the content
folder too.
Else, I would have to consider a sub directory inside content
as the root and manage the website that way. Say: content/root
and have sub directories inside it to act as multi blogs. I am not even sure if this will work though. Even if it does, it just over complicates things.
If you want to make blog the main blog at the root, then change index_route and entry_route in blog.yml to /.
That's a work around. Yet I tried it.
index_route: /
entry_route: /{slug}
This creates a problem with the urls. localhost/saaze-example/build
renders the /blog
directory, but clicking on each post takes you to localhost/example-post-1
. It should be localhost/saaze-example/build/example-post-1
Setting entry route back to /blog/{slug}
only redirects it to localhost/saaze-example/blog/build/example-post-1
. To speak in a common term, the base_url
is missing.
I am thinking about a default yaml file, having its Markdown files directly under content. That might solve your requirement.
I am yet to understand Saaze concept. So forgive me for my misunderstandings (if any).
It should render index.md
and index.yml
. I did try creating them.
title: Home Page
sort_field: date
sort_direction: desc
index_route: /
entry_route: /{slug}
But the build throws an error.
> php saaze
PHP Warning: Module "FFI" is already loaded in Unknown on line 0
Building static site in /var/www/saaze-example/build...
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/saaze-example/vendor/eklausme/saaze/BuildCommand.php:43
Stack trace:
#0 /var/www/saaze-example/vendor/eklausme/saaze/BuildCommand.php(43): count()
#1 /var/www/saaze-example/vendor/eklausme/saaze/SaazeCli.php(98): Saaze\BuildCommand->buildAllStatic()
#2 /var/www/saaze-example/saaze(6): Saaze\SaazeCli->run()
#3 {main}
thrown in /var/www/saaze-example/vendor/eklausme/saaze/BuildCommand.php on line 43
I added a landing page to saaze-example v1.4:
it makes sense to have a home page (that is either a special landing page ...)
Valid point.
I hadn't done so, as the saaze-example was essentially just my personal blog at some former time, and I did not and still do not use a landing page. However, my personal choice should not be "enforced" to any other users, who want that, and there are many.
If you re-install saaze-example, watch out to uncomment three lines in Config.php
: see point 5 for FFI. There should be no need to fiddle with MarkdownContentParser.php
.
So far I did not come up with a good approach to have separate Markdown files outside of collections, i.e., that would be your index.md
directly beneath content
. The reason being that the collections serve as the point to recursively read the directory for any Markdown files.
I can confirm that changing index_route
and entry_route
in blog.yml
requires changes in the blog
directory.
However, my personal choice should not be "enforced" to any other users, who want that, and there are many.
Glad to see you think that way. I am merely thinking from a general product design perspective. I am not specially looking at it as "this is what I want, so let's implement it", although a part of what I what happens to be the general design seen itself.
If you re-install saaze-example...
Yes, I am reinstalling and testing again. However, the directory vendor
contains only autoload.php
file and the composer
directory. I cannot find the eklausme
folder inside and therefore, I cannot compile FFI (step 5).
Hmm. I cannot reproduce this. This is what I get:
$ /tmp: composer create-project eklausme/saaze-example
Creating a "eklausme/saaze-example" project at "./saaze-example"
Installing eklausme/saaze-example (v1.4)
- Downloading eklausme/saaze-example (v1.4)
- Installing eklausme/saaze-example (v1.4): Extracting archive
Created project in /tmp/saaze-example
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking eklausme/saaze (v2.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Downloading eklausme/saaze (v2.4)
- Installing eklausme/saaze (v2.4): Extracting archive
Generating optimized autoload files
No security vulnerability advisories found.
$ /tmp: cd saaze-example
$ /tmp/saaze-example: ll
total 24
drwxr-xr-x 6 klm klm 240 Aug 9 15:55 ./
drwxrwxrwt 14 root root 280 Aug 9 15:55 ../
-rw-r--r-- 1 klm klm 480 Aug 6 12:58 composer.json
-rw-r--r-- 1 klm klm 2250 Aug 9 15:55 composer.lock
drwxr-xr-x 5 klm klm 160 Aug 6 12:58 content/
-rw-r--r-- 1 klm klm 48 Aug 6 12:58 .gitignore
-rw-r--r-- 1 klm klm 1110 Aug 6 12:58 LICENSE
drwxr-xr-x 2 klm klm 80 Aug 6 12:58 public/
-rw-r--r-- 1 klm klm 1613 Aug 6 12:58 README.md
-rwxr-xr-x 1 klm klm 108 Aug 6 12:58 saaze*
drwxr-xr-x 3 klm klm 180 Aug 6 12:58 templates/
drwxr-xr-x 4 klm klm 100 Aug 9 15:55 vendor/
$ /tmp/saaze-example: find vendor
vendor
vendor/eklausme
vendor/eklausme/saaze
vendor/eklausme/saaze/.gitignore
vendor/eklausme/saaze/BuildCommand.php
vendor/eklausme/saaze/Collection.php
vendor/eklausme/saaze/CollectionArray.php
vendor/eklausme/saaze/Config.php
vendor/eklausme/saaze/Entry.php
vendor/eklausme/saaze/LICENSE
vendor/eklausme/saaze/MarkdownContentParser.php
vendor/eklausme/saaze/README.md
vendor/eklausme/saaze/Saaze.php
vendor/eklausme/saaze/SaazeCli.php
vendor/eklausme/saaze/TemplateManager.php
vendor/eklausme/saaze/composer.json
vendor/eklausme/saaze/php_md4c_toHtml.c
vendor/eklausme/saaze/saaze
vendor/composer
vendor/composer/installed.json
vendor/composer/installed.php
vendor/composer/InstalledVersions.php
vendor/composer/autoload_namespaces.php
vendor/composer/autoload_psr4.php
vendor/composer/autoload_classmap.php
vendor/composer/autoload_static.php
vendor/composer/platform_check.php
vendor/composer/autoload_real.php
vendor/composer/ClassLoader.php
vendor/composer/LICENSE
vendor/autoload.php
Sorry. My syntax was wrong. I was trying to name the project locally with the same command and I entered the command.
composer create-project eklausme/test
instead of
composer create-project eklausme/saaze-example test
I will do the rest of the testing the coming week and update. Thanks.
I reinstalled SS and built it with php saaze
. I am able to visit the site, but the links are broken. For eg, I have copied the blogklm.css
from public/
to build/
. However, the source code of build/index.html
just says <link href=/blogklm.css rel=stylesheet>
, which basically means localhost/blogklm.css
. The links to blog/
and music/
from home page also directs the user to pages localhost/blog
and localhost/music
.
Now, I remember your earlier comment that the css file should be copied to the web server's document root. In my case (and in most cases), this is not possible because there are other projects too, which is why there is the concept called base url. This is there in SS too, as I see it from top-layout.php
: $rbase.$url
.
I see from the documentation that it is an environment variable. Just for clarity: is this the Linux environment variable or PHP. Knowing that would help me understand how to change it.
That said, from the design perspective, the $rbase.$url
should default to the build/
or public/
directory. Defaulting it to the web server's document root doesn't make sense because most people have multiple projects in the document root.
Your comments are correct.
saaze-example was meant to be a an example. It does not show all possibilities. For example, it shows no MathJax, no galleries, etc.
If you use, e.g., saaze-paternoster, you will see that there I indeed use $rbase
to make the presence "movable" to "any" directory. In other examples I also use $rbase
extensively.
My own blog also uses $rbase
for links, images, etc.
By the way, that was one of the reason to create Simplified Saaze, as the original Saaze from Gilbert Pellegrom did not have this functionality. See Saaze generates static files for root-directory only, relative positioning would be preferred #1 .
Some examples:
<?php $NO_CSS = getenv('NO_CSS') ? true : false; ?>
<?php if (isset($entry['prismjs']) && ! $NO_CSS) { ?>
<link href="<?=$rbase?>/jscss/prism.css" rel=stylesheet>
<?php } ?>
...
<div id=hamitems> <!-- (C) MENU ITEMS -->
<a href="<?= $rbase ?>/blog">Blog</a>
<a href="<?= $rbase ?>/aux/about">About</a>
<a href="<?= $rbase ?>/music" aria-label="Music"> ...
So, $rbase
is used in the templates.
You can go even further, you can use $rbase
also in your Markdown files, i.e., mix PHP with Markdown. But watch out, your templates must accomodate for that!
And for your question: Yes, $rbase
PHP variable can also be set from the outside via shell environment variable $RBASE
.
Alright.
Just trying out the software. I am installing the software following the steps in the documentation and I am getting an error while creating a project.
Note that I install composer from the Debian apt repository.
When I list the files inside the installation directory, I see that the
vendor
directory point to a directory in my home, which does not exist.What am I doing wrong?