Skip to content

Commit 16b1dce

Browse files
committed
ui: Add logo as homepage link.
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 #53.
1 parent e1a01d3 commit 16b1dce

File tree

3 files changed

+26
-26
lines changed

3 files changed

+26
-26
lines changed

lib/html.py

+13-22
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,8 @@ def format_message(
5858
):
5959
msg_id = str(msg['id'])
6060

61-
zulip_link = link_to_zulip(
61+
post_link = zulip_post_url(
6262
zulip_url,
63-
zulip_icon_url,
6463
stream_id,
6564
stream_name,
6665
topic_name,
@@ -80,32 +79,24 @@ def format_message(
8079
anchor = '<a name="{0}"></a>'.format(msg_id)
8180
html = f'''
8281
{anchor}
83-
<h4>{zulip_link} {user_name} <a href="{anchor_url}">({date})</a>:</h4>
82+
<h4>
83+
{user_name}
84+
(<a href="{post_link}" target="_blank">{date}</a>
85+
<a href="{anchor_url}" class="archive-link-color"> | Archive</a>):
86+
</h4>
8487
{msg_content}
8588
'''
8689
return html
8790

88-
89-
def link_to_zulip(
90-
zulip_url,
91-
zulip_icon_url,
92-
stream_id,
93-
stream_name,
94-
topic_name,
95-
msg_id,
96-
):
97-
# format a link to the original post where you click on the Zulip icon
98-
# (if it's available)
99-
post_link = zulip_post_url(zulip_url, stream_id, stream_name, topic_name, msg_id)
100-
if zulip_icon_url:
101-
img_tag = f'<img src="{zulip_icon_url}" alt="view this post on Zulip" style="width:20px;height:20px;">'
102-
else:
103-
img_tag = ''
104-
zulip_link = f'<a href="{post_link}" class="zl">{img_tag}</a>'
105-
return zulip_link
106-
10791
def last_updated_footer(stream_info):
10892
last_updated = format_date1(stream_info['time'])
10993
date_footer = f'\n<hr><p>Last updated: {last_updated} UTC</p>'
11094
return date_footer
11195

96+
def homepage_link(site_url, zulip_icon_url):
97+
if zulip_icon_url:
98+
img_tag = f'<img src="{zulip_icon_url}" alt="homepage" style="height: 30px;max-width: 200px;">'
99+
else:
100+
img_tag = ''
101+
homepage_url = f'<a href="{site_url}/archive/">{img_tag}</a>'
102+
return homepage_url

lib/jekyll.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
from .html import (
4242
format_message,
43+
homepage_link,
4344
last_updated_footer,
4445
topic_page_links,
4546
)
@@ -58,7 +59,7 @@ def build_website(json_root, md_root, site_url, html_root, title, zulip_url, zul
5859

5960
streams = stream_info['streams']
6061
date_footer = last_updated_footer(stream_info)
61-
write_main_page(md_root, site_url, html_root, title, streams, date_footer)
62+
write_main_page(md_root, site_url, html_root, title, streams, date_footer, zulip_icon_url)
6263
write_css(md_root)
6364

6465
for stream_name in streams:
@@ -74,6 +75,7 @@ def build_website(json_root, md_root, site_url, html_root, title, zulip_url, zul
7475
stream_name,
7576
stream_data,
7677
date_footer,
78+
zulip_icon_url
7779
)
7880

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

9597
# writes the index page listing all streams.
9698
# `streams`: a dict mapping stream names to stream json objects as described in the header.
97-
def write_main_page(md_root, site_url, html_root, title, streams, date_footer):
99+
def write_main_page(md_root, site_url, html_root, title, streams, date_footer, zulip_icon_url):
98100
'''
99101
The main page in our website lists streams:
100102
@@ -108,12 +110,12 @@ def write_main_page(md_root, site_url, html_root, title, streams, date_footer):
108110
write_main_page_header(outfile, html_root, title)
109111

110112
content = stream_list_page(streams)
111-
113+
outfile.write(f'\n{homepage_link(site_url, zulip_icon_url)}\n')
112114
outfile.write(content)
113115
outfile.write(date_footer)
114116
outfile.close()
115117

116-
def write_stream_topics(md_root, site_url, html_root, title, stream_name, stream, date_footer):
118+
def write_stream_topics(md_root, site_url, html_root, title, stream_name, stream, date_footer, zulip_icon_url):
117119
'''
118120
A stream page lists all topics for the stream:
119121
@@ -135,6 +137,7 @@ def write_stream_topics(md_root, site_url, html_root, title, stream_name, stream
135137

136138
content = topic_list_page(stream_name, stream_url, topic_data)
137139

140+
outfile.write(f'\n{homepage_link(site_url, zulip_icon_url)}\n')
138141
outfile.write(content)
139142
outfile.write(date_footer)
140143
outfile.close()
@@ -203,6 +206,7 @@ def write_topic_messages(
203206
topic_name,
204207
)
205208

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

style.css

+5
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
11
.msg { margin-left: 2em; }
2+
3+
.archive-link-color{
4+
color: grey;
5+
text-decoration: none;
6+
}

0 commit comments

Comments
 (0)