-
Notifications
You must be signed in to change notification settings - Fork 1
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
Is this ready for use? #1
Comments
I'm using this for my own personal website, but have been busy with exams lately, so I haven't been able to write documentation. I have some ideas for improvements as well. Since there are no documentation at the moment, you could get inspiration from here: https://github.com/atmoz/atmoz-net (templates are in the Any feedback or ideas is welcome for future development. |
Ok, I'll give it a try. The only extra thing I need is tags for posts, is that doable? I looked at your site you suggested above. Is it using the current version of ply? There seems to be a lot of extras there that are not described in this ply repo? |
Yes, I'm using tags on my own website. I haven't written much documentation (yet), so for now, my website mentioned above is the best source to learn about this tool. You can see available template functions here (if you do not mind reading some code): https://github.com/atmoz/ply/blob/master/templatefn.go |
Ok, just ran it and got this error -
Windows uses backslash not front slash, I think that's it?? |
Yeah, the directory path is used as regex, and apparently backslash in the path is parsed as an escape character. Haven't tried this on Windows yet (I'm using Linux). Good thing you tested it, so I'm now aware of the problem. I will have to test this on Windows and fix any related bugs. |
Is there a quick change I can make at my end and recompile locally here just to get it to work? |
I'll take a closer look tomorrow, but I guess the solution is to replace |
So I would have to do the "go get" command again to get the new version from github. I've never done anything but that. Is there a local command I can use to rebuild my exe after I do the local mod? |
Fixed in e68897f. I tested |
Ok, I'm testing. Previous problem gone. Thanks. Now I'm getting something funny with the menuing. In the build folder if I load one of the main pages, not a blog page, it shows fine. All the links in the menu are perfect. If I click on a link to a blog post, I see it fine but then all my menu links have "blog" inserted into them which makes everything not work. Give it a try. I've never seen menu items change, strange. The page source file is unchanged -
Note above - backslashes should be frontslashes. Update- Must be something to do with relative links in the menu. Notice above the links are relative to where you are. So if I'm in a blog page and hover over other menu items, the above links take hold and I get "blog\blog\overview.html" etc. which does not exist. So how to prevent this? Make them absolute from root. I'll try it. Nope - not when ply is in a sub-folder of the root, which mine is. One other thing - When I go into a blog post I lose the link to images because the image folder is in the main folder not the blog folder. How to fix? Duplicating the image folder into the blog folder is not a good remedy. Update2 - Ok, I tried making everything absolute from the root and the menu items need to look like this
Now all works. I suspect the images folder needs the same thing. I don't see any newline problems. My markdown seems to populate my template fine. So only one mod to do, add that front slash in menu items first character and change the backslash to frontslash in the rest of their paths. One other consideration - Instead of multiple links on the main menu to the blog posts how about one "Blog" menu item that links to a blog page with the blog menu items there. |
Backslashes should indeed be frontslashes. It's using relative paths from the filesystem right now. Regarding relative paths, when a template is used on a page, all paths are relative to that page. So when you want to link to files on the same level as the template, e.g. The second problem you have identified is the use of page Both these relative path problems are solved by using
Since my This makes the href become I try to avoid using absolute paths, as that limits where you can deploy your website. By always using relative paths, it's easy to host the website independent of directory levels. Imagine if you one day want to move your blog from blog.domain to domain/blog. Hopes that makes sense! |
.Rel works for my images -
but I changed my template to this but still not right for navigation -
|
You are calling |
Great, thanks working good. |
Sure, that's how I solved it myself. I have a "notes" directory with an empty
As you can see, I use some template magic to make this work, as I check if the current page being rendered is |
So if I make a "Blog" directory and use the above like this, it should work -
Update - tried it but I'm getting a menu item of "index" and the text from Blog/index.md for the content area.
I don't know what it's doing here. It's reading the template after it copied it from the root. Why did it even copy the template when building? It didn't when I left the forward slash there. I guess the match got triggered and the next part of the script saw the backslashes and complained. I'll try double backslash just for fun. Update3- Yup, double backslash works fine. The listing is horizontal, I'll try to make it vertical. I'm also getting "index" in the main menu. I'd like to see "Blog". Update4- Ok, got the menu vertical, and used this to get "Blog' in the main menu -
Don't know if I need Now I need to remove from the menu the items that are showing in the Blog menu. I suspect this has to be edited a little -
This removed the Blog folder items but I lose my "Blog" menu item.
|
I'll have to normalize the file paths in some way, so it's consistent across operating systems, or else people wouldn't be able to share templates. For showing only the index (I really would recommend using
EDIT: Fixed code typo |
That one didn't work. I got multiple "Blog" items in the menu, so I changed it to this -
Update - The above nearly works. Once I get to the blog page then hover over the Blog menu item I get
|
Oh, that's right, I meant to put the line on the outside of the range loop, my bad. Try |
That works if I add the double backslash. Thanks. Now all I have left to add is Tags! |
It's possible to include custom meta data in the top of pages like so:
But You can see how I've used this feature here: https://github.com/atmoz/atmoz-net/tree/master/.ply/tags – this is how it looks when it's built: http://atmoz.net/tags/ |
Yeah, I really like that tag page although I don't need feeds I guess. I will take a look at your code. What I would like is to have a page of tags like yours but also to have a line in each blog post with the tags associated with that post like this -
I can put the Title of Blog post and the Tag: line in the meta for sure. I'll try to see if I can figure it out. |
For commas between tags you would have to do something like this: https://stackoverflow.com/questions/21305865/golang-separating-items-with-comma-in-template EDIT: Actually, I forgot that I included
|
I added your code to tags/ply.template then added this to the top of a blog post -
When I build, I get a tag folder with nothing in it. |
Did you remember to add a markdown file ala |
No I forgot, but just added and now I get in my main menu an "index" item with the contents of tags/index.md in it. Do I have to make the tags template similar to the blog template with an "if" statement at the beginning? |
There are multiple ways to solve that. Simplest solution is to use if condition in the template as we talked about above. It's also possible to use meta data, e.g. "hideFromMenu" and set that to "true" or something like that on pages you want to hide from the main menu. Another is to use an YAML file with ignore patterns for the menu and read this file in the template to check with an if statement. One of my goals was to make it as flexible as possible and not force too much predefined structure onto the content or templates. |
Ok, I edited the tags template to this and now I get my "Tags" heading but the page of tags is still blank -
|
|
That feed info is confusing me. I'm not sure what to leave or what to delete. |
Here is the relevant parts only:
|
Ok, I'm nearly done I think. I added the meta for the blog pages like this and it works although I would prefer to have the tags under the Heading of the post I don't think that's possible because that would be within the markdown content, true?
|
That is correct. You could use a CSS trick where you put the content into a div and then hide the heading with Instead of hiding the header with CSS (which is not optimal), another possibility is to remove the header before outputting it, using regex: |
I moved them to the bottom of the posts, that seems ok for now. |
Back from xmas. Hope yours was a good one! Back to tweaking the code a little. Is it possible to grab the first sentence of each blog post and put it under the tag listing for that post? My blog template is currently this -
Maybe adding it to the meta is the easiest?? |
This can also be solved with some regex magic:
BTW, I have worked on the path issues. I pushed the code now (8e81c39). You must update your code for it to work, unfortunately. Basically I solved it by keeping the
Remember to always use |
I tried the code above and it works for one of my blog posts but not the other -
Overview post looks like this -
and Welcome post looks like this -
|
Try this regex: You can tweak the regex using https://regex-golang.appspot.com/assets/html/index.html and for example use this test string:
Regex syntax: https://github.com/google/re2/wiki/Syntax |
Tried your suggestion above but some pages match and others don't.
|
I'm ready to run my static ply site using Netlify but a couple of minor issues popped into my mind.
Update - I ran
and I got what I think is a linux exe without the .exe extension. |
I see in main.go there is command line usage using |
OK, this regex ignores exe and bat files in the root folder -
|
Ok, I changed all my path codes to the new values as shown above and got the new exe and all works good! |
Good to hear that it works! There are a lot of sharp edges so early in the development stage, so any feedback is appreciated! Since it looks like you have tried a variety of static website tools, you probably know what features are lacking the most? |
Yes, I've tried a lot and ply is in my top 3! So many lack must have's like tags (for me anyway), others just don't work properly, others use paths from root only, etc. I used to use only php script cms's but since static is the current rage and I can't see a downside to using it for just pages or blogs that's what currently interests me. And all these frameworks, nodejs, gatsby, vue, etc. A user like myself is not going to take months to learn those just to build a simple blog site although many are. I suspect they are developers themselves because someone who uses something like Wordpress cannot just decide to build a new site using gatsby and have it running in a few minutes like Wordpress can (although Netlify has one click installers now, but then to modify takes knowledge). My top 3 builders currently are all written in GO language. It is very nice to only have one exe to deal with and it's so fast to build the site. With your help in this issue, I have picked up more GO knowledge but I am not a coder and I don't have to be to use GO. |
I have plans for adding template functions for image processing, i.e. being able to write something like But you should be able to make a simple image gallery without resizing now as well. I just tested this by creating a new directory and putting some pictures into it, including this
and this
It's hard to balance ease of use and flexibility, and being a programmer myself, I tend to lean more against having more flexibility, but that will require more template programming (like you have seen here). |
Thanks, I tried the above but get some error about the .UrlDir. I removed the dot and used a small case u like you said above -
but it's still not building properly. This is the error -
but ply.template is not supposed to be in the ply.build folder. This is what occurs when it doesn't build properly so it's nothing unusual but I don't know if it's pointing to the actual problem? |
I got ahead of myself, |
Thanks, works good but because of no resize I have portions of the full image but that is to be expected. I'll resize first. |
Greetings, long time no talk!
I tried a couple of things but the build failed. I guess I want to urlmatch tags/* and not have it in the menu. I still want the tag page available though which already works good.
|
Hi! Nice to hear that it still works! I haven't worked much more on this (as you can probably tell by the activity in this repo), but it works well for blogs and small websites as-is. You would need to use
Which in your case would be
|
Very nice, thanks, works great. |
Hi atmoz
Saw your ycombinator post about this. I did a "go get" and got an exe. I'm on Windows7. Shall I give it a try?
The text was updated successfully, but these errors were encountered: