Skip to content

Commit

Permalink
Feature front article content creation (#91)
Browse files Browse the repository at this point in the history
* Branching for Articles

Branching off develop to create article content

* Delete articleTemplate_Savings.html

deleted a file i accidentally created

* article html

reset my duplcation of the article html

* Dynamically generated articles

I created a json document to store different articles so I can iterate through them for the different article links. Altered the articleTemplate.html to dynamically insert various paragraphs and quotes. The news.html href's was changed to link to the article sites id's. Finally in app.py I imported the json module. changed the Article template route to accept article id's. It gets the current directory and constructs the path than reads the JSON data than finds a particular id. Than renders the article template

* Update article.json

Added the content for 5 money savings tips

* Delete transactions_ut.db

---------

Co-authored-by: ShaneD <[email protected]>
  • Loading branch information
washyking and SDzartov authored Nov 22, 2023
1 parent b7709df commit 0c0016d
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 74 deletions.
17 changes: 12 additions & 5 deletions neo_dolfin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import plotly.graph_objects as go
from services.basiq_service import BasiqService
from io import StringIO
import json


load_dotenv() # Load environment variables from .env
from classes import *
Expand Down Expand Up @@ -421,11 +423,16 @@ def open_terms_of_use():
def open_terms_of_use_AI():
return render_template("TermsofUse-AI.html")

# APPLICATION Article Template PAGE
@app.route('/articleTemplate/')
def open_article_template():
return render_template("articleTemplate.html")

# APPLICATION ARTICLE TEMPLATE ROUTING
@app.route('/articleTemplate/<int:article_id>')
def open_article_template(article_id):
current_dir = os.path.dirname(os.path.abspath(__file__))
json_path = os.path.join(current_dir, 'static', 'json', 'article.json')
with open(json_path) as json_file:
articles_data = json.load(json_file)
article = next((article for article in articles_data if article['id'] == article_id), None)
return render_template('articleTemplate.html', articles=[article])

# APPLICATION USER SPECIFIC PROFILE PAGE
@app.route('/profile')
def profile():
Expand Down
35 changes: 35 additions & 0 deletions neo_dolfin/static/json/article.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[
{
"id": 1,
"title": "Unravelling Common Bad Saving Habits",
"date": "25/09/2023",
"content1": " When it comes to financial stability, the road is often obstructed by common bad saving habits that many individuals unknowingly develop. One pervasive issue is the absence of a well-structured budget. Without a clear understanding of income, expenses, and financial goals, people risk spending impulsively and struggling to allocate funds for savings. As financial guru Dave Ramsey wisely notes, 'A budget is telling your money where to go instead of wondering where it went.' Establishing and adhering to a budget is foundational to fostering successful saving habits, helping individuals take control of their financial destinies.",
"content2": " Procrastination emerges as another significant hurdle on the path to financial security. Delaying the initiation of a savings plan deprives individuals of the compounding power that accelerates wealth accumulation. Embracing the proverbial wisdom that 'The best time to plant a tree was 20 years ago. The second-best time is now,' is crucial. Overcoming the bad habit of procrastination requires a proactive approach, urging individuals to start saving immediately to maximise the benefits of compound interest over time.",
"content3": " A detrimental habit that can lead to financial turmoil is reliance on credit to sustain a lifestyle beyond one's means. Excessive use of credit cards and the accumulation of high-interest debt create a cycle that is challenging to break. Financial expert Suze Orman offers valuable advice, stating, 'A big part of financial freedom is having your heart and mind free from worry about the what-ifs of life.' Escaping the clutches of credit dependency involves developing a realistic budget, cutting unnecessary expenses, and diligently working to pay down outstanding debts.",
"content4": " Finally, failing to establish an emergency fund is a common pitfall that leaves individuals vulnerable to unforeseen financial challenges. Without a financial safety net, unexpected expenses can lead to debt and disrupt long-term savings goals. As Warren Buffett wisely notes, 'The most important investment you can make is in yourself.' Creating an emergency fund provides a cushion, allowing individuals to navigate financial uncertainties without compromising their overall stability. In unravelling these common bad saving habits, individuals can pave the way for a more secure and prosperous financial future.",
"quote1": "The most important investment ",
"quote2": "you can make is in yourself."
},
{
"id": 2,
"title": "Article 2",
"date": "02/15/2023",
"content1": "Another article...",
"content2": "More content...",
"content3": "Even more content...",
"content4": "Final content...",
"quote1": "Quote-first half",
"quote2": "Quote-second half.."
},
{
"id": 3,
"title": "Article 3",
"date": "09/15/2024",
"content1": "Another article...",
"content2": "More content...",
"content3": "Even more content...",
"content4": "Final content...",
"quote1": "Quote-first half",
"quote2": "Quote-second half.."
}
]
112 changes: 49 additions & 63 deletions neo_dolfin/templates/articleTemplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,75 +2,61 @@
<html lang="en">

<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>DolFin - Article</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="{{url_for('static', filename='css/main.css')}}" rel="stylesheet" type="text/css">
<link href="{{url_for('static', filename='css/articles.css')}}" rel="stylesheet" type="text/css">
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1" name="viewport">
<title>DolFin - Article</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
<link href="{{url_for('static', filename='css/main.css')}}" rel="stylesheet" type="text/css">
<link href="{{url_for('static', filename='css/articles.css')}}" rel="stylesheet" type="text/css">
</head>

<body>

{% include 'components/navbar.html' %}
{% include 'components/navbar.html' %}

{% for article in articles %}
<div class="container" id="mainTitleArea">
<div class="row">
<div class="col">
<h1 id="articleTitle">{{ article.title }}</h1>
</div>
<div class="col-sm-6 text-sm-start text-md-end">
<h2 id="articleDate">{{ article.date }}</h2>
</div>
</div>
<svg height="12" id="articleBreak" width="100%" xmlns="http://www.w3.org/2000/svg">
<rect fill="#343A40" height="12" width="100%"></rect>
</svg>
</div>
<div class="container" id="firstSection">
<div class="row">
<div class="col">

<p id="p1">{{ article.content1 }}</p>
</div>
<div class="col-md-6">
<p id="p2">{{ article.content2 }}</p>
</div>
</div>
<div class="container" id="secondSection">
<div class="row">
<div class="col-md-6 text-sm-start" id="quoteBackground">

<h3 id="quoteText">"{{ article.quote1 }},</h3>
<h3 id="quoteText2">{{ article.quote2 }}..."</h3>
</div>
<div class="col">
<p id="p3">{{ article.content3 }}</p>
</div>
</div>
<p id="p4">{{ article.content4 }}</p>
</div>
</div>
{% endfor %}

<div>
<div class="container" id="mainTitleArea">
<div class="row">
<div class="col">
<h1 id="articleTitle">Article Title</h1>
</div>
<div class="col-sm-6 text-sm-start text-md-end">
<h2 id="articleDate">01/09/2023</h2>
</div>
</div>
<svg height="12" id="articleBreak" width="100%" xmlns="http://www.w3.org/2000/svg">
<rect fill="#343A40" height="12" width="100%"></rect>
</svg>
</div>
<div class="container" id="firstSection">
<div class="row">
<div class="col">
<p id="p1">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur purus velit, mattis
faucibus risus at, porta aliquet elit. Suspendisse mollis nulla dolor, nec eleifend urna
malesuada sit amet. Sed vel elit dui. Curabitur fermentum, mi id porta rutrum, justo leo gravida
ipsum, at maximus elit ante nec tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Curabitur purus velit.</p>
</div>
<div class="col-md-6"><img alt="Placeholder Image" id="articleImg" src="/static/img/fillerSquare.jpg">
</div>
</div>
<div>
<p id="p2">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur purus velit, mattis
faucibus risus at, porta aliquet elit. Suspendisse mollis nulla dolor, nec eleifend urna malesuada
sit amet. Sed vel elit dui. Curabitur fermentum, mi id porta rutrum, justo leo gravida ipsum, at
maximus elit ante nec tortor.</p>
<div class="container" id="secondSection">
<div class="row">
<div class="col-md-6 text-sm-start" id="quoteBackground">
<h3 id="quoteText">"Lorem ipsim dolor sit amet,</h3>
<h3 id="quoteText2">consectetur adipiscing elit..."</h3>
</div>
<div class="col">
<p id="p3">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur purus velit,
mattis faucibus risus at, porta aliquet elit. Suspendisse mollis nulla dolor, nec
eleifend urna malesuada sit amet. Sed vel elit dui. Curabitur fermentum, mi id porta
rutrum, justo leo gravida ipsum, at maximus elit ante nec tortor. Lorem ipsum dolor sit
amet, consectetur adipiscing elit. Curabitur purus velit , mattis faucibus risus at,
porta aliquet elit.</p>
</div>
</div>
<p id="p4">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur purus velit, mattis
faucibus risus at, porta aliquet elit. Suspendisse mollis nulla dolor, nec eleifend urna
malesuada sit amet. Sed vel elit dui. Curabitur fermentum, mi id porta rutrum, justo leo gravida
ipsum, at maximus elit ante nec tortor.</p>
</div>
</div>
</div>{% include 'components/footer.html' %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
{% include 'components/footer.html' %}
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>

</div>
</body>

</html>
</html>
12 changes: 6 additions & 6 deletions neo_dolfin/templates/news.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h1 id="headerTitle" class="display-1 text-center ">Latest News</h1>
<div class="col-sm">
<div class="card border-0 shadow hide-card-default" style="width: 22rem;" data-category="sept">

<a id="articleLink" href="/articleTemplate/">
<a id="articleLink" href="/articleTemplate/1">
<div class="ratio ratio-16x9">
<img class="card-img-top rounded-top img-fluid" src="/static/img/article1_cover.jpg"
alt="https://images.unsplash.com/photo-1553729459-efe14ef6055d">
Expand All @@ -71,7 +71,7 @@ <h5 id="articleTitle" class="card-title">Top 5 common bad saving habits</h5>
<div class="container">
<div class="row mb-2">
<div class="col-6 ps-0">
<a id="readButton" href="/articleTemplate/" class="btn btn-primary">Read more</a>
<a id="readButton" href="/articleTemplate/1" class="btn btn-primary">Read more</a>
</div>
<div class="col-6 pt-2 text-end pe-3">
<p class="h5">10/10/23</p>
Expand All @@ -82,7 +82,7 @@ <h5 id="articleTitle" class="card-title">Top 5 common bad saving habits</h5>
</a>
</div>
<div class="card border-0 shadow hide-card-default" style="width: 22rem;" data-category="july">
<a id="articleLink" href="/articleTemplate/">
<a id="articleLink" href="/articleTemplate/3">
<div class="ratio ratio-16x9">
<img class="card-img-top rounded-top" src="/static/img/article2_cover.jpg"
alt="https://images.unsplash.com/photo-1481223014211-199b3e8f0002">
Expand All @@ -103,7 +103,7 @@ <h5 id="articleTitle" class="card-title card-title-text-custom-truncate">What is
<div class="container">
<div class="row mb-2">
<div class="col-6 ps-0">
<a id="readButton" href="/articleTemplate/" class="btn btn-primary">Read more</a>
<a id="readButton" href="/articleTemplate/3" class="btn btn-primary">Read more</a>
</div>
<div class="col-6 pt-2 text-end pe-3">
<p class="h5">25/06/23</p>
Expand All @@ -116,7 +116,7 @@ <h5 id="articleTitle" class="card-title card-title-text-custom-truncate">What is
</div>
<div class="col-sm">
<div class="card border-0 shadow hide-card-default" data-category="sept" style="width: 22rem;">
<a id="articleLink" href="/articleTemplate/">
<a id="articleLink" href="/articleTemplate/2">
<div class="ratio ratio-16x9">
<img class="card-img-top rounded-top" src="/static/img/article3_cover.jpg"
alt="https://plus.unsplash.com/premium_photo-1676637656277-498f73258bec">
Expand All @@ -136,7 +136,7 @@ <h5 id="articleTitle" class="card-title card-title-text-custom-truncate">Learn w
<div class="container">
<div class="row mb-2">
<div class="col-6 ps-0">
<a id="readButton" href="/articleTemplate/" class="btn btn-primary">Read more</a>
<a id="readButton" href="/articleTemplate/2" class="btn btn-primary">Read more</a>
</div>
<div class="col-6 pt-2 text-end pe-3">
<p class="h5">08/10/23</p>
Expand Down
Binary file removed neo_dolfin/transactions_ut.db
Binary file not shown.

0 comments on commit 0c0016d

Please sign in to comment.