Giter Site home page Giter Site logo

snehesht / blog Goto Github PK

View Code? Open in Web Editor NEW
173.0 173.0 7.0 2.2 MB

Minimalist database less blog engine

Home Page: https://snehesh.me

Python 33.99% CSS 35.07% JavaScript 8.11% HTML 21.31% Shell 0.12% Dockerfile 1.39%
blog-engine minimalist-design python

blog's People

Contributors

snehesht avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blog's Issues

500 Error When Non existent url is requested

  • When you go to a non existent url, the application fails like so

image

  • This is because in the finally block below when no url is found data[bp['file']] has no value.
# app/views.py
def blog_post(url_slug):
    data = DS.get_data()
    metadata = DS.get_metadata()
    bp = {}
    try:
        # ISSUE-1a: If below raises an exception
        for item in metadata:
            # Search for metadata of the blogpost with that url
            if item['url'] == url_slug:
                bp = item
    except Exception as e:
        # No such blogpost
        return redirect(url_for('index_page'))
    finally:
        #  ISSUE-1b: 'bp' is still and empty dict  
        raw_content = data[bp['file']]
        processed_content = Markup(markdown.markdown(raw_content))
        return render_template('blog_post.html', content=processed_content,metadata=bp)
  • Here is a proposed solution with future things to look out for
def blog_post(url_slug):
    data = DS.get_data()
    metadata = DS.get_metadata()
    bp = {}

    # Search for metadata of the blogpost with that url
    bp = [item for item in metadata if item['url'] == url_slug]

    if not bp:
        # No such blogpost
        return redirect(url_for('blog_index_page'))
    else:
           # TODO: Decide how to handle multiple blog posts with the same title
           # Idea: During data load/reload, throw an error if duplicate title is found
        bp = bp.pop(0)
        raw_content = data[bp['file']]
        processed_content = Markup(markdown.markdown(raw_content))

        return render_template('post.html', content=processed_content, metadata=bp)

Cleanup non issue

When my account was compromised a spam issue was created in this repo. I sincerely apologize. Cleaning up such issues via script.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.