Skip to content

Commit

Permalink
Add helios backlinks
Browse files Browse the repository at this point in the history
  • Loading branch information
dgarciabriseno committed Nov 30, 2022
1 parent 34b2bad commit 6557ad5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 1 addition & 1 deletion resources/js/HelioviewerWebClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var HelioviewerWebClient = HelioviewerClient.extend(
this.imageSelectTool = new ImageSelectTool();

this._screenshotManagerUI = new ScreenshotManagerUI();
this._movieManagerUI = new MovieManagerUI(serverSettings.regenerateMovieThreshold);
this._movieManagerUI = new MovieManagerUI(serverSettings.regenerateMovieThreshold, serverSettings.enableHelios);

this._glossary = new VisualGlossary(this._setupDialog);

Expand Down
15 changes: 10 additions & 5 deletions resources/js/Media/MediaManagerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ var MediaManagerUI = Class.extend(
* Creates a new ScreenshotManagerUI instance
*
* @param {ScreenshotManager} model ScreenshotManager instance
* @param {bool} enable_helios Determines whether or not to render helios links on movies
*/
init: function (type) {
init: function (type, enable_helios = false) {
this._type = type;

this._btn = $("#" + type + "-button");
Expand All @@ -30,6 +31,7 @@ var MediaManagerUI = Class.extend(
this._clearBtn = $("#" + type + "-clear-history-button");
this._tooltips = $("#social-buttons div");
this._cleanupFunctions = [];
this._enable_helios = enable_helios;

this._loadSavedItems();
},
Expand Down Expand Up @@ -81,22 +83,25 @@ var MediaManagerUI = Class.extend(
* @param {Object} The movie or screenshot to be added
*/
_addItem: function (item) {
var htmlId, html, last, url, name = item.name;
var htmlId, html, last, url, name = item.name, helios_link = "";

// HTML for a single row in the history dialog
htmlId = this._type + "-" + item.id;

// Link
if (this._type === "movie") {
url = "?movieId=" + item.id;
if (this._enable_helios) {
helios_link = "&nbsp;&nbsp;&nbsp;<a class='text-btn' href='https://gl.helioviewer.org/?movie=" + item.id + "'>View on Helios</a>";
}
}
else {
url = Helioviewer.api + "?action=downloadScreenshot&id=" + item.id;
}

html = $("<div id='" + htmlId + "' class='history-entry'>" +
"<div class='label' data-id='" + item.id + "'><a class='text-btn' style='float: left' href='" + url +
"'>" + name + "</a></div>" +
"<div class='label' data-id='" + item.id + "'><p style='float: left'><a class='text-btn' href='" + url +
"'>" + name + "</a>"+ helios_link +"</p></div>" +
"<div class='status'></div>" +
"</div>");

Expand Down Expand Up @@ -254,4 +259,4 @@ var MediaManagerUI = Class.extend(
}
return true;
}
});
});
10 changes: 8 additions & 2 deletions resources/js/Media/MovieManagerUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ var MovieManagerUI = MediaManagerUI.extend(
* Creates a new MovieManagerUI instance
*
* @param {int} regenerateMovieThreshold Number of days to wait before displaying the "regenerate" option on an old movie.
* @param {bool} enable_helios Determines whether or not to render helios links on movies
*/
init: function (regenerateMovieThreshold = 90) {
init: function (regenerateMovieThreshold = 90, enable_helios = false) {
var movies = Helioviewer.userSettings.get('history.movies');
this._manager = new MovieManager(movies);
this._super("movie");
this._super("movie", enable_helios);
this._settingsDialog = $("#movie-settings-container");
this._advancedSettings = $("#movie-settings-advanced");
this._settingsHelp = $("#movie-settings-help");
Expand Down Expand Up @@ -589,6 +590,11 @@ var MovieManagerUI = MediaManagerUI.extend(
_onMovieClick: function (event) {
var id, movie, dialog, action, dateRequested;

if (event.target.href.indexOf("gl.helioviewer.org") != -1) {
window.open(event.target.href, '_blank');
return false;
}

id = $(event.currentTarget).data('id');
movie = this._manager.get(id);

Expand Down
6 changes: 4 additions & 2 deletions resources/js/Utility/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ var Config = Class.extend(
'news_url' : "https://helioviewer-project.github.io/",
'user_video_feed' : "https://api.helioviewer.org/",
'contact_email' : "HelioViewerDevelopment@nasa.onmicrosoft.com",
'regenerate_movie_threshold': 90
'regenerate_movie_threshold': 90,
'enable_helios_backlinks' : true
},

/**
Expand Down Expand Up @@ -92,7 +93,8 @@ var Config = Class.extend(
'videoFeed' : this.params["user_video_feed"],
'contactEmail' : this.params["contact_email"],
'apiURL' : this.params["back_end"],
'regenerateMovieThreshold': this.params["regenerate_movie_threshold"]
'regenerateMovieThreshold': this.params["regenerate_movie_threshold"],
'enableHelios' : this.params["enable_helios_backlinks"]
};
}
});

0 comments on commit 6557ad5

Please sign in to comment.