Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QA] page break (pagination), blogroll not on home page, multimedia dir tree, relative urls etc. #784

Open
Joduai opened this issue Jul 17, 2024 · 9 comments

Comments

@Joduai
Copy link
Contributor

Joduai commented Jul 17, 2024

Hello
I've got couple questions I haven't found answers to while browsing through issues. By the way I'm not fond of asking them in issues, but there's no message board for talking about htmly, nor even a discussions section on its github.

Either way after using for couple years bludit as a blog cms, I'm not fond of using it anymore. To make it work as I wanted I had to heavily interfere with core files, and updates became very tedious. Just to mention, back then I was considering putting up a blog using htmly, but it lacked many features I needed out of box to make the workflow smooth enough for me.

Now when I'm doing some sort of cleanup in old software I took a peek at htmly's list of features. After a few perturbation I was able to import some old posts and check how things look after couple years. As a sidenote importing data through inbuild rss import option from external atom feed causes a lot or problems.

I'd like to clarify some things before I delve into porting my own template from bludit to htmly, not to find out after spending much time that it was a bad idea.

  1. I've got couple long posts that I had to split into subpages I could link to directly. Is there a way (maybe a shortcode like the one to show posts summary on the wall) that could allow me to split a post into couple pages, and show a pagination below post/page content?

  2. I'd like to show only latest posts on homepage, while having all posts listed under /blog page. Haven't found a snippet in docs, thus I'm wondering if using
    foreach ($posts as $key => $p): instead of foreach ($posts as $p):
    and breaking the loop with for example if( $key == 4 ) break; would be a good practice?
    assuming that foreach loop iterates through posts based on creation date
    Or better look into recent_posts() function and use it or modify it?

  3. Are the media files able to be uploaded in wysiwyg editor only to /content/images?
    I'm not very fond of supporting only one flat dir, as dozen images inside it always lead to performance problems during opening or during thumbnail creation process. Maybe implementing nested directories for media files are on future todo list?

  4. I suppose that I'd find, and do it anyway, but could you point me to the place where I could change the way urls are handled inside editor field? I'd like to switch from pasting absolute URIs to relative ones. In common wysiwyg editors like tinymce this isn't a problem, but I didn't yet dig much into htmly core files. Still not fond of interfering with core files - as always, works until next update :\

  5. I'd like to implement (more like porting from bludit) user reactions for blog entries but I see that HTMLy doesn't support plugins. Do I have to implement such things as a part of template structure?
    The same question applies to comment system. I've read couple threads about comment systems, especially this one
    Comment Slug #654
    and should I assume that htmly might get its own commenting system?

that's pretty much I wanted to ask at this stage of trying out this blog platform.

@danpros
Copy link
Owner

danpros commented Jul 17, 2024

Hello,

  1. Currently htmly only support subpages on static pages and not for blog post. You can see the example in doks theme (docs.htmly.com).

  2. Use recent_posts(true) to override the recent_posts widget, see blog theme for an example.

  3. Of course, we can change these folders in the future, especially for performance reason, for example grouped by year.

  4. For the editor: system/admin/editor/js

  5. Currently user reactions only support from 3rd party, example: disqus, commentics. Haven't thought about adding comments built-in yet.

If we use the master branch, for widget I am recommend to use recent_posts(), recent_tag(), recent_type() functions because its cached. I am testing it in this blog. The recent_type, allows you to get recent content based on content type and category.

@Joduai
Copy link
Contributor Author

Joduai commented Jul 17, 2024

Thx for an insta answer :)
To clarify a bit, in pt1. I meant splitting a long post or page into couple pages with its own pagination. Not in the matter of nesting additional pages as subpagesof their parent page. In bludit I made it so that using <!-- pagebreak --> shortcodes split the content into subpages. Just like the <!--more--> in htmly split the post into summary and full post, that's a bit similar behavior.

ad.2 thx for pointing out where to look. I've also found such info in docs. Looks promising.
Just have to use mb_substr or something else to get the summary with leading img as shorten() incorporates strip_tags(). Changing core functions would lead me to same problems as I had with bludit :/
Or maybe there's something I'm missing and there's another way of adding a feature image to post other than pasting the link at the beginning of article? While reading older issues I've seen on some screenshots that was an input field for such img in older htmly versions thus I could just get it from array.

