middleman / middleman-blog Goto Github PK
View Code? Open in Web Editor NEWBlog Engine Extension for Middleman
Home Page: https://middlemanapp.com
License: MIT License
Blog Engine Extension for Middleman
Home Page: https://middlemanapp.com
License: MIT License
I blog infrequently, so having a directory structure that matches my permalink structure means I'll have a lot of deep directories with only one post in each. I'd prefer if the blog extension at least had an option to work a bit more like Jekyll, where posts can all be stored in one folder, and then are rendered to folders for permalinks. For example, I might have a post:
2011-12-13-middleman-is-awesome.md
Which would produce the output file:
2011/12/13/middleman-is-awesome.html
Actually, since the date is in the frontmatter anyway, I should be able to structure my posts any way I like and still have them output in my preferred permalink structure. Perhaps a setting where I can give the regex I like - for me, "blog/*.md" is enough to specify my posts.
The default templates generated for calendar and tag loop through page_articles. This shows all the articles in the entire blog, instead of the appropriate subset for the year or tag.
I believe the templates should be using the articles local variable instead.
I'm working on adding pagination to the index of my blog. I'd like to get the code generalized at some point to be used by others.
Hi all,
I'm currently using Middleman inside a subdirectory on my domain (relative_assets turned on), so I was wondering if it was possible for next_page and prev_page to be "dynamic" links (not relative to root). Right now it seems they're always relative to root.
https://github.com/tdreyno/middleman-blog/blob/master/lib/middleman-blog/feature.rb#L77-78
engine = app.settings.markdown_engine.new { sum }
data["summary"] = engine.render
app.settings.markdown_engine.new is returning the symbol :maruku, then .new tries to create an instance of that symbol which results in:
/Users/bgessler/Projects/middleman-blog/lib/middleman-blog/feature.rb in block (2 levels) in registered
engine = app.settings.markdown_engine.new { sum }
/Users/bgessler/Projects/middleman-blog/lib/middleman-blog/feature.rb in map
articles = Dir[articles_glob].map do |article|
/Users/bgessler/Projects/middleman-blog/lib/middleman-blog/feature.rb in block in registered
articles = Dir[articles_glob].map do |article|
/Users/bgessler/Projects/middleman-blog/lib/middleman-blog/feature.rb in block (2 levels) in registered
})
Initially I had trouble defining blog.source
/blog.permalink
in conjunction with blog.prefix
. The docs don't make it obvious that something like the following will result in no source files being found:
blog.prefix = "news/"
blog.permalink = "news/:year-:month-:title"
blog.sources = "news/:year-:month-:title"
This won't work because the prefix is ALWAYS prepended to permalink/sources. I was quite confused until I poked around the prefixing code.
It would be sufficient to simply note that the source dir should only be defined in either the permalink/source or the prefix.
I'm thinking we should re-org our internals a little more. @bhollis has already done a ton.
I think we need a root Blog class which is initialized with a hash, instead of the set
variable methods.
Old format:
activate :blog
set :blog_permalink, ":year/:month/:day/:title.html"
New format:
activate :blog, :permalink => "blog1/:year/:month/:day/:title.html"
activate :blog, :permalink => "blog2/:year/:month/:day/:title.html"
With an old version of the extension I was able to have have source files such as 2012-01-blogpost.html.markdown
In theory this seems like it should be possible, by simply doing blog.sources = ":year-:month-:title.html"
but this does not work, the following error is thrown:
/projects/mm-blog-test/vendor/bundler/gems/middleman-blog-3.0.0/lib/middleman-blog/blog_data.rb:80:in
sub': can't convert nil into String (TypeError)`
Apparently because of resource.slug = $4
on line 76 of blog_data.rb.
Thanks.
I'm using the Middleman Blog guide for reference material.
$ gem install middleman
********************************************************************************
Welcome to Middleman 2.0
In addition to many new features, some backwards-incompatible
changes have been made to the structure of Middleman sites.
Before running you old, v1.x project on Middleman 2.0,
review the Migration guide:
http://middlemanapp.com/guides/migrating
********************************************************************************
Successfully installed middleman-2.0.14
1 gem installed
$ gem install middleman-blog
Successfully installed middleman-blog-0.1.3
1 gem installed
$ middleman init blogtagblues --template=blog
/home/blt/.rvm/gems/ruby-1.9.3-p0/gems/middleman-2.0.14/lib/middleman/guard.rb:
5: Use RbConfig instead of obsolete and deprecated Config.
create blogtagblues/config.ru
create blogtagblues/config.rb
create blogtagblues/source
create blogtagblues/source/2011/01/01/new-article.html.markdown
create blogtagblues/source/_article_template.erb
create blogtagblues/source/archives/index.html.erb
create blogtagblues/source/feed.xml.builder
create blogtagblues/source/index.html.erb
create blogtagblues/source/layout.erb
create blogtagblues/source/stylesheets
create blogtagblues/source/javascripts
create blogtagblues/source/images
You may find blogtagblues here. I edit source/2011/01/01/new-article.html.markdown
to look like so:
---
title: "New Article title"
date: 01/01/2011
tags: blogging
---
Content of my article
and find that, after I've started up middleman server
for this project I'm greeted with the exception:
NameError at /
undefined local variable or method `blog_taglink' for #<#<Class:0x9c948bc>:0xaef6a64>
file: feature.rb location: block (3 levels) in registered line: 96
I'm trying to add an About page to my middleman blog. To do this I added an "about.markdown" file in my source/ directory. Running middleman build correctly generated about.html in the correct location. I would, however, like to have this custom page generated as :title/index.html i.e. it should generate about/index.html so that I can access the page as http://myWebSite/about/
How could I do this?
Is there support for per-page permalinks in the YAML frontmatter?
I want to use a layout for the blog, but it isn't using the layout file. What am I doing wrong?
This is my config.rb
activate :blog do |blog|
blog.prefix = "blog"
blog.layout = "blog_layout"
end
the blog_layout.erb sits in the "blog"-directory in the source folder.
Do I have to place this file somewhere else?
Thanks
Nick
Hi,
All articles use the layout set for the blog in config.rb
and cannot be overridden by the YAML front matter, like it can be done with normal pages.
I'm still figuring out your code, so I haven't been able to fork it and edit it yet, but I'm guessing it has to do with the render
method in /lib/middleman-blog/blog_article.rb
not considering the front matter of articles.
Also, I'm not sure if this is a bug or if this was done by design.
I was wondering if middleman-blog is supposed to work with middleman 3.0.
After a quick look, it doesn't seem to register properly. I wanted to ask before diving into the code.
(I'm using repositories directly, not gems).
Thanks!
With middleman master and middleman-blog master checked out (and referenced in a Gemfile), running
bundle exec middleman init . --template=blog
just produces the normal template. At the very least I'd expect the template option to error out if no matching template were present.
The documentation links for middleman-blog as specified in Readme.md are broken. For instance, the link http://beta.middlemanapp.com/extensions/blog/ does not work.
Where should I look for documentation?
An import from an existing wordpress-blog would be great ;D
I am looking to create some posts in a blog that are of the link-style, probably made most famous by Gruber's DaringFireball.
Not all posts will necessarily be of this type, but I would like to see if it can be done.
There is a technique for doing this in Octopress at http://www.cnnr.me/b/2012/01/how-to-link-to-other-posts-in-octopress/
This looks a bit messy though, and I am not sure I like having those if statements in the template.
I am new to middleman, but I will give it a try. I wanted to get it out there in case any one had any pointers on how best to do this.
Thanks, Steve
When I create a blog post with a header and a few paragraphs, the summary shows me the first paragraph and the header. Is there a way to strip out the first header in the summary?
I would guess that this is the preferred behavior for must users.
Steps to Reproduce:
• Create a blog article using "middleman article title"
• Run middleman build
Expected Results:
The build should not fail.
Actual Results:
The build fails.
Notes:
This is because the markdown filename contains only the date, whereas the frontmatter contains the time as well.
date: 2006-06-10 00:00 +00:00
Specifically when publishing multiple articles on one day. I currently I have a loop that looks like the following:
<% data.blog.articles[0...5].each do |article| %>
<article>
...article content...
</article>
<% end %>
Which lists the 5 most recent articles on my index page, but when I publish more than one article per day it sorts them in chronological order, where I would like them to be reverse chron, like a blog typically is. Is there an easy way to reorder this so it works in a typical blog format, with the newest article of that day appearing first?
If I set up a new blog project and add a tag to an article (exactly the same as the example in #14), going to the tag's page (tags/blogging.html, for example) returns a File Not Found. The page is also missing when building the project. According to the docs:
Simply add tag frontmatter to your articles and they will be organized on a tag page at tags/TAGNAME.html by default.
I'm trying to create other standalone pages (in addition to the index page) along with the blog extension. It seems the is_blog_article?
function returns true for these non-blog pages. I get the following exception:
TypeError at /about.html
can't convert nil into String
file: feature.rb location: parse line: 120
/Users/matt/Web/svn/phaseshift_website/source/_article_template.erb in evaluate_source
<time class="updated" pubdate><%= current_article_date.strftime('%b %e %Y') %></time>
/Users/matt/Web/svn/phaseshift_website/source/layout.erb in evaluate_source
<%= partial settings.blog_article_template %>
Here's the excerpt from my layout.erb
file:
<% if is_blog_article? %>
<% content_for :blog_article, yield %>
<%= partial settings.blog_article_template %>
<% else %>
<%= yield %>
<% end %>
My _article_template.erb
is as follows:
<article class="hentry">
<h2 class="entry-title">
<%= current_article_title %>
<time class="updated" pubdate><%= current_article_date.strftime('%b %e %Y') %></time>
</h2>
<div class="entry-content">
<%= yield_content :blog_article %>
</div>
</article>
My config.rb:
activate :blog do |blog|
blog.layout = "article"
blog.taglink = "metadata/:tag.html"
blog.tag_template = "source/tag.html.erb"
end
When I middleman build
I get:
error build/metadata/beta.html
Path metadata/beta.html proxies to unknown file source/tag.html.erb
No matter where I put tag.html.erb
or what I name it, I get the same error. It seems there is a problem with the proxy?
I'm using v3.0.0.beta.3 for both blog and middleman
Hey guys, I'm trying to add a next and prev article navigation functionality to my blog. However I couldn't make it work :( I tried to use next_article
and prev_article
but it didn't work.
A screenshot to illustrate what I'm trying to do: http://cl.ly/JdQX
Is it possible to do this with middleman?
I do know if this is an issue with middleman or middleman-blog, but it fails to find blog articles that have non-ASCII characters in the file name. This means that the blog title and the file name have to be different. In the case of Latin-based languages, the file name has to be stripped of accents.
Make sure markdown config options like this:
set :markdown, :smartypants => true
Is actually used. Works in normal Middleman, but not in the blog extension.
Hello,
I was getting some serious errors trying to use Slim as a default template language. I already installed the slim gem, replaced layout.erb to layout.slim and here's my config.rb:
activate :blog
set :blog_permalink, ":year-:month-:day-:title.html"
# set :blog_summary_separator, /READMORE/
# set :blog_summary_length, 500
set :blog_layout_engine, "slim"
page "/feed.xml", :layout => false
# Build-specific configuration
configure :build do
# For example, change the Compass output style for deployment
activate :minify_css
# Minify Javascript on build
activate :minify_javascript
# Enable cache buster
# activate :cache_buster
end
So, what's wrong?
I've noticed a couple of times that e.g. the year calendar page sometimes has the @month
or @day
variables set but haven't been able to pin it down until I tried combining my tag and calendar pages into a single template.
Here is a commit with some failing tests that demonstrate the problem: rumpuslabs/middleman-blog@8af45b9c8f47d4dde50d492666d8377026b29e65 (pull the instance_vars_bug
branch)
If I figure out what's going on and manage to fix it I'll turn this into a pull request, in the meantime if anyone has any ideas...
Commit: eaf4e7a is not included in 0.1.4.
I locally created a "0.1.5" version on above commit and it seems to work.
I know mm 3.0 is WIP, but not having a usable set of default gems for ruby 1.9.2 is a little annoying.
Thanks.
I'm getting an error when attempting to run a freshly (had to make my own _article_template.erb) generated blog with middleman. The details are below, let me know if you need any other info, or want me to try anything out to fix it.
private method `gsub!' called for #Array:0x10ba7aa10 @ Line 53
app.get("/#{app.blog_permalink}") do
process_request({
:layout => app.blog_layout,
:layout_engine => app.blog_layout_engine
})
# No need for separator on permalink page
body body.gsub!(app.blog_summary_separator, "")
OS X Snow Leopard
Default Ruby Install (Ruby 1.8.7)
We include the date in the filename of the article, but then require it again in frontmatter and only use the frontmatter date. It should be implicitly set by the filename.
Hi,
I live in Japan Standard Time (JST), GST+09:00.
I have several past articles created in the morning before 9am, local time, that will now raise an exception today when I try to build the site. The URL to the article uses UTC while the article's metadata uses local time, and Middleman Blog doesn't like it.
For example, let's say I have an article source file named 2012-01-01-happy-new-year.html.markdown
, with the date in its metadata set as date: 2012-01-01 01:00 +09:00
, when building the site, Middleman Blog will convert the metadata to UTC and think the file name is incorrect as it should match 2011-12-31-happy-new-year.html.markdown
instead, raising this exception:
/Users/remi/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/middleman-blog-3.1.1/lib/middleman-blog/blog_article.rb:127:in `date': The date in articles/2011-12-31-happy-new-year.html's filenam
e doesn't match the date in its frontmatter (RuntimeError)
In my opinion, since my blog is only authored by myself, the local time should prevail. Before I dig into the code to fix this, if need be, I want to know the opinion of others on this.
Hi,
when I set a title on the blog index page frontmatter, the title passed to the layout, through data.page.title, is the one of the last article on the index page, not the one on the frontmatter section.
Because of the way tag and calendar pages are generated (as proxies after_configuration
), they don't update when pages change. The global list of tags is also not recalculated. This means adding or removing a tag from posts while the server is running won't be reflected in any tag lists and new tags won't have a page.
I spent a while running around in circles trying to get the blog extension working on master after reading the docs - I didn't realize that I needed to do that special trick in my layout where I explicitly render my content into the _article_template.erb. It'd be much more straightforward if the article template was simply applied like a layout around blog post content, and then render the result into the regular layout.
Since @bhollis added the ability to leave posts unpublished, I was thinking it might also make sense to extend BlogArticle#published?
to also check whether the article's date is later than the current time. This would allow e.g. automatic posting using a cron job to regenerate your site regularly - as soon as the post is no longer future-dated it will be published.
I ran into problems though, because DateTime.parse
and Date#to_datetime
assume that the given date is in UTC unless the timezone is explicitly specified. ActiveSupport has a lot of date/time/timezone handling code that I could use to solve this problem but it adds a dependency on the tzinfo
gem.
Is this worth pursuing?
Current issue:
middleman init my_blog --bundler --template=blog
create my_blog/config.ru
Could not find "shared/Gemfile.tt" in any of your source paths. Your current source paths are:
/Library/Ruby/Gems/1.8/gems/middleman-blog-0.1.5/lib/middleman-blog
Right now, the Gemfile template (Gemfile.tt) is in the middleman gem, should add one to middleman-blog which also includes the blog gem (duh).
This is for once https://github.com/tdreyno/middleman/issues/199 is available - it would be really nice to have a "new blog post <title>" command that created a new markdown file in the right folder structure with prefilled frontmatter.
Hello, i've setup my blog extension like this (excerpt from config.rb):
activate :blog do |blog|
blog.prefix = "blog"
blog.permalink = ":year/:month/:day/:title.html"
blog.taglink = "tags/:tag.html"
blog.paginate = true
blog.page_link = "p:num"
blog.per_page = 20
blog.tag_template = "blog/tag.html"
blog.calendar_template = "blog/calendar.html"
end
For some reason, when i attempt to go to "/blog/2012.html" the calendar template (i'm assuming) throws out an Internal Server Error saying "negative argument".
Any ideas why that might be?
Thanks in advance,
Pedro
when you are viewing a tag page, the tag_path renders as /tag/tag/[name of tag].html.
I was wondering if there's a way to get a list of relevant posts per article?
Right now our template ships with feed.xml.builder
, but who's really going to customize that? We should ship with a default feed implementation that uses an in-gem template instead of relying on users to generate feeds themselves. If we do that, we can easily do per-tag feeds too.
The gem requires version 2.1.0.pre of Middleman, which doesn't exist.
Using Middleman version 2.0.14.pre2 and 3.0.0.alpha.2 I get this error:
/Users/jesper/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/gems/middleman-3.0.0.alpha.2/lib/middleman/core_extensions/features.rb:102:in 'instance_eval': uninitialized constant Middleman::Features::Blog (NameError)
Which version of Middleman supports the blog extension?
File /source/feed.xml.builder with this code, when I build html:
/Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt/template.rb:108:in `require': cannot load such file -- builder (LoadError)
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt/template.rb:108:in `require_template_library'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt/builder.rb:14:in `initialize_engine'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt/template.rb:55:in `initialize'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt.rb:98:in `new'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt.rb:98:in `block in []'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt.rb:96:in `each'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/tilt-1.3.3/lib/tilt.rb:96:in `[]'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/sitemap/store.rb:189:in `extensionless_path'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/sitemap/store.rb:178:in `file_to_path'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/sitemap/extensions/on_disk.rb:45:in `touch_file'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/sitemap/extensions/on_disk.rb:24:in `block in initialize'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:158:in `instance_exec'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:158:in `block in run_callbacks'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:156:in `each'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:156:in `run_callbacks'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:94:in `did_change'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:126:in `block (2 levels) in reload_path'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:122:in `each'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:122:in `block in reload_path'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:115:in `chdir'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:115:in `reload_path'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/file_watcher.rb:37:in `block in registered'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb:53:in `instance_exec'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb:53:in `block in run_hook_for'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb:49:in `each'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb:49:in `run_hook_for'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/vendor/hooks-0.2.0/lib/hooks.rb:107:in `run_hook'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/core_extensions/request.rb:57:in `inst'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/cli/build.rb:85:in `shared_instance'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/cli/build.rb:56:in `build'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/task.rb:27:in `run'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/cli.rb:77:in `method_missing'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/task.rb:29:in `run'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/task.rb:126:in `run'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/lib/middleman-core/cli.rb:22:in `start'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/gems/middleman-core-3.0.6/bin/middleman:18:in `<top (required)>'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/bin/middleman:23:in `load'
from /Users/artemeff/.rvm/gems/ruby-1.9.3-p194/bin/middleman:23:in `<main>'
My and @tdreyno's initial attempt at producing blog summaries didn't work because it would split tags, sometimes causing invalid HTML. @rumpuslabs fixed it to truncate the template, then render, which sounds better, except:
The correct solution would be to use Nokogiri to parse the rendered content, then iterate through the nodes, adding whole elements until the total text length got past a certain point. This would necessitate adding a dependency on nokogiri
to middleman-blog
. Alternately, we could just drop the summary-based-on-length feature and require people place a break point in their blog posts.
I am running middleman 3.0.0.rc1 on Ubuntu 12.04 using rvm and MRI ruby 1.9.2
Here are the steps to reproduce this problem:
$ gem install middleman --pre
$ middleman init mm
$ cd mm
$ bundle
$ middleman
Everything works fine at this point.
Add gem "middleman-blog", "~> 3.0.0.rc1" to Gemfile
$ bundle
$ middleman init . --template=blog
$ middleman
== The Middleman is loading
/home/hectorsq/.rvm/gems/ruby-1.9.2-p290@middleman/gems/tilt-1.3.3/lib/tilt/template.rb:108:in `require': no such file to load -- builder (LoadError)
Installing builder gem manually does not solve the problem.
We're using a custom layout for the articles through nested layouts:
/config.rb
activate :blog do |blog|
blog.layout = "article_layout"
# ...
end
/source/article_layout.haml
- wrap_layout :layout do
%h2 Blog
%article
%h3= current_article.title
%section.body
= yield
This works fine while running the preview server, but during build we're getting
$ middleman build --debug
…
error build/article_layout.html
path/source/article_layout.haml:5:in `block (2 levels) in evaluate_source': undefined method `title' for nil:NilClass (NoMethodError)
Any idea what's going wrong here? Are we using the layouts wrong?
The source includes the blog_index_template setting, and the docs reference it, but it doesn't look like it's actually used. I'm guessing it was intended for a feature that would generate index pages based on dates (year's posts, month's posts, etc) and tags (again, as mentioned by the docs). Right now it looks like if you wanted those types of pages you'd have to build them yourself via helpers/proxy (see issue #6). It'd be great if the blog extension did this stuff.
So, I attempted to use wrap_layout within a blog post to get it working as we'd hope but... it doesn't seem to work as you'd expect. I tried taking a stab at the code but got a bit lost in middleman-core's rendering area.
When you attempt to wrap_layout, you only get the layout you specified and not the layout as called in the wrap_layout.
I will provide code that shows the failing feature.
We should provide a method on each blog article that returns "related articles" for that article. We can crib the algorithm for related posts from https://wordpress.org/extend/plugins/yet-another-related-posts-plugin/
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.