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

Feature #165 Wiki link in notification #166

Closed
Closed
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
6 changes: 6 additions & 0 deletions scripts/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ function() {

$friendlyfilename = "[Listen here](".$filename.")";

$wikiurl = "https://wikipedia.org/wiki/".preg_replace('/ /', '_', $sciname);

$attach="";
$exampleimage = "https://live.staticflickr.com/7430/27545810581_8bfa8289a3_c.jpg";
if (strpos($body, '$flickrimage') !== false) {
Expand All @@ -254,6 +256,7 @@ function() {
$title = str_replace("\$sens", $sens, $title);
$title = str_replace("\$overlap", $overlap, $title);
$title = str_replace("\$flickrimage", $exampleimage, $title);
$title = str_replace("\$wikiurl", $wikiurl, $title);
$title = str_replace("\$reason", 'Test message', $title);

$body = str_replace("\$sciname", $sciname, $body);
Expand All @@ -271,6 +274,7 @@ function() {
$body = str_replace("\$sens", $sens, $body);
$body = str_replace("\$overlap", $overlap, $body);
$body = str_replace("\$flickrimage", $exampleimage, $body);
$body = str_replace("\$wikiurl", $wikiurl, $body);
$body = str_replace("\$reason", 'Test message', $body);

$temp = tmpfile();
Expand Down Expand Up @@ -531,6 +535,8 @@ function runProcess() {
<dd>Overlap set in "Advanced Settings"</dd>
<dt>$flickrimage</dt>
<dd>A preview image of the detected species from Flickr. Set your API key below.</dd>
<dt>$wikiurl</dt>
<dd>A link to the Wikipedia page</dd>
<dt>$reason</dt>
<dd>The reason a notification was sent</dd>
</dl>
Expand Down
2 changes: 2 additions & 0 deletions scripts/utils/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def render_template(template, reason=""):
.replace("$cutoff", cutoff) \
.replace("$sens", sens) \
.replace("$flickrimage", image_url if "{" in body else "") \
.replace("$wikiurl", wikiurl) \
.replace("$overlap", overlap) \
.replace("$reason", reason)
return ret
Expand Down Expand Up @@ -99,6 +100,7 @@ def render_template(template, reason=""):

listenurl = websiteurl+"?filename="+path
friendlyurl = "[Listen here]("+listenurl+")"
wikiurl = "https://wikipedia.org/wiki/" + sciName.replace(' ', '_')
image_url = ""

if len(settings_dict.get('FLICKR_API_KEY')) > 0 and "$flickrimage" in body:
Expand Down
Loading