edit: i'll check what offers recent_type() function as you suggest

ad.3 for a quickie, handling nested directories in multimedia wild be great. While looking at it I created additional dirs inside /content/images but clicking on such dir to enter it only pasted the path to dir in img url input fiield. Recently noticed that "mediamanager" allows only to upload or insert images without any other actions like deleting them

ad.4 changing basepath in callbackfunc inside editor.js did the trick for pasting relative link to uploaded img, but I failed to find the function responsible for pasting the img url into unput field along with site_url() while clicking on already uploaded img
pity, but that's just a small qol thing I can live without

ad.5 about user reactions I meant those like rating post with stars, emotes or likes/dislikes
just like I implemented as a plugin in my earlier website
reactionsbld
The same goes to comments or any other not built in feature as I assume there is no plugin handling that could store and handle data using htmly core functions.

@danpros
Copy link
Owner

danpros commented Jul 17, 2024

For <!-- pagebreak --> is interesting feature actually (split a post). Let see how it goes but no ETA.

Featured image? when creating blog post choose post with featured image. Than you can call it in template example using $post->image. We can choose regular post, with featured image, video, quote etc. and htmly put it in folder based on the content type (post, image, video). Why? for performance reason and simplicity. Let say we can display 5 latest image or quote on sidebar, use recent_type('image').

And htmly allows theme functions.php like on WP. So you can create custom functions without modify the core, mostly it can cover our needs.

Edit: go ahead if you want to add new features to htmly 😃

@Joduai
Copy link
Contributor Author

Joduai commented Jul 18, 2024

Ohh, that explains why I couldn't see the image while looking what post's data is available. All imported articles through rss were set automatically as "regular posts". Can't even explain why I didn't even test the post type possibilities. Maybe the post type descriptions were a bit confusing and I thought "featured image" is only an image type of posts, like on demotivator's websites. Same with video ones.
Now it shouldn't be a problem with getting the data and displaying it. Just have to edit some of imported posts.
Great idea with different post types, gotta check all possibilities it offers. Haven't seen such approach in any other blogging platforms. Or maybe I just haven't checked enough all of them?

Btw. moving manually post file between directories switches its type automatically, thus having the possibility to change post type while editing it in future might be useful for editors.
Also, since importing through rss sets pot's type automatically, bulk edit for those who migrate to htmly would also come in handy.
Nonetheless I'll add a column with post type in posts list page, but you could consider adding it as well in future versions to see post's type along its category and tags. Unfortunately I was never a type involved into joining any ongoing projects, create changes, discuss them all the time, and maybe finally push requests. Project owners have their own vision, and I fully respect that.

As for theme functions, I'd have to read a bit about it, as I had only a brief look at htmly docs. Also while browsing some theme's dirs haven't seen any of them using custom functions. Anyway, incorporating own functions shouldn't become a problem, even without the support in core functionality. But having possibility to some kind of overload existing functions within template is a nice addon.

Long time ago I had an attempt to implement a microblogging feature inside bludit, but I dropped it due to lack of time. Now when I see different types of posts in HTMLy I wonder if you ever had a thought abut such feature. Maybe not exactly as an additional blog post type, but rather independent one, like blog posts differ from static pages. I imagine this can be achieved with current functionality, but whole logic staying with blog workflow is a bit overkill for such short type of content.

@danpros
Copy link
Owner

danpros commented Jul 20, 2024

Yes we need to improve the importer, it would be great if we could import xml from WP. It's a good idea to check first at system/includes/functions.php because the docs is so far behind.

For theme functions.php we just need to create it inside our theme and this file will included automatically. Eg. to create custom function for our theme.

For microblogging, we just need the right theme actually.

@Joduai
Copy link
Contributor Author

Joduai commented Jul 22, 2024

Should microblogging base on actual logic?
While checking flat file cmses from time to time I've read struggles of people working on file based comments for pico cms (1 file per comment in post dir) as this might become a truly mess even with caching.
I wondered about using 1 file for storing all entries in json or xml structure, maybe splitting it after X entries, but this would complicate the core logic of txt based content management.
Nonetheless such micro entries don't require all the hassle with wysiwyg, SEO options, maybe even own URLs.

Got 3 additional questions

is there a builtin image gallery?
Or should I base only on the possibility of putting 1 image at a time into content, and just implement a jquery gallery like lightbox within template, as HTMLy is based on this js framework?
This way I'd also had to add a thumbnail generation in upload.php

Could you point me to places where I can:
1.change the /admin/ uri to a custom URI for obfuscation reasons, if it's not split between multiple files
2. change the posts URI from /post/posttitle to /customlocation/posttitle. I enabled blog listing under /blog page, thus I'd like to display the post also under the /blog/posttitle

@danpros
Copy link
Owner

danpros commented Jul 22, 2024

Do you mean microblogging like Twitter? without title and just the content? with current workflow possible, we just need to not print the title in the template.

Or just make the title optional is enough and use the date as the title automatically if we leave the title empty. The url perhaps example.com/post/20240722201322. Because of current folder and file structure, the title, category and tags is mandatory (more info)

For comments, I will use one comment file per post. Why? because htmly is a flat file based so I try not to save crucial data in one file, the meaning of crucial here is that if this file is corrupted then the blog cannot run as it should be.

Currently the data stored in one file is the page views and menus, this data is not that important compared to other data like username, category, tags, date, slug etc. so even those file deleted then the blog is still running as usual.

Currently the image gallery is still very limited and can only be accessed when we add/edit content, this can be developed further, for example creating a new route /admin/gallery.

For thumbnail, I already add such function in master branch, create_thumb($imgFile, $width, $height) and improving the get_image($string, $width, $height). Example code from my htmly dev blog:

// get recent posts with tag 'featured', max 5 posts
<?php $featured = recent_tag('featured', 5, true);?>
<?php if(!empty($featured)):?>
<!-- Main slider -->
<div class="main_slider">
    <?php foreach ($featured as $f):?>
    <!-- Article -->
    <article class="item">
        <div class="item_overlay">
            <a href="<?php echo $f->url;?>"><img loading="lazy" width="360" height="240" src="<?php echo get_image($f->body, 360, 240);?>" alt="<?php echo $f->title;?>"></a>
            <div class="item_overlay_container">
                <div class="item_overlay_category">
                    <?php echo $f->category;?>
                </div>
                <div class="item_overlay_content">
                    <h3><a href="<?php echo $f->url;?>"><?php echo $f->title;?></a></h3>
                    <div class="item_meta">
                        <span><?php echo format_date($f->date);?></span>
                        <?php if (authorized($f->url)):?><span><a href="<?php echo $f->url;?>/edit?destination=post">Edit</a></span><?php endif;?>
                    </div>
                </div>
            </div>
        </div>
    </article>
    <?php endforeach;?>
</div>
<?php endif;?>

Post with featured image:

create_thumb($f->image, 360, 240);

For more complete query use recent_type(), get recent post by type (regular post, image, video), by category, and by author.

// 5 recent posts with featured image
$recentImage= recent_type('image', 5, true);

// 5 recent posts with 'tech` category / use the slug
$recentTech = recent_type('tech', 5, true);

// 5 recent posts from username
$recentUsername = recent_type('username', 5, true);

Those recent functions is cached so let say we create magazine like blog, displaying 10 type of posts (from tag, category, type), the performance will not decreased much (already implemented in master branch).

Regarding the /admin/ we need to login first before we can access it so to change it is not necessary. And with how htmly is now, changing the login page is pointless, because by adding /edit/ after the post it will automatically redirected to login page.

For changing /post/posttitle to /customlocation/posttitle you need to modify htmly.php

@Joduai
Copy link
Contributor Author

Joduai commented Jul 23, 2024

Do you mean microblogging like Twitter? without title and just the content? with current workflow possible, we just need to not print the title in the template.
Or just make the title optional is enough and use the date as the title automatically if we leave the title empty. The url perhaps example.com/post/20240722201322. Because of current folder and file structure, the title, category and tags is mandatory (more info)

