fixed some bugs
parent
9080374d7b
commit
bf9b244180
|
@ -28,6 +28,6 @@ Do your best to use good english.
|
||||||
|
|
||||||
For any non-trivial changes, please get in touch with us first to discuss your plans.
|
For any non-trivial changes, please get in touch with us first to discuss your plans.
|
||||||
|
|
||||||
Please try to use a similar coding style as the project.
|
Please try to use a similar coding style as the project. We like PEP-8 despite being lazy with it in the past.
|
||||||
|
|
||||||
**Thanks for contributing to Onionr!**
|
**Thanks for contributing to Onionr!**
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
ouodhqewz7x7sajdnbeixmffnuzjxpv2z6djuiqkjloywepcsmfkazqd.onion
|
3msj7fgyxgpfsjvvtcji7a4tkjbna6jmpealv6mun7435jjyptctfxyd.onion
|
|
@ -22,10 +22,10 @@ from flask import Response, request, redirect, Blueprint, abort
|
||||||
from utils import identifyhome
|
from utils import identifyhome
|
||||||
import deadsimplekv as simplekv
|
import deadsimplekv as simplekv
|
||||||
flask_blueprint = Blueprint('flow', __name__)
|
flask_blueprint = Blueprint('flow', __name__)
|
||||||
board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json')
|
|
||||||
|
|
||||||
@flask_blueprint.route('/flow/getpostsbyboard/<board>')
|
@flask_blueprint.route('/flow/getpostsbyboard/<board>')
|
||||||
def get_post_by_board(board):
|
def get_post_by_board(board):
|
||||||
|
board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json')
|
||||||
board_cache.refresh()
|
board_cache.refresh()
|
||||||
posts = board_cache.get(board)
|
posts = board_cache.get(board)
|
||||||
if posts is None:
|
if posts is None:
|
||||||
|
|
|
@ -33,7 +33,6 @@ flask_blueprint = flowapi.flask_blueprint
|
||||||
|
|
||||||
plugin_name = 'flow'
|
plugin_name = 'flow'
|
||||||
PLUGIN_VERSION = '0.0.1'
|
PLUGIN_VERSION = '0.0.1'
|
||||||
board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json')
|
|
||||||
|
|
||||||
class OnionrFlow:
|
class OnionrFlow:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -105,16 +104,14 @@ def on_init(api, data = None):
|
||||||
inputted is executed. Could be called when daemon is starting or when
|
inputted is executed. Could be called when daemon is starting or when
|
||||||
just the client is running.
|
just the client is running.
|
||||||
'''
|
'''
|
||||||
# Doing this makes it so that the other functions can access the api object
|
return
|
||||||
# by simply referencing the variable `pluginapi`.
|
|
||||||
global pluginapi
|
|
||||||
pluginapi = api
|
|
||||||
|
|
||||||
def on_processblocks(api, data=None):
|
def on_processblocks(api, data=None):
|
||||||
b_hash = reconstructhash.deconstruct_hash(data['block'].hash) # Get the 0-truncated block hash
|
|
||||||
metadata = data['block'].bmetadata # Get the block metadata
|
metadata = data['block'].bmetadata # Get the block metadata
|
||||||
if data['block'].bheader['type'] != 'brd':
|
if data['type'] != 'brd':
|
||||||
return
|
return
|
||||||
|
b_hash = reconstructhash.deconstruct_hash(data['block'].hash) # Get the 0-truncated block hash
|
||||||
|
board_cache = simplekv.DeadSimpleKV(identifyhome.identify_home() + '/board-index.cache.json') # get the board index cache
|
||||||
|
|
||||||
# Validate the channel name is sane for caching
|
# Validate the channel name is sane for caching
|
||||||
try:
|
try:
|
||||||
|
@ -130,11 +127,10 @@ def on_processblocks(api, data=None):
|
||||||
existing_posts = board_cache.get(ch)
|
existing_posts = board_cache.get(ch)
|
||||||
if existing_posts is None:
|
if existing_posts is None:
|
||||||
existing_posts = ''
|
existing_posts = ''
|
||||||
else:
|
|
||||||
existing_posts += ','
|
|
||||||
check_list = existing_posts.split(',')
|
check_list = existing_posts.split(',')
|
||||||
if len(check_list) > 30:
|
if len(check_list) > 30:
|
||||||
check_list.pop(0)
|
check_list.pop(0)
|
||||||
existing_posts = ','.join(check_list)
|
existing_posts = ','.join(check_list)
|
||||||
board_cache.put(ch, '%s%s' % (existing_posts, b_hash))
|
board_cache.put(ch, '%s,%s' % (existing_posts, b_hash))
|
||||||
board_cache.flush()
|
board_cache.flush()
|
|
@ -94,7 +94,7 @@ newPostForm.onsubmit = function(){
|
||||||
var message = document.getElementById('newMsgText').value
|
var message = document.getElementById('newMsgText').value
|
||||||
var channel = document.getElementById('feedIDInput').value
|
var channel = document.getElementById('feedIDInput').value
|
||||||
var meta = {'ch': channel}
|
var meta = {'ch': channel}
|
||||||
var postData = {'message': message, 'type': 'txt', 'encrypt': false, 'meta': JSON.stringify(meta)}
|
var postData = {'message': message, 'type': 'brd', 'encrypt': false, 'meta': JSON.stringify(meta)}
|
||||||
postData = JSON.stringify(postData)
|
postData = JSON.stringify(postData)
|
||||||
newPostForm.style.display = 'none'
|
newPostForm.style.display = 'none'
|
||||||
fetch('/insertblock', {
|
fetch('/insertblock', {
|
||||||
|
@ -108,6 +108,7 @@ newPostForm.onsubmit = function(){
|
||||||
.then(function(data) {
|
.then(function(data) {
|
||||||
newPostForm.style.display = 'block'
|
newPostForm.style.display = 'block'
|
||||||
alert('Queued for submission!')
|
alert('Queued for submission!')
|
||||||
|
setTimeout(function(){getBlocks()}, 3000)
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
}
|
}
|
|
@ -67,4 +67,5 @@ function getStats(){
|
||||||
}
|
}
|
||||||
lastIncoming.innerText = lastConnect
|
lastIncoming.innerText = lastConnect
|
||||||
}
|
}
|
||||||
getStats()
|
getStats()
|
||||||
|
setInterval(function(){getStats()}, 10000)
|
Loading…
Reference in New Issue