Skip to content

Commit

Permalink
Adds Favicon support
Browse files Browse the repository at this point in the history
Introduces a new optional config option FAVICON. The option points to
an icon present in STATIC_DIR and will be used as a favicon for the
HTML page.
  • Loading branch information
joehakimrahme committed May 28, 2020
1 parent 23a16ba commit 08d66f1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion blogstrap/blogstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class DefaultConfig(object):
BLOGTITLE = "Powered by Blogstrap"
DEFAULT_LANG = "en"
NAVBAR_LINKS = []
STATIC_DIR = "images"
TOC_BLACKLIST = []


Expand All @@ -80,7 +81,7 @@ def create_app(config_file=None):
app.config.from_pyfile(config_file)

# default static files directory
staticdir = app.config.get('STATIC_DIR', 'images')
staticdir = app.config.get('STATIC_DIR')

def _render(template, message=None):
ctx = context.context(app, message)
Expand Down
1 change: 1 addition & 0 deletions blogstrap/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# NAVBAR_LINKS = {} # key:value map of links to include in the Navbar.
# TOC_BLACKLIST = [] # Exclude these pages from the TOC
# STATIC_DIR = "images"
# FAVICON = "favicon.ico" # Located in the STATIC_DIR
"""

HOMEPAGE_TEMPLATE = """# This page will be displayed at the blog root
Expand Down
3 changes: 3 additions & 0 deletions blogstrap/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ def toc():
"description": app.config['DESCRIPTION'],
"lang": app.config['DEFAULT_LANG'],
"navbar_links": app.config['NAVBAR_LINKS'],
"static_dir": app.config['STATIC_DIR'],
"title": app.config['BLOGTITLE'],
"toc": toc()
}
if message:
context_dict['text'] = message['content']
context_dict.update(message['metadata'])
if app.config.get("FAVICON"):
context_dict["favicon"] = app.config["FAVICON"]
return context_dict
3 changes: 3 additions & 0 deletions blogstrap/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<meta property="og:url" content="" />
<meta property="og:description" content="{{ description }}" />
<title>{{ title }}</title>
{% if favicon %}
<link rel="icon" href="{{ static_dir }}/{{ favicon }}" type="image/x-icon">
{% endif %}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="{{ url_for('static', filename='blogstrap.css') }}">
</head>
Expand Down

0 comments on commit 08d66f1

Please sign in to comment.