With current logic of content management it's pretty easy to display a "microblog" feed on website like the way on mastodon or twitter as you mentioned. I'm having more on mind backend logic, where posting a microblog entry becomes some kind of a hassle compared to the simplicity of X or FB where I just click a button, enter couple words, add a link or paste text from clipboard and voilla. We have to enter title, select mandatory things like category and tag(s), just like in a fully blog post.
Those entries would be still included in rss, sitemap, will have own URI, and of course would be displayed along normal blog posts in default templates without changes - but that actually doesn't matter.
The question is: should a microblog entry be managed the same way as usual blog post?

Basically additional webpage for microblog entries would be great. Just like the blog posts have the option to be displayed under /blog URI, so could be with /microblog, especially when there was more than 1 registered user.
Title as proposed could consist of date. Filename could automatically get proper category/tag for such entry.
As for tags such simplicity could have an impact on using #tags to show same tagged microblog entries
But they could be optional. Maybe entered in textarea and processed automatically as links to search results for entries with same tags? Just like it works on socialnetwork websites?

To be honest I haven't seen such functionality in any flat file cms. Not sure about database powered cms and their default functions as I haven't touched such things for years.

For comments, I will use one comment file per post. Why? because htmly is a flat file based so I try not to save crucial data in one file, the meaning of crucial here is that if this file is corrupted then the blog cannot run as it should be.

It's understandable as those are basic principals you described in docs.
I just had on mind issues like the one about comments in picocms: picocms/Pico#700
Just for the sake of efficiency when there would be many comment files, maybe caching them in one file inside post/comments dir?

Currently the image gallery is still very limited and can only be accessed when we add/edit content, this can be developed further, for example creating a new route /admin/gallery.

hmm....you'd like to go further by adding a standalone gallery management based on shortcodes, that can be pasted within post content? Didn't think about that. Just had on mind a way of creating a gallery during a post adding/editing basis, but a stanadlone functionality would be fantastic. But still, uploading in more than 1 flat dir (with subdirs) and additional media management (rename,delete etc.) would be more useful at the mean time.

For thumbnail, I already add such function in master branch, create_thumb($imgFile, $width, $height) and improving the get_image($string, $width, $height). Example code from my htmly dev blog:
create_thumb($f->image, 360, 240);

great! I scrolled through functions.php while having first approach to port old template yesterday, but as you say it's a fresh thing not avail in 2.9.9 I have installed.

Regarding the /admin/ we need to login first before we can access it so to change it is not necessary. And with how htmly is now, changing the login page is pointless, because by adding /edit/ after the post it will automatically redirected to login page.

I'm just used to change default administration URIs as I've seen how many bots and automatic attacks were requesting resources in default paths, especially on wordpress instances. Platforms like prestashop generate custom string in path to admin during installation. Maybe it's time to change approach, as getting to content management as you say requires logging in through /login uri.
But still trying to access to /admin returns http 302 letting know it's the right path.

For changing /post/posttitle to /customlocation/posttitle you need to modify htmly.php

ohhh thx for pointing, I was wondering about get(/post/:name function but also had to change generated post->url path in functions.

btw. auto generated ToC function is awesome!

@danpros
Copy link
Owner

danpros commented Jul 24, 2024

should a microblog entry be managed the same way as usual blog post?

It should yes for easy to scaling it, like recent microblog with X category, or with X hashtag. For category provide the user with current form as an example (so its mandatory), use show hide more options etc.

Interesting actually, let see how it goes.

hmm....you'd like to go further by adding a standalone gallery management based on shortcodes, that can be pasted within post content?

Please go ahead if you want to develop the gallery to more advanced gallery.

I'm just used to change default administration URIs as I've seen how many bots and automatic attacks were requesting resources in default paths, especially on wordpress instances.

In htmly, the accepted URLs route are very limited (see: htmly.php). So I'm sure that now it's very safe from attacks as long as you use a strong password, enable the security features (recaptcha etc.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants