diff --git a/onionr/api.py b/onionr/api.py index 753afcce..75f02a13 100755 --- a/onionr/api.py +++ b/onionr/api.py @@ -222,7 +222,6 @@ class API: This also saves the used host (random localhost IP address) to the data folder in host.txt ''' # assert isinstance(onionrInst, onionr.Onionr) - print(type(onionrInst)) # configure logger and stuff onionr.Onionr.setupConfig('data/', self = self) @@ -235,7 +234,7 @@ class API: bindPort = int(config.get('client.client.port', 59496)) self.bindPort = bindPort - self.whitelistEndpoints = ('site', 'www', 'onionrhome', 'board', 'boardContent') + self.whitelistEndpoints = ('site', 'www', 'onionrhome', 'board', 'boardContent', 'sharedContent') self.clientToken = config.get('client.webpassword') self.timeBypassToken = base64.b16encode(os.urandom(32)).decode() @@ -278,6 +277,9 @@ class API: @app.route('/board/', endpoint='boardContent') def boardContent(path): return send_from_directory('static-data/www/board/', path) + @app.route('/shared/', endpoint='sharedContent') + def sharedContent(path): + return send_from_directory('static-data/www/shared/', path) @app.route('/www/', endpoint='www') def wwwPublic(path): diff --git a/onionr/static-data/www/board/board.js b/onionr/static-data/www/board/board.js index fbdddd51..7f513357 100644 --- a/onionr/static-data/www/board/board.js +++ b/onionr/static-data/www/board/board.js @@ -1,30 +1,56 @@ webpassword = '' -requested = {} -document.getElementById('feed').innerText = 'none :)' +requested = [] + +document.getElementById('webpassWindow').style.display = 'block'; + +var windowHeight = window.innerHeight; +document.getElementById('webpassWindow').style.height = windowHeight + "px"; function httpGet(theUrl) { var xmlHttp = new XMLHttpRequest() xmlHttp.open( "GET", theUrl, false ) // false for synchronous request xmlHttp.setRequestHeader('token', webpassword) xmlHttp.send( null ) - return xmlHttp.responseText + if (xmlHttp.status == 200){ + return xmlHttp.responseText + } + else{ + return ""; + } } function appendMessages(msg){ - document.getElementById('feed').append(msg) + el = document.createElement('div') + el.className = 'entry' + el.innerText = msg + document.getElementById('feed').appendChild(el) document.getElementById('feed').appendChild(document.createElement('br')) } function getBlocks(){ + if (document.getElementById('none') !== null){ + document.getElementById('none').remove(); + + } var feedText = httpGet('/getblocksbytype/txt') var blockList = feedText.split(',') for (i = 0; i < blockList.length; i++){ - bl = httpGet('/gethtmlsafeblockdata/' + blockList[i]) - appendMessages(bl) - } + if (! requested.includes(blockList[i])){ + bl = httpGet('/gethtmlsafeblockdata/' + blockList[i]) + appendMessages(bl) + requested.push(blockList[i]) + } + } } -document.getElementById('webpassword').oninput = function(){ +document.getElementById('registerPassword').onclick = function(){ webpassword = document.getElementById('webpassword').value + if (httpGet('/ping') === 'pong!'){ + document.getElementById('webpassWindow').style.display = 'none' + getBlocks() + } + else{ + alert('Sorry, but that password appears invalid.') + } } document.getElementById('refreshFeed').onclick = function(){ diff --git a/onionr/static-data/www/board/index.html b/onionr/static-data/www/board/index.html index 3b1c3426..df48e912 100644 --- a/onionr/static-data/www/board/index.html +++ b/onionr/static-data/www/board/index.html @@ -5,12 +5,17 @@ OnionrBoard + - -

Onionr Board

- + + -
+
None Yet :)
\ No newline at end of file diff --git a/onionr/static-data/www/board/theme.css b/onionr/static-data/www/board/theme.css index e69de29b..766e4407 100644 --- a/onionr/static-data/www/board/theme.css +++ b/onionr/static-data/www/board/theme.css @@ -0,0 +1,31 @@ +h1, h2, h3{ + font-family: sans-serif; +} +.hidden{ + display: none; +} +p{ + font-family: sans-serif; +} +#webpassWindow{ + background-color: black; + border: 1px solid black; + border-radius: 5px; + width: 100%; + z-index: 2; + color: white; + text-align: center; +} + +.entry{ + color: red; +} + +#feed{ + margin-left: 2%; + margin-right: 25%; + margin-top: 1em; + border: 2px solid black; + padding: 5px; + min-height: 50px; +} \ No newline at end of file