diff --git a/src/Mod/Start/StartPage/LoadForum.py b/src/Mod/Start/StartPage/LoadForum.py deleted file mode 100644 index 5e50c40ba2..0000000000 --- a/src/Mod/Start/StartPage/LoadForum.py +++ /dev/null @@ -1,63 +0,0 @@ -#*************************************************************************** -#* * -#* Copyright (c) 2018 Yorik van Havre * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Lesser General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* This program is distributed in the hope that it will be useful, * -#* but WITHOUT ANY WARRANTY; without even the implied warranty of * -#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * -#* GNU Library General Public License for more details. * -#* * -#* You should have received a copy of the GNU Library General Public * -#* License along with this program; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#*************************************************************************** - -# NOT WORKING - for further implementation - -# The forum has a "last posts" feed at -# https://forum.freecadweb.org/feed.php -# Javascript can't fetch it directly, because of cross-domain prohibition -# We can't fetch this from python at StartPAge load, becuase it could take -# several seconds or even fail -# So the idea is to have javascript call this script here, which would -# do it, then find a way to make the result available back to javascript -# a tempfile, for example... - -url = "https://forum.freecadweb.org/feed.php" -from xml.etree.ElementTree import parse -xml = parse(urllib.urlopen(url)).getroot() -items = [] -channel = xml.find('channel') -for element in channel.findall('item'): - items.append({'title': element.find('title').text, - 'description': element.find('description').text, - 'link': element.find('link').text}) -if len(items) > numitems: - items = items[:numitems] -resp = '' -print(resp) diff --git a/src/Mod/Start/StartPage/StartPage.html b/src/Mod/Start/StartPage/StartPage.html index ef5bfe16a2..aa2a591ecb 100644 --- a/src/Mod/Start/StartPage/StartPage.html +++ b/src/Mod/Start/StartPage/StartPage.html @@ -106,7 +106,7 @@

T_RECENTCOMMITS

-

T_DESCR_RECENTCOMMITS

+
T_DESCR_RECENTCOMMITS
T_OFFLINEPLACEHOLDER
@@ -117,6 +117,16 @@ +
+ +

T_FORUM

+ +
T_DESCR_FORUM
+ +
T_OFFLINEPLACEHOLDER
+ +
+ diff --git a/src/Mod/Start/StartPage/StartPage.js b/src/Mod/Start/StartPage/StartPage.js index 57f898e61d..238a5ed65a 100644 --- a/src/Mod/Start/StartPage/StartPage.js +++ b/src/Mod/Start/StartPage/StartPage.js @@ -1,7 +1,10 @@ var allowDownloads = 0; + function toggle(tab) { + // switch to the given tab ID ("tab1", "tab2", etc...) + var tabs = document.getElementById("tabs").childElementCount; document.getElementById(tab).classList.remove("hidden"); document.getElementById("h"+tab).classList.add("active"); @@ -13,7 +16,11 @@ function toggle(tab) { } } + function load() { + + // run at startup + if (allowDownloads == 1) { // load latest commits ddiv = document.getElementById("commits"); @@ -29,10 +36,21 @@ function load() { tobj.buildScriptTag(); // Build the script tag tobj.addScriptTag(); // Execute (add) the script tag ddiv.innerHTML = "Downloading addons list..."; + // load forum recent posts + ddiv = document.getElementById("forum"); + ddiv.innerHTML = "Connecting..."; + var tobj=new JSONscriptRequest('https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fforum.freecadweb.org%2Ffeed.php&api_key=s9yqcsrevp9irkqworzmvnrjs4jotjac2g4ybs95&callback=printForum'); + tobj.buildScriptTag(); // Build the script tag + tobj.addScriptTag(); // Execute (add) the script tag + ddiv.innerHTML = "Downloading addons list..."; } } + function printCommits(data) { + + // json callback for git commits + ddiv = document.getElementById('commits'); ddiv.innerHTML = "Received"; var html = ['