renard / o-blog

Standalone orgmode blog exporter. DEPECATED, NOT MAINTAINED
http://renard.github.com/o-blog-v2
260 stars 58 forks source link

Suggestions / Questions #25

Closed ghost closed 12 years ago

ghost commented 12 years ago

Thank you for your work on o-blog. I am currently working on modifying o-blog to make it into a system capable of managing an online, open-access journal. I am currently using a combination of Org export and Jekyll, but discovered o-bog, which allowed me to create most of the functionality I needed. I do have a few things that I can't seem to get working. I would greatly appreciate your help with those few things. Since this will be a real-world application of o-blog, fixing these issues may be advantageous for others as well.

  1. Currently I can make long tags by using _ which creates safe urls and but presents as a space. I really need a similar functionality for categories. Is there any way to make multi-word categories that export in a safe/sanitized manner such as volume_1_issue_2, but display as something like "Volume 1 Issue 2"?
  2. Is there any way to use categories and tags together?

In Jekyll, I am using the following code, but can't seem to do something similar with o-blog:

<nav>
    <h2>Number {{page.issue | capitalize}}</h2>
    <h3>{{page.volume}}</h3>
    {% for category in site.categories %}
        <h3>{{category[0]}}</h3>
    {% for post in category[1] %}
    {% if post.issue == page.issue %}
    <ul>
        <li><a href="{{post.url}}" title="{{post.title | escape}}" rel="bookmark">{{post.title}}</a><br/><span>{{post.author}}</span></li>
    </ul>
    {% else %}
    {% endif %}
    {% endfor %}
    {% endfor %}
</nav>

Basically, what I am trying to do is limit posts to the current category / issue, say One for example and then go through all tags for articles in that issue and display first the tag, then the articles associated with that tag.

Ex:

{% assign activemenu = page.bodyclass %}

renard commented 12 years ago

Hi,

Currently I can make long tags by using _ which creates safe urls and but presents as a space.

I just add category-safe property for a post. Thus It would be published into category-safe instead of category.

Is there any way to use categories and tags together?

For the moment a tag is not connected to a category. Maybe in a future version this will be done.

Is there any way to get automatic excerpts?

RSS exporter use the function: (htmlize-protect-string(ob:post-content-html p)) You can thus change it and use your own. Be aware that you might break the html.

Automatic Sitemap generation.

Do you have an example of your needs?

In Jekyll, I can have highlighted menu items automatically without any javascript by using code such as follows

It might be possible by comparing the link path and the post output path.

ghost commented 12 years ago

Thanks again!

renard commented 12 years ago

One issue I found is that the category index was still sent to an unsanitized directory. I also sent a pull request to fix this.

Please check last commit (de5dc0d5cb7b3b1c231192f2b7064335b347bbae) that should fix the category issue.

renard commented 12 years ago

The body class issue isn't a big deal since I can easily do it with javascript.

If you do have a fix please send a pull request.

renard commented 12 years ago

If sometime in the future you could get the tags and categories to know about each other that would be great.

Yep that's why using a cl-structure ob:category is a better idea that adding a category-safe as I did before.

renard commented 12 years ago

I really wish there was an easy way to truncate the post for RSS export.

This is not liquid unfortunately. What does exactly "{{post.content | strip_html | xml_escape | truncatewords: 60}}"?

Maybe a piece of lisp can handle this.

Update: AFAICR the html is removed thus you get an unformated text right?

ghost commented 12 years ago

Please check last commit (de5dc0d) that should fix the category issue.

Almost! It fixes the previous issues and works well except for one thing that was working before but no longer works. I want to get the category name and link of a particular post on the tags index page, but that no longer works. I tried everything but get errors such as "Lisp error in nil: (error ob:post-category-safe accessing a non-ob:post)". The debug page now has "[cl-struct-ob:category "Volume 1 No. 1 (2012): May" "volume-1-no-1-2012-may"]" for the category. My current code is below:

<lisp>(ob:insert-template "page_header.html")</lisp>
<h2>Articles</h2>
<lisp>
  (progn
  (loop for post in POSTS
  do (when (member (ob:tags-safe TAG) (mapcar 'ob:tags-safe (ob:post-tags post)))
  (insert (format "
  <section>
    <h3><a href=\"%s/%s\" title=\"%s\">%s</a></h3>
    <h4>%s</h4>
    <p>%s <a href=\"%s/%s\" title=\"%s\">Read more &rarr;</a></p>
    <p><cite><a href=\"%s/%s/index.html\">From <em>Luvah Number %s</em></a></cite></p>
" (ob:path-to-root) (ob:post-htmlfile post) (ob:post-title post) (ob:post-title post) (ob:post-author post) (ob:post-excerpt post) (ob:path-to-root) (ob:post-htmlfile post) (ob:post-title post) (ob:path-to-root) (ob:post-category-safe post) (ob:post-category-name post) )"</section>"))))
</lisp>
<lisp>(ob:insert-template "page_footer.html")</lisp>

If you do have a fix please send a pull request.

I have a quick and dirty hack that works for top level menus. I will refine it and send a pull request if I can manage to get it working properly.

Yep that's why using a cl-structure ob:category is a better idea that adding a category-safe as I did before.

I can't say I understand this fully. Would you mind explaining how this will solve my issue? I am more used to PHP and Ruby, and an just getting started with Lisp, so please be patient and bear with my novice mistakes and possibly silly questions.

This is not liquid unfortunately....

"{{post.content | strip_html | xml_escape | truncatewords: 60}}" simply removes all HTML tags, then processes what is left to make sure it is safe and valid XML, then finally truncates the text after 60 words. This works well for me since I prefer for my news feeds to contain teasers with plain text. The reader can then visit the site if they so desire. As you can see, my needs here are rather simple. Do you think some Lisp can work magic here?

ghost commented 12 years ago

Re. Categories

I managed to get the categories on the tag page working by using the following:

(ob:category-safe (ob:post-category post)) (ob:category-name (ob:post-category post))

I am not sure if it is the best solution, but it works.

renard commented 12 years ago

Yes this is the way to use categories.

renard commented 12 years ago

I close this discussion. Please re-open one issue per topic.

Thanks

ghost commented 12 years ago

I apologize for the rambling thread. Thank you so much for all of your help!