From b24c683f5fccbc54b061ce32b064b16bfc65d3bf Mon Sep 17 00:00:00 2001 From: Kevin Froman Date: Sat, 27 Jul 2019 02:29:16 -0500 Subject: [PATCH] work on chat --- onionr/coredb/keydb/userinfo.py | 4 +++- onionr/httpapi/miscclientapi/staticfiles.py | 8 +++++++ onionr/httpapi/security/client.py | 4 ++-- onionr/static-data/www/chat/css/convos.css | 10 +++++++++ .../www/{clandestine => chat}/index.html | 21 ++++++++++++------- .../www/{clandestine => chat}/js/main.js | 2 +- onionr/utils/hastor.py | 6 ++++++ 7 files changed, 43 insertions(+), 12 deletions(-) create mode 100644 onionr/static-data/www/chat/css/convos.css rename onionr/static-data/www/{clandestine => chat}/index.html (83%) rename onionr/static-data/www/{clandestine => chat}/js/main.js (92%) create mode 100644 onionr/utils/hastor.py diff --git a/onionr/coredb/keydb/userinfo.py b/onionr/coredb/keydb/userinfo.py index 6d0daea4..23ee8b7c 100644 --- a/onionr/coredb/keydb/userinfo.py +++ b/onionr/coredb/keydb/userinfo.py @@ -67,4 +67,6 @@ def set_peer_info(peer, key, data): c.execute('UPDATE peers SET ' + key + ' = ? WHERE id=?', command) conn.commit() - conn.close() \ No newline at end of file + conn.close() + +set_user_info = set_peer_info \ No newline at end of file diff --git a/onionr/httpapi/miscclientapi/staticfiles.py b/onionr/httpapi/miscclientapi/staticfiles.py index a89f0cc1..d43d5b7f 100644 --- a/onionr/httpapi/miscclientapi/staticfiles.py +++ b/onionr/httpapi/miscclientapi/staticfiles.py @@ -24,6 +24,14 @@ static_files_bp = Blueprint('staticfiles', __name__) root = os.getcwd() + '/static-data/www/' # should be set to onionr install directory from onionr startup +@static_files_bp.route('/chat/', endpoint='chatIndex') +def chat_index(): + return send_from_directory(root + 'chat/', "index.html") + +@static_files_bp.route('/chat/', endpoint='chat') +def load_chat(path): + return send_from_directory(root + 'chat/', path) + @static_files_bp.route('/board/', endpoint='board') def loadBoard(): return send_from_directory(root + 'board/', "index.html") diff --git a/onionr/httpapi/security/client.py b/onionr/httpapi/security/client.py index 4191e67f..7838d974 100644 --- a/onionr/httpapi/security/client.py +++ b/onionr/httpapi/security/client.py @@ -23,10 +23,10 @@ from onionrservices import httpheaders # Be extremely mindful of this. These are endpoints available without a password whitelist_endpoints = ('siteapi.site', 'www', 'staticfiles.onionrhome', 'staticfiles.homedata', 'staticfiles.board', 'staticfiles.profiles', -'staticfiles.profilesindex', +'staticfiles.profilesindex', 'staticfiles.boardContent', 'staticfiles.sharedContent', 'staticfiles.mail', 'staticfiles.mailindex', 'staticfiles.friends', 'staticfiles.friendsindex', -'staticfiles.clandestine', 'staticfiles.clandestineIndex') +'staticfiles.chat', 'staticfiles.chatIndex') class ClientAPISecurity: def __init__(self, client_api): diff --git a/onionr/static-data/www/chat/css/convos.css b/onionr/static-data/www/chat/css/convos.css new file mode 100644 index 00000000..12b8aa0e --- /dev/null +++ b/onionr/static-data/www/chat/css/convos.css @@ -0,0 +1,10 @@ +.conversationList li{ + list-style: none; + padding-top: 1em; +} + +.convoListContainer{ + margin-left: 1%; + border-radius: 10px solid black; + min-height: 100%; +} \ No newline at end of file diff --git a/onionr/static-data/www/clandestine/index.html b/onionr/static-data/www/chat/index.html similarity index 83% rename from onionr/static-data/www/clandestine/index.html rename to onionr/static-data/www/chat/index.html index cbed280a..6b66a29f 100755 --- a/onionr/static-data/www/clandestine/index.html +++ b/onionr/static-data/www/chat/index.html @@ -6,11 +6,12 @@ - Clandestine + Onionr Chat - + + @@ -35,7 +36,7 @@ Mail Friends Circles - Clandestine + Chat @@ -47,10 +48,10 @@

- Clandestine + Onionr Chat

- Instant messaging + Instant Messaging

@@ -77,12 +78,16 @@
-
-
    +
    +
    +
      +
      +
      + - + \ No newline at end of file diff --git a/onionr/static-data/www/clandestine/js/main.js b/onionr/static-data/www/chat/js/main.js similarity index 92% rename from onionr/static-data/www/clandestine/js/main.js rename to onionr/static-data/www/chat/js/main.js index a757f713..baa3ab56 100755 --- a/onionr/static-data/www/clandestine/js/main.js +++ b/onionr/static-data/www/chat/js/main.js @@ -5,7 +5,7 @@ function createConvoList(){ console.log(friendList) for (friend in friendList){ - var convoEntry = document.createElement('div') + var convoEntry = document.createElement('li') convoEntry.classList.add('convoEntry') convoEntry.setAttribute('data-pubkey', friend) convoEntry.innerText = friendList[friend] diff --git a/onionr/utils/hastor.py b/onionr/utils/hastor.py new file mode 100644 index 00000000..94a33be1 --- /dev/null +++ b/onionr/utils/hastor.py @@ -0,0 +1,6 @@ +import netcontroller + +def has_tor(): + if netcontroller.tor_binary() is None: + return False + return True \ No newline at end of file