Skip to content

Commit a313b86

Browse files
committed
Expand the resources displayed in the announcement
1 parent d7a5be3 commit a313b86

File tree

1 file changed

+45
-7
lines changed

1 file changed

+45
-7
lines changed

appstore/discourse.py

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@
55
from .discord import random_party_emoji
66
from .utils import get_app_description, generate_image_url
77

8+
PLATFORM_EMOJI = {
9+
'aplite': ':pebble-orange:',
10+
'basalt': ':pebble-time-red:',
11+
'chalk': 'pebble-time-round-14-rainbow',
12+
'diorite': 'pebble-2-aqua',
13+
'emery': 'core-time-2-red',
14+
'flint': 'core-2-duo-black'
15+
}
16+
817
if config['DISCOURSE_API_KEY'] is None:
918
_client = None
1019
else:
@@ -46,11 +55,38 @@ def _create_or_post_to_topic(app, is_generated, text):
4655
else:
4756
_client.create_post(text, category_id=config['DISCOURSE_SHOWCASE_TOPIC_ID'], topic_id=app.discourse_topic_id)
4857

58+
def banner(app):
59+
asset_collections = app.asset_collections
60+
for platform in asset_collections:
61+
banner = asset_collections[platform].banner
62+
if banner:
63+
return f"![App banner]({generate_image_url(banner)})"
64+
return ''
65+
66+
def screenshot_section(app):
67+
asset_collections = app.asset_collections
68+
output = ''
69+
# TODO: Make the order here more intentional
70+
for index, platform in enumerate(asset_collections):
71+
if len(asset_collections[platform].screenshots) > 0:
72+
screenshots = asset_collections[platform].screenshots
73+
output += f"### {PLATFORM_EMOJI[platform]} {platform.title()} screenshots:\n\n"
74+
if index != 0:
75+
output += '[details="Expand"]'
76+
output += f"|{''.join(['|' for screenshot in screenshots])}\n"
77+
output += f"|{''.join(['-|' for screenshot in screenshots])}\n"
78+
screenshot_section = ''.join([f"![Screenshot {s_index}]({generate_image_url(screenshot)})|" for s_index, screenshot in enumerate(screenshots)])
79+
output += f"|{screenshot_section}\n"
80+
if index != 0:
81+
output += '[/details]'
82+
output += "\n\n"
83+
return output
84+
4985
def announce_release(app, release, is_generated):
5086
_create_or_post_to_topic(app, is_generated, text=f"""
5187
# {random_party_emoji()} Update alert!
5288
53-
{app.developer.name} just released *version *{release.version}** of **{app.title}**!
89+
:party: {app.developer.name} just released *version *{release.version}** of **{app.title}**!
5490
5591
[Go check it out!]({config['APPSTORE_ROOT']}/application/{app.id})
5692
@@ -62,19 +98,21 @@ def announce_release(app, release, is_generated):
6298

6399
def announce_new_app(app, is_generated):
64100
_create_or_post_to_topic(app, is_generated, text=f"""
65-
# {app.title} by {app.developer.name}
101+
{banner(app)}
66102
67-
There's a new {app.type} on the Rebble App Store!
103+
# {app.title} by {app.developer.name}
68104
69-
{app.developer.name} says:
105+
:party: There's a new {app.type} on the Rebble App Store!
70106
71-
{_md_quotify(get_app_description(app))}
107+
[quote=\"{app.developer.name} says\"]
108+
{get_app_description(app)}
109+
[/quote]
72110
73111
[Go check it out in the App Store!]({config['APPSTORE_ROOT']}/application/{app.id})
74112
75-
![App icon]({generate_image_url(app.icon_large)})
113+
{screenshot_section(app)}
76114
77-
*P.S.: I'm just a helpful robot that posted this. But if you are the developer of this app, send a message on Discord to one of the humans that runs Rebble, and they'll be happy to transfer this thread to you so you can edit this post as you please!*
115+
###### *P.S.: I'm just a helpful robot that posted this. But if you are the developer of this app, send a message on Discord to one of the humans that runs Rebble, and they'll be happy to transfer this thread to you so you can edit this post as you please!*
78116
""")
79117

80118
def get_topic_url_for_app(app):

0 commit comments

Comments
 (0)