Skip to content

Commit

Permalink
ui: Add logo as homepage link.
Browse files Browse the repository at this point in the history
The logo is removed from the previous position
besides each chat. It is placed at the top left
corner serving as the link to the homepage.
Fixes zulip#53.
  • Loading branch information
Abhirup-99 committed Apr 8, 2021
1 parent e1a01d3 commit 16b1dce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
35 changes: 13 additions & 22 deletions lib/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,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 +79,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;
}

0 comments on commit 16b1dce

Please sign in to comment.