Skip to content

Commit

Permalink
updated css
Browse files Browse the repository at this point in the history
updated html escaping
  • Loading branch information
Mole1424 committed Jul 16, 2023
1 parent 9921626 commit 7d51126
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 57 deletions.
90 changes: 45 additions & 45 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 31 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def wrapper(*args, **kwargs):
return wrapper


limiter = Limiter(
limiter = Limiter( # limits the amount of requests per hour (mainly for logging in page for security)
get_remote_address,
app=app,
default_limits=["50 per hour"],
Expand All @@ -46,6 +46,7 @@ def wrapper(*args, **kwargs):
def home():
projects = Projects.query.all()
return render_template("home.html", homepage=True, projects=projects)
# hompeage is used to determine whether to show the long about me or not


@app.route("/aboutme")
Expand All @@ -64,14 +65,40 @@ def project(project_id):
project = Projects.query.filter_by(id=project_id).first()
if project is None: # protect against invalid project ids which caused 500 errors
return render_template("noproject.html")
markdown_html = markdown(
escape(project.blog)
) # converts markdown to html for blog and escapes to prevent XSS
markdown_html = remove_amp_from_code_tags(
markdown(escape(project.blog))
) # converts markdown to html (escape is used to prevent xss)
return render_template(
"projectpage.html", project=project, markdown_html=markdown_html
)


def remove_amp_from_code_tags(text):
lines = text.splitlines() # Split the text into lines

code_block = False
modified_lines = []

for line in lines:
if "<code>" in line:
code_block = True
modified_lines.append(line)
continue

if "</code>" in line:
code_block = False
modified_lines.append(line)
continue

if code_block:
# Remove "amp;" from code content
line = line.replace("amp;", "")

modified_lines.append(line)

return "\n".join(modified_lines) # Join the lines back together


@app.route("/projects/<int:project_id>/edit")
@login_required
def edit_project(project_id):
Expand Down
17 changes: 9 additions & 8 deletions static/css/projectpage.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.projectarticle {
width: 80vw;
max-width: 80vw;
margin: auto;
}

Expand All @@ -13,8 +13,9 @@
}

.imgtitle img {
height: 30vh;
max-height: 30vh;
width: auto;
max-width: 30vw;
border-radius: 10px;
}

Expand Down Expand Up @@ -42,15 +43,17 @@

.fullblog img {
max-height: 25vh;
width: auto;
max-width: 100%;
border-radius: 10px;
}

.fullblog pre {
display: inline-block;
max-width: 100%;
background-color: var(--background2);
border-radius: 10px;
padding: 1vh 1vw;
overflow: scroll;
}

.fullblog code {
Expand All @@ -59,7 +62,6 @@

@media screen and (max-width: 500px) {
.projectarticle {
width: 90vw;
padding-top: 10vh;
}

Expand All @@ -68,18 +70,17 @@
}

.imgtitle img {
height: 20vh;
max-height: 20vh;
max-width: 100%;
}

.description {
width: 90vw;
width: 100%;
padding-top: 2vh;
padding-left: none;
}

.description h1 {
margin-top: 0;
font-size: 5vh;
width: 90vw;
}
}

0 comments on commit 7d51126

Please sign in to comment.