pretzel icon indicating copy to clipboard operation
pretzel copied to clipboard

Bookmarklet to swap between GitHub Pages and local pretzel instance

Open idvorkin opened this issue 10 years ago • 8 comments

I love pretzel, it's a great way to use static blogs on windows - THANK YOU for creating it!

I'm not sure if this is helpful to others, if it is, I'm not sure where to stick it, so creating an issue to have the discussion.

For reasons I don't yet understand, navigation works better in my GitHub pages (GHP) blog, then in my pretzel blog. Thus I navigate on GitHub Pages and then swap the URL to my local instance. I do this using the below code converted to a bookmarklet. Lastest code as gist :

function swapLocalRemoteBlog() { 
    /*
     * Pretzel renders, but doesn't navigate the same as github pages (GHP).
     *  Thus use GHP to navigate, then use this bookmarklet to swap with local pretzel blog.
     */
    var currentUrl = document.URL;
    var errorMessage = "Only works on Igor's Blog"; 
    var githubBlogURL =  "http://idvorkin.github.io";
    var localPretzelBlogUrl =  "http://localhost:8080";
    var newUrl = "";
    if (currentUrl.startsWith(githubBlogURL)) {
        newUrl = currentUrl.replace(githubBlogURL,localPretzelBlogUrl);
        /*pretzel can't have a trailing slash - Issue 289, so remove it*/
        newUrl = newUrl.substr(0, newUrl.length-1)
    } else if (currentUrl.startsWith(localPretzelBlogUrl)) {
        newUrl = currentUrl.replace(localPretzelBlogUrl,githubBlogURL);
    } else {
        alert(errorMessage);
        return;
    }
    window.location = newUrl;
};
swapLocalRemoteBlog();
void(0);

idvorkin avatar Dec 25 '15 15:12 idvorkin

In what way does pagination not work with Pretzel? It works fine on my site.

thoemmi avatar Dec 26 '15 17:12 thoemmi

RE: Pagination, I wasn't clear:

Several things aren't working locally on my site. Some of those things are certainly my fault, :) Others I'm logging bugs for as I debug them (e.g #289).

If you clone and run my site locally, you'll see no posts showing up on the main page, even though it works fine on GitHub pages. I assumed the problem was pagination, but it's quite possibly another issue.

I'll update the description in this issue, and log bugs for the other issues as I debug more.

idvorkin avatar Dec 27 '15 00:12 idvorkin

Thanks! :smile: Pretzel was created years ago but since there are only few people who are still maintaining it, so we are far from having all features of Jekyll. And sadly I can't promess you that one day it will. But we can still have a minimum of working stuff. :smiley:

What version of pretzel have you tried? Builded from the source or from chocolatey?

laedit avatar Dec 28 '15 11:12 laedit

I'm grateful for chocolatey even if you never make a single improvement :) Having single page rendering is very valuable for me, as it lets me write/edit/debug my styling/posts on windows, and only fire up a linux vm when I'm messing with pagination or complex navigation goop.

I use chocolatey today, but I can build from source if you recommend that.

idvorkin avatar Dec 28 '15 14:12 idvorkin

@idvorkin RE: pagination: you have to specify paginate: 5 in the frontmatter of your file. I cloned your repository, added paginate: 5 to index.html, and it worked.

thoemmi avatar Dec 28 '15 17:12 thoemmi

@thoemmi - Huge thanks for making the effort -- that was incredibly helpful. Is there something obvious to fix tags as well?

From:

http://localhost:8080/tags/

failed

idvorkin avatar Dec 28 '15 20:12 idvorkin

If you use the Chocolatey version please specify the version 0.3.0 when you install pretzel, it's the last version but hasn't been validated by chocolatey moderators yet.

laedit avatar Dec 28 '15 22:12 laedit

The version 0.3.0 has just been validated, you only need to do:

cup pretzel

laedit avatar Dec 29 '15 10:12 laedit