Misc changes
parent
3711b02924
commit
0c9847fbec
|
@ -644,7 +644,7 @@ class Core:
|
||||||
conn.close()
|
conn.close()
|
||||||
return True
|
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
|
Inserts a block into the network
|
||||||
encryptType must be specified to encrypt a block
|
encryptType must be specified to encrypt a block
|
||||||
|
@ -663,9 +663,6 @@ class Core:
|
||||||
with open(self.dataNonceFile, 'a') as nonceFile:
|
with open(self.dataNonceFile, 'a') as nonceFile:
|
||||||
nonceFile.write(dataNonce + '\n')
|
nonceFile.write(dataNonce + '\n')
|
||||||
|
|
||||||
if meta is None:
|
|
||||||
meta = dict()
|
|
||||||
|
|
||||||
if type(data) is bytes:
|
if type(data) is bytes:
|
||||||
data = data.decode()
|
data = data.decode()
|
||||||
data = str(data)
|
data = str(data)
|
||||||
|
|
|
@ -163,7 +163,7 @@ class Block:
|
||||||
self.raw = str(blockdata)
|
self.raw = str(blockdata)
|
||||||
self.bheader = json.loads(self.getRaw()[:self.getRaw().index('\n')])
|
self.bheader = json.loads(self.getRaw()[:self.getRaw().index('\n')])
|
||||||
self.bcontent = self.getRaw()[self.getRaw().index('\n') + 1:]
|
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.bmetadata = self.getHeader('meta', None)
|
||||||
self.isEncrypted = True
|
self.isEncrypted = True
|
||||||
else:
|
else:
|
||||||
|
@ -193,6 +193,8 @@ class Block:
|
||||||
# if block can't be parsed, it's a waste of precious space. Throw it away.
|
# if block can't be parsed, it's a waste of precious space. Throw it away.
|
||||||
if not self.delete():
|
if not self.delete():
|
||||||
logger.error('Failed to delete invalid block %s.' % self.getHash(), error = e)
|
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
|
self.valid = False
|
||||||
return False
|
return False
|
||||||
|
@ -207,7 +209,7 @@ class Block:
|
||||||
|
|
||||||
if self.exists():
|
if self.exists():
|
||||||
os.remove(self.getBlockFile())
|
os.remove(self.getBlockFile())
|
||||||
removeBlock(self.getHash())
|
self.getCore().removeBlock(self.getHash())
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -230,7 +232,7 @@ class Block:
|
||||||
blockFile.write(self.getRaw().encode())
|
blockFile.write(self.getRaw().encode())
|
||||||
self.update()
|
self.update()
|
||||||
else:
|
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()
|
self.update()
|
||||||
|
|
||||||
return self.getHash()
|
return self.getHash()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!-- POST -->
|
<!-- POST -->
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="onionr-post">
|
<div class="onionr-post" id="onionr-post-$post-hash" onclick="focusPost('$post-hash', 'user-id-url', 'user-name-url', '')">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-2">
|
<div class="col-2">
|
||||||
<img class="onionr-post-user-icon" src="$user-image">
|
<img class="onionr-post-user-icon" src="$user-image">
|
||||||
|
@ -8,8 +8,8 @@
|
||||||
<div class="col-10">
|
<div class="col-10">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-auto">
|
<div class="col col-auto">
|
||||||
<a class="onionr-post-user-name" href="#!" onclick="viewProfile('$user-id-url', '$user-name-url')">$user-name</a>
|
<a class="onionr-post-user-name" id="onionr-post-user-name" href="#!" onclick="viewProfile('$user-id-url', '$user-name-url')">$user-name</a>
|
||||||
<a class="onionr-post-user-id" href="#!" onclick="viewProfile('$user-id-url', '$user-name-url')" data-placement="top" data-toggle="tooltip" title="$user-id">$user-id-truncated</a>
|
<a class="onionr-post-user-id" id="onionr-post-user-id" href="#!" onclick="viewProfile('$user-id-url', '$user-name-url')" data-placement="top" data-toggle="tooltip" title="$user-id">$user-id-truncated</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col col-auto text-right ml-auto pl-0">
|
<div class="col col-auto text-right ml-auto pl-0">
|
||||||
|
|
|
@ -41,6 +41,8 @@ body {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,6 +117,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- onionr-post-focus -->
|
||||||
|
<div class="modal fade" id="onionr-post-focus" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="onionr-post-focus-content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
|
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
|
||||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
|
|
@ -285,7 +285,7 @@ class Post {
|
||||||
getHTML() {
|
getHTML() {
|
||||||
var postTemplate = '<!-- POST -->\
|
var postTemplate = '<!-- POST -->\
|
||||||
<div class="col-12">\
|
<div class="col-12">\
|
||||||
<div class="onionr-post">\
|
<div class="onionr-post" id="onionr-post-$post-hash" onclick="focusPost(\'$post-hash\', \'user-id-url\', \'user-name-url\', \'\')">\
|
||||||
<div class="row">\
|
<div class="row">\
|
||||||
<div class="col-2">\
|
<div class="col-2">\
|
||||||
<img class="onionr-post-user-icon" src="$user-image">\
|
<img class="onionr-post-user-icon" src="$user-image">\
|
||||||
|
@ -293,8 +293,8 @@ class Post {
|
||||||
<div class="col-10">\
|
<div class="col-10">\
|
||||||
<div class="row">\
|
<div class="row">\
|
||||||
<div class="col col-auto">\
|
<div class="col col-auto">\
|
||||||
<a class="onionr-post-user-name" href="#!" onclick="viewProfile(\'$user-id-url\', \'$user-name-url\')">$user-name</a>\
|
<a class="onionr-post-user-name" id="onionr-post-user-name" href="#!" onclick="viewProfile(\'$user-id-url\', \'$user-name-url\')">$user-name</a>\
|
||||||
<a class="onionr-post-user-id" href="#!" onclick="viewProfile(\'$user-id-url\', \'$user-name-url\')" data-placement="top" data-toggle="tooltip" title="$user-id">$user-id-truncated</a>\
|
<a class="onionr-post-user-id" id="onionr-post-user-id" href="#!" onclick="viewProfile(\'$user-id-url\', \'$user-name-url\')" data-placement="top" data-toggle="tooltip" title="$user-id">$user-id-truncated</a>\
|
||||||
</div>\
|
</div>\
|
||||||
\
|
\
|
||||||
<div class="col col-auto text-right ml-auto pl-0">\
|
<div class="col col-auto text-right ml-auto pl-0">\
|
||||||
|
|
|
@ -179,6 +179,12 @@ function makePost() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function focusPost(id) {
|
||||||
|
document.getElementById("onionr-post-focus-content").innerHTML = "";
|
||||||
|
|
||||||
|
jQuery('#onionr-post-focus').modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
jQuery('body').on('click', '[data-editable]', function() {
|
jQuery('body').on('click', '[data-editable]', function() {
|
||||||
var el = jQuery(this);
|
var el = jQuery(this);
|
||||||
var txt = el.text();
|
var txt = el.text();
|
||||||
|
@ -213,6 +219,10 @@ jQuery('body').on('click', '[data-editable]', function() {
|
||||||
|
|
||||||
input.one('blur', save).bind('keyup', saveEnter).focus();
|
input.one('blur', save).bind('keyup', saveEnter).focus();
|
||||||
});
|
});
|
||||||
|
//viewProfile('$user-id-url', '$user-name-url')
|
||||||
|
jQuery('#onionr-post-user-id').on('click', function(e) { alert(3);});
|
||||||
|
//jQuery('#onionr-post *').on('click', function(e) { e.stopPropagation(); });
|
||||||
|
jQuery('#onionr-post').click(function(e) { alert(1); });
|
||||||
|
|
||||||
currentUser = getCurrentUser();
|
currentUser = getCurrentUser();
|
||||||
if(currentUser !== undefined && currentUser !== null) {
|
if(currentUser !== undefined && currentUser !== null) {
|
||||||
|
|
|
@ -41,6 +41,8 @@ body {
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
margin-bottom: 1rem;
|
margin-bottom: 1rem;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,20 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- onionr-post-focus -->
|
||||||
|
<div class="modal fade" id="onionr-post-focus" tabindex="-1" role="dialog" aria-labelledby="modal-title" aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="onionr-post-focus-content"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<footer />
|
<footer />
|
||||||
<script src="js/timeline.js"></script>
|
<script src="js/timeline.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -179,6 +179,12 @@ function makePost() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function focusPost(id) {
|
||||||
|
document.getElementById("onionr-post-focus-content").innerHTML = "";
|
||||||
|
|
||||||
|
jQuery('#onionr-post-focus').modal('show');
|
||||||
|
}
|
||||||
|
|
||||||
jQuery('body').on('click', '[data-editable]', function() {
|
jQuery('body').on('click', '[data-editable]', function() {
|
||||||
var el = jQuery(this);
|
var el = jQuery(this);
|
||||||
var txt = el.text();
|
var txt = el.text();
|
||||||
|
@ -213,6 +219,10 @@ jQuery('body').on('click', '[data-editable]', function() {
|
||||||
|
|
||||||
input.one('blur', save).bind('keyup', saveEnter).focus();
|
input.one('blur', save).bind('keyup', saveEnter).focus();
|
||||||
});
|
});
|
||||||
|
//viewProfile('$user-id-url', '$user-name-url')
|
||||||
|
jQuery('#onionr-post-user-id').on('click', function(e) { alert(3);});
|
||||||
|
//jQuery('#onionr-post *').on('click', function(e) { e.stopPropagation(); });
|
||||||
|
jQuery('#onionr-post').click(function(e) { alert(1); });
|
||||||
|
|
||||||
currentUser = getCurrentUser();
|
currentUser = getCurrentUser();
|
||||||
if(currentUser !== undefined && currentUser !== null) {
|
if(currentUser !== undefined && currentUser !== null) {
|
||||||
|
|
Loading…
Reference in New Issue