镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content
This repository was archived by the owner on Jun 25, 2020. It is now read-only.
This repository was archived by the owner on Jun 25, 2020. It is now read-only.

Bookmarklet to swap between GitHub Pages and local pretzel instance #290

Open

Description

@idvorkin

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);

Activity

  1. thoemmi commented on Dec 26, 2015

    @thoemmi
    Contributor

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

  2. idvorkin commented on Dec 27, 2015

    @idvorkin
    Author

    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.

  3. laedit commented on Dec 28, 2015

    @laedit
    Contributor

    Thanks! 😄
    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. 😃

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

  4. idvorkin commented on Dec 28, 2015

    @idvorkin
    Author

    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.

  5. thoemmi commented on Dec 28, 2015

    @thoemmi
    Contributor

    @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.

  6. idvorkin commented on Dec 28, 2015

    @idvorkin
    Author

    @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

  7. laedit commented on Dec 28, 2015

    @laedit
    Contributor

    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.

  8. laedit commented on Dec 29, 2015

    @laedit
    Contributor

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

    cup pretzel
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions