Skip to content
Snippets Groups Projects
Commit 9018df3f authored by Aishik Nath's avatar Aishik Nath
Browse files

Merge branch 'krishna' into 'main'

Blog Ready

See merge request !2
parents a84e21d6 c99a15b1
No related branches found
No related tags found
2 merge requests!2Blog Ready,!1Krishna
Pipeline #415074 failed
from os import path
from pathlib import Path
from flask import Flask, render_template
from flask_frozen import Freezer
template_folder = path.abspath('./wiki')
app = Flask(__name__, template_folder=template_folder)
#app.config['FREEZER_BASE_URL'] = environ.get('CI_PAGES_URL')
app.config['FREEZER_DESTINATION'] = 'public'
app.config['FREEZER_RELATIVE_URLS'] = True
app.config['FREEZER_IGNORE_MIMETYPE_WARNINGS'] = True
freezer = Freezer(app)
@app.cli.command()
def freeze():
freezer.freeze()
@app.cli.command()
def serve():
freezer.run()
@app.route('/')
def home():
return render_template('pages/home.html')
@app.route('/<page>')
def pages(page):
return render_template(str(Path('pages')) + '/' + page.lower() + '.html')
# Main Function, Runs at http://0.0.0.0:8080
if __name__ == "__main__":
app.run(port=8080)
from os import path, walk, getcwd
from pathlib import Path
import markdown2
from flask import Flask, render_template
from flask_frozen import Freezer
template_folder = path.abspath('./wiki')
app = Flask(__name__, template_folder=template_folder)
#app.config['FREEZER_BASE_URL'] = environ.get('CI_PAGES_URL')
app.config['FREEZER_DESTINATION'] = 'public'
app.config['FREEZER_RELATIVE_URLS'] = True
app.config['FREEZER_IGNORE_MIMETYPE_WARNINGS'] = True
freezer = Freezer(app)
@app.cli.command()
def freeze():
freezer.freeze()
@app.cli.command()
def serve():
freezer.run()
@app.route('/')
def home():
return render_template('pages/home.html')
def listblogs():
filenames = next(walk('./wiki/blogs/'), (None, None, []))[2]
bloglist = {}
for filename in filenames:
with open(f'./wiki/blogs/{filename}', 'r') as file:
bloglist[filename]= markdown2.markdown(file.read(), extras=[
"metadata",
]).metadata
return bloglist
@app.route('/blogs')
def blogs():
return render_template(str(Path('pages')) + '/' + 'bloglist.html', bloglist=listblogs())
def readblog(blog):
try:
with open(f'./wiki/blogs/{blog}', 'r') as file:
return markdown2.markdown(file.read(), extras=["code-friendly",
"fenced-code-blocks",
"tables", "wiki-tables",
"strike",
"footnotes",
"break-on-backslash",
"metadata",
"target-blank-links",
"numbering",
"tag-friendly",
"cuddled-lists",])
except FileNotFoundError:
return 'Blog Not Found'
@app.route('/blogs/<blog>')
def blog(blog):
return render_template(str(Path('pages')) + '/' + 'blog.html', blog=readblog(blog))
@app.route('/<page>')
def pages(page):
return render_template(str(Path('pages')) + '/' + page.lower() + '.html')
# Main Function, Runs at http://0.0.0.0:8080
if __name__ == "__main__":
app.run(port=8080)
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
.card-body{
/*grey background with opacity 0.2*/
background-color: rgba(128, 128, 128, 0.2);
border: none;
border-radius: 10px;
/*fit page with equal left and right margins*/
margin-bottom: 2%;
margin-right: 0%;
}
.card-mb-4{
border: none;
}
.card-title, .card-text, .blog-text{
color: black;
margin-right: 0%;
}
\ No newline at end of file
......@@ -25,7 +25,8 @@
<div class="container h-100">
<div class="row h-100 align-items-center">
<div class="col-lg-12">
<h1 class="display-4 text-white mt-5 mb-2">{{ self.title() }}</h1>
{% block backlink %}{% endblock %}
<h1 class="display-4 text-white mt-3 mb-2">{{ self.title() }}</h1>
<p class="lead mb-5 text-white-50">{% block lead %}{% endblock %}</p>
</div>
</div>
......
......@@ -16,6 +16,10 @@
<li class="nav-item">
<a class="nav-link" href="{{ url_for('home') }}">Home</a>
</li>
<!---- BLOG ---->
<li class="nav-item">
<a class="nav-link" href="{{ url_for('blogs') }}">Blogs</a>
</li>
<!---- TEAM ---->
<li class="nav-item dropdown">
......
{% extends "layout.html" %}
{% block title %}{{ blog.metadata['title'] }}{% endblock %}
{% block lead %}~ {{ blog.metadata['author'] }} | {{ blog.metadata['date'] }}{% endblock %}
{% block backlink %}<a href="{{ url_for('blogs') }}" class="text-white">Back to Blog List</a>{% endblock %}
{% block page_content %}
<link href="{{ url_for('static', filename = 'blog.css') }}" rel="stylesheet">
<p class="blog-text">{{ blog|safe }}</p>
{% endblock %}
{% extends "layout.html" %}
{% block title %}Blogs{% endblock %}
{% block lead %}Document the dates you worked on your project. This should be a detailed account of the work done each day for your project.{% endblock %}
{% block page_content %}
<link href="{{ url_for('static', filename = 'blog.css') }}" rel="stylesheet">
<div class="d-flex gap-3">
{% for blog in bloglist: %}
<div class="card-mb-4 col-3">
<div class="card-body">
<h5 class="card-title">{{ bloglist[blog]['title'] }}</h5>
<p class="card-text">{{ bloglist[blog]['author'] }}</p>
<a class="btn btn-primary" href="{{ url_for('blog', blog=blog) }}">Read</a>
</div>
</div>
{% endfor %}
</div>
{% endblock %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment