From 0c9847fbecb23f539266c5e80028a7a4a8bd067f Mon Sep 17 00:00:00 2001 From: Arinerron Date: Wed, 26 Sep 2018 17:40:02 -0700 Subject: [PATCH] Misc changes --- onionr/core.py | 5 +---- onionr/onionrblockapi.py | 8 +++++--- .../www/ui/common/onionr-timeline-post.html | 6 +++--- onionr/static-data/www/ui/dist/css/main.css | 2 ++ onionr/static-data/www/ui/dist/index.html | 14 ++++++++++++++ onionr/static-data/www/ui/dist/js/main.js | 6 +++--- onionr/static-data/www/ui/dist/js/timeline.js | 10 ++++++++++ onionr/static-data/www/ui/src/css/main.css | 2 ++ onionr/static-data/www/ui/src/index.html | 14 ++++++++++++++ onionr/static-data/www/ui/src/js/timeline.js | 10 ++++++++++ 10 files changed, 64 insertions(+), 13 deletions(-) diff --git a/onionr/core.py b/onionr/core.py index bff27e45..e1f38fa8 100644 --- a/onionr/core.py +++ b/onionr/core.py @@ -644,7 +644,7 @@ class Core: conn.close() return True - def insertBlock(self, data, header='txt', sign=False, encryptType='', symKey='', asymPeer='', meta = None): + def insertBlock(self, data, header='txt', sign=False, encryptType='', symKey='', asymPeer='', meta = dict()): ''' Inserts a block into the network encryptType must be specified to encrypt a block @@ -663,9 +663,6 @@ class Core: with open(self.dataNonceFile, 'a') as nonceFile: nonceFile.write(dataNonce + '\n') - if meta is None: - meta = dict() - if type(data) is bytes: data = data.decode() data = str(data) diff --git a/onionr/onionrblockapi.py b/onionr/onionrblockapi.py index 87ca2984..b656bd43 100644 --- a/onionr/onionrblockapi.py +++ b/onionr/onionrblockapi.py @@ -163,7 +163,7 @@ class Block: self.raw = str(blockdata) self.bheader = json.loads(self.getRaw()[:self.getRaw().index('\n')]) self.bcontent = self.getRaw()[self.getRaw().index('\n') + 1:] - if self.bheader['encryptType'] in ('asym', 'sym'): + if ('encryptType' in self.bheader) and (self.bheader['encryptType'] in ('asym', 'sym')): self.bmetadata = self.getHeader('meta', None) self.isEncrypted = True else: @@ -193,6 +193,8 @@ class Block: # if block can't be parsed, it's a waste of precious space. Throw it away. if not self.delete(): logger.error('Failed to delete invalid block %s.' % self.getHash(), error = e) + else: + logger.debug('Deleted invalid block %s.' % self.getHash(), timestamp = False) self.valid = False return False @@ -207,7 +209,7 @@ class Block: if self.exists(): os.remove(self.getBlockFile()) - removeBlock(self.getHash()) + self.getCore().removeBlock(self.getHash()) return True return False @@ -230,7 +232,7 @@ class Block: blockFile.write(self.getRaw().encode()) self.update() else: - self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign) + self.hash = self.getCore().insertBlock(self.getContent(), header = self.getType(), sign = sign, meta = self.getMetadata()) self.update() return self.getHash() diff --git a/onionr/static-data/www/ui/common/onionr-timeline-post.html b/onionr/static-data/www/ui/common/onionr-timeline-post.html index a6873abe..67ec158c 100644 --- a/onionr/static-data/www/ui/common/onionr-timeline-post.html +++ b/onionr/static-data/www/ui/common/onionr-timeline-post.html @@ -1,6 +1,6 @@
-
+
@@ -8,8 +8,8 @@
diff --git a/onionr/static-data/www/ui/dist/css/main.css b/onionr/static-data/www/ui/dist/css/main.css index a69216cb..4b9cfe8d 100644 --- a/onionr/static-data/www/ui/dist/css/main.css +++ b/onionr/static-data/www/ui/dist/css/main.css @@ -41,6 +41,8 @@ body { padding: 1rem; margin-bottom: 1rem; + cursor: pointer; + width: 100%; } diff --git a/onionr/static-data/www/ui/dist/index.html b/onionr/static-data/www/ui/dist/index.html index 90f9a30d..080c67eb 100644 --- a/onionr/static-data/www/ui/dist/index.html +++ b/onionr/static-data/www/ui/dist/index.html @@ -117,6 +117,20 @@
+ + +