Generate Markdown Posts in Jekyll and Made Available to Paginator Variable - ruby

Is it possible to generate a set of posts in _posts as Markdown files in a way that they are treated as if they had been manually created and therefore, available to the process of creating the site pagination? I found examples of how to generate pages in various places like this SO question, but they seem to put the rendered content in _site and displaying the {{ paginator.total_pages }} variable does not yield any value.

Yes its possible to add "dynamic" content using a generator plugin.
You can generate pages, posts, collection's items, static files, anything you want.
For the {{ paginator.total_pages }} returning nothing. The paginator variable will only be available in your pagination template and nowhere else.

Related

Passing a YAML frontmatter variable from a page to a collection in Jekyll?

So i have a collection called components. The components are a series of small HTML objects with some data in.
I want to pull these components into a page, and be able to pass overriding YAML frontmatter from the page into the component to determine a couple of things on the component.
Is this possible?
I'm pulling specific components onto a page using the following syntax:
{{ site.components | where:"component_name","event-title" }}
but i'd like to be able to do something like:
{{ site.components var-page-state="offline" | where:"component_name","event-title" }}
I chose to use a collection than a series of includes, as i need to loop through the collection and generate/render an index page of all of the components on it automatically.
EDIT:
So i want my component to be able to output a variable set on the page it's included on.
component.title.html:
<h2 class="title">{{ page.var-page-status }}</h2>

Laravel: How to use composer to inject data across all views?

I want to offload some HTML sections of my site into partials (includes) files rather than repeating the information in each view or layout. However, I also need them to contain specific data. An obvious example is the head section; I would like to put this into a partial, however I also want to be able to set the document title and META fields for each page.
I think the best way is to use Laravel's view-composer
As per the docs, I can use an array to define the composer for multiple views at once:
View::composer(array('view1','view2', 'view3'), function($view)
{
$view->with('count', User::count());
});
However, what if I want to use this composer for every view, as I do in this case?
There's a few answers kicking around SO (such as this one) which suggests I use a wildcard. So here's my code:
View::composer('*', function($view)
{
$view->with('header', View::make('partials.head', $view->getData()));
$view->with('footer', View::make('partials.footer', $view->getData()));
});
Here's the problem: Using this is currently giving me an out of memory error, which suggests that it is very inefficient (and therefore that I really shouldn't be doing this).
So do I really need to pass an array listing every page on my website?
Isn't there a way to use composer for every page rendered, like I can with View::share(); ?
If the data is going to be unique for each view, there's no point in putting it in a view composer; you can do this just by using blade templates, and pass the page-specific data to the view from your controller.
Set up header and footer partials, then set up a base template that uses #include to load your header and footer partials, then a section for your content with #yield('content').
<!DOCTYPE html>
...
#include('partials.header')
#yield('content')
#include('partials.footer')
...
Then your individual page's views would each extend this base template:
#extends('base')
#section('content')
//...specific page content here
#stop
In your header and footer partials, include {{ $someData }} for whatever specific needs to change from page to page, and pass that data to each view from the controller.
This is now possible in Laravel 5.5
Put this is your AppServiceProvider boot method:
View::share('data', [1, 2, 3]);

Jekyll/Octopress: How can I use a tag inside a tag

In Jekyll/Octopress, how can I place the output of a tag inside another tag?
This is what I want to do (using Octopress's img tag):
{% img {% PluginThatOutputsAURL %} %}
If I do that I get this error:
Error processing input, expected syntax: {% img [class name(s)] [http[s]:/]/path/to/image [width [height]] [title text | “title text” [“alt text”]] %} %}
Is it possible to do this? What would be the right syntax to do so?
Jekyll/Octopress uses Liquid Templates to parse these things.
As far as I know, you can't call two functions within a tag like that. You can however specify variable names in tags:
using Liquid variables inside of a liquid tag call
I tried Googling a bit and didn't see anything pop up for calling two functions within one tag.
IMO, I'd recommend creating a custom tag to do exactly what you want. I have created several custom plugins to Octopress because I needed such customization. The plugins, which is just Ruby. is pretty straight forward.
So, copy the existing img_tag.rb and call it, mycustom_img_tag.rb or whatever, and perform your magic within the render() method.
For example, here's my HTML5 audio player tag I wrote where I needed to know what extension the audio file was (specified in the url) in order to specify the content type:
https://github.com/eduncan911/eduncan911.github.io/blob/b89f47cd86c37f2cfb5c3093612fe0a049808325/plugins/audio_tag.rb
^- NOTE: It is incomplete and all the options doesn't work as I specified. You can see what works in the render() section, where I just parse the data-* attributes manually (I ran outta time and just made it work).
I basically used two other plugins as a template and created this one.
You have access to the entire Octopress methods and variables in your plugin - there are no restrictions to the entire code base.

How do I include all documents in the Sphinx globaltoc sidebar?

I would like every single document in the entire TOC to be included in the globaltoc sidebar. How do I achieve this?
In theme files, there are calls to {{ toctree() }}, but I don't know what toctree() refers to.
You can use the sphinxcontrib-fulltoc sphinx extension to include a complete TOC in the side bar.

Wordpress: show comments on separate page

I need to show comments on separate page, on the page itself, so there will be only link to the comment page like www.example.com/my-post/comments (and great would be also to have /my-post/comments/name-of-some-comment for every single comment).
any idea, how can i do it? E.g. some plugin? I have not found anything.
You do not need any plugin. basically you just need to copy either post or page template, which already has both post/page body and comments and then remove everything but the comments.
Check wordpress codex:
Template Tags
Custom Page Templates
Query-based Template Files
Conditional Tags
Most likely you will need to create your own conditional tag, or just check for particular query string (GET) parameter and apply your custom template

Resources