Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logo: Use logo as the homepage link. #59

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions assets/img/zulip.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 18 additions & 24 deletions lib/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ def topic_page_links(
topic_url = archive_topic_url(site_url, html_root, sanitized_stream_name, sanitized_topic_name)

return f'''\
<h2>Stream: <a href="{stream_url}">{stream_name}</a></h2>
<h3>Topic: <a href="{topic_url}">{topic_name}</a></h3>
<h2>
<a href="{stream_url}">{stream_name}</a>
>
<a href="{topic_url}">{topic_name}</a>
</h2>

<hr>

Expand All @@ -58,9 +61,8 @@ def format_message(
):
msg_id = str(msg['id'])

zulip_link = link_to_zulip(
post_link = zulip_post_url(
zulip_url,
zulip_icon_url,
stream_id,
stream_name,
topic_name,
Expand All @@ -80,32 +82,24 @@ def format_message(
anchor = '<a name="{0}"></a>'.format(msg_id)
html = f'''
{anchor}
<h4>{zulip_link} {user_name} <a href="{anchor_url}">({date})</a>:</h4>
<h4>
{user_name}
(<a href="{post_link}" target="_blank">{date}</a>
<a href="{anchor_url}" class="archive-link-color"> | Archive</a>):
</h4>
{msg_content}
'''
return html


def link_to_zulip(
zulip_url,
zulip_icon_url,
stream_id,
stream_name,
topic_name,
msg_id,
):
# format a link to the original post where you click on the Zulip icon
# (if it's available)
post_link = zulip_post_url(zulip_url, stream_id, stream_name, topic_name, msg_id)
if zulip_icon_url:
img_tag = f'<img src="{zulip_icon_url}" alt="view this post on Zulip" style="width:20px;height:20px;">'
else:
img_tag = ''
zulip_link = f'<a href="{post_link}" class="zl">{img_tag}</a>'
return zulip_link

def last_updated_footer(stream_info):
last_updated = format_date1(stream_info['time'])
date_footer = f'\n<hr><p>Last updated: {last_updated} UTC</p>'
return date_footer

def homepage_link(site_url, zulip_icon_url):
if zulip_icon_url:
img_tag = f'<img src="{zulip_icon_url}" alt="homepage" style="height: 30px;max-width: 200px;">'
else:
img_tag = ''
homepage_url = f'<a href="{site_url}/archive/">{img_tag}</a>'
return homepage_url
12 changes: 8 additions & 4 deletions lib/jekyll.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

from .html import (
format_message,
homepage_link,
last_updated_footer,
topic_page_links,
)
Expand All @@ -58,7 +59,7 @@ def build_website(json_root, md_root, site_url, html_root, title, zulip_url, zul

streams = stream_info['streams']
date_footer = last_updated_footer(stream_info)
write_main_page(md_root, site_url, html_root, title, streams, date_footer)
write_main_page(md_root, site_url, html_root, title, streams, date_footer, zulip_icon_url)
write_css(md_root)

for stream_name in streams:
Expand All @@ -74,6 +75,7 @@ def build_website(json_root, md_root, site_url, html_root, title, zulip_url, zul
stream_name,
stream_data,
date_footer,
zulip_icon_url
)

for topic_name in topic_data:
Expand All @@ -94,7 +96,7 @@ def build_website(json_root, md_root, site_url, html_root, title, zulip_url, zul

# writes the index page listing all streams.
# `streams`: a dict mapping stream names to stream json objects as described in the header.
def write_main_page(md_root, site_url, html_root, title, streams, date_footer):
def write_main_page(md_root, site_url, html_root, title, streams, date_footer, zulip_icon_url):
'''
The main page in our website lists streams:

Expand All @@ -108,12 +110,12 @@ def write_main_page(md_root, site_url, html_root, title, streams, date_footer):
write_main_page_header(outfile, html_root, title)

content = stream_list_page(streams)

outfile.write(f'\n{homepage_link(site_url, zulip_icon_url)}\n')
outfile.write(content)
outfile.write(date_footer)
outfile.close()

def write_stream_topics(md_root, site_url, html_root, title, stream_name, stream, date_footer):
def write_stream_topics(md_root, site_url, html_root, title, stream_name, stream, date_footer, zulip_icon_url):
'''
A stream page lists all topics for the stream:

Expand All @@ -135,6 +137,7 @@ def write_stream_topics(md_root, site_url, html_root, title, stream_name, stream

content = topic_list_page(stream_name, stream_url, topic_data)

outfile.write(f'\n{homepage_link(site_url, zulip_icon_url)}\n')
outfile.write(content)
outfile.write(date_footer)
outfile.close()
Expand Down Expand Up @@ -203,6 +206,7 @@ def write_topic_messages(
topic_name,
)

outfile.write(f'\n{homepage_link(site_url, zulip_icon_url)}\n')
outfile.write(topic_links)
outfile.write(f'\n<head><link href="{site_url}/style.css" rel="stylesheet"></head>\n')

Expand Down
5 changes: 5 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
.msg { margin-left: 2em; }

.archive-link-color{
color: grey;
text-decoration: none;
}