Compare commits

...

12 Commits
0.0.7 ... 0.0.8

Author SHA1 Message Date
Mark Qvist
557ddd7d1e Updated guide. Implemented link peeking. 2021-09-11 15:39:46 +02:00
Mark Qvist
dcfcb27848 Default editor condition on Darwin 2021-09-11 13:08:54 +02:00
Mark Qvist
70910ae475 Added guide on first run 2021-09-11 12:21:35 +02:00
Mark Qvist
b49f9e7175 Added ability to clear conversation history 2021-09-11 11:33:20 +02:00
Mark Qvist
c6c471e4cd Updated readme 2021-09-11 11:11:23 +02:00
Mark Qvist
e606892ff0 Added file hosting to nodes. 2021-09-10 21:33:29 +02:00
Mark Qvist
903c75db0f Added new message indicator. 2021-09-05 20:38:10 +02:00
Mark Qvist
675946e2b7 Improved browser UI. 2021-09-03 23:34:39 +02:00
Mark Qvist
29c843509a Improved browser UI. 2021-09-03 18:55:34 +02:00
Mark Qvist
b4d056e9ef Updated RNS API calls. 2021-09-03 14:17:00 +02:00
Mark Qvist
39c2db321f Updated versions. 2021-09-02 20:43:31 +02:00
Mark Qvist
83679cae3d Improved browser UI. 2021-09-02 18:45:17 +02:00
14 changed files with 522 additions and 151 deletions

View File

@@ -7,24 +7,25 @@ Communicate Freely.
The intention with this program is to provide a tool to that allows you to build private and resilient communications platforms that are in complete control and ownership of the people that use them. The intention with this program is to provide a tool to that allows you to build private and resilient communications platforms that are in complete control and ownership of the people that use them.
Nomad Network is build on [LXMF](https://github.com/markqvist/LXMF) and [Reticulum](https://github.com/markqvist/Reticulum), which together provides the cryptographic mesh functionality and peer-to-peer message routing that Nomad Network relies on. This foundation also makes it possible to use the program over a very wide variety of communication mediums, from packet radio to gigabit fiber. Nomad Network is build on [LXMF](https://github.com/markqvist/LXMF) and [Reticulum](https://github.com/markqvist/Reticulum), which together provides the cryptographic mesh functionality and peer-to-peer message routing that Nomad Network relies on. This foundation also makes it possible to use the program over a very wide variety of communication mediums, from packet radio to fiber.
Nomad Network does not need any connections to the public internet to work. In fact, it doesn't even need an IP or Ethernet network. You can use it entirely over packet radio, LoRa or even serial lines. But if you wish, you can bridge islanded Reticulum networks over the Internet or private ethernet networks, or you can build networks running completely over the Internet. The choice is yours. Nomad Network does not need any connections to the public internet to work. In fact, it doesn't even need an IP or Ethernet network. You can use it entirely over packet radio, LoRa or even serial lines. But if you wish, you can bridge islanded Reticulum networks over the Internet or private ethernet networks, or you can build networks running completely over the Internet. The choice is yours.
## Notable Features ## Notable Features
- Encrypted messaging over packet-radio, LoRa, WiFi or anything else [Reticulum](https://github.com/markqvist/Reticulum) supports. - Encrypted messaging over packet-radio, LoRa, WiFi or anything else [Reticulum](https://github.com/markqvist/Reticulum) supports.
- Zero-configuration, minimal-infrastructure mesh communication - Zero-configuration, minimal-infrastructure mesh communication
- Connectable nodes that can host pages and files
- Built-in text-based browser for interacting with contents on nodes
- An easy to use and bandwidth efficient markup language for writing pages
## Current Status ## Current Status
The current version of the program should be considered a beta release. The program works well, but there will most probably be bugs and possibly sub-optimal performance in some scenarios. On the other hand, this is the ideal time to have an influence on the direction of the development of Nomad Network. To do so, join the discussion, report bugs and request features here on the GitHub project.
### Feature roadmap
The current version of the program should be considered an alpha release. The program works well, but there will most probably be bugs and possibly sub-optimal performance in some scenarios. On the other hand, this is the ideal time to have an influence on the direction of the development of Nomad Network. To do so, join the discussion, report bugs and request features here on the GitHub project. - Page caching in browser
- Node-side generated pages with PHP, Python, bash or others
Development is ongoing and current features being implemented are: - Access control and authentication for pages and files
- Propagated messaging and discussion threads - Propagated messaging and discussion threads
- Connectable nodes that can host pages, files and other resources
- Collaborative information sharing and spatial map-style "wikis"
## Dependencies: ## Dependencies:
- Python 3 - Python 3

View File

@@ -7,6 +7,7 @@ from nomadnet.Directory import DirectoryEntry
class Conversation: class Conversation:
cached_conversations = {} cached_conversations = {}
unread_conversations = {}
created_callback = None created_callback = None
aspect_filter = "lxmf.delivery" aspect_filter = "lxmf.delivery"
@@ -57,6 +58,16 @@ class Conversation:
conversation = Conversation.cached_conversations[RNS.hexrep(source_hash, delimit=False)] conversation = Conversation.cached_conversations[RNS.hexrep(source_hash, delimit=False)]
conversation.scan_storage() conversation.scan_storage()
if not source_hash in Conversation.unread_conversations:
Conversation.unread_conversations[source_hash] = True
try:
dirname = RNS.hexrep(source_hash, delimit=False)
open(app.conversationpath + "/" + dirname + "/unread", 'a').close()
except Exception as e:
pass
Conversation.created_callback()
return ingested_path return ingested_path
@staticmethod @staticmethod
@@ -70,6 +81,13 @@ class Conversation:
app_data = RNS.Identity.recall_app_data(source_hash) app_data = RNS.Identity.recall_app_data(source_hash)
display_name = app.directory.display_name(source_hash) display_name = app.directory.display_name(source_hash)
unread = False
if source_hash in Conversation.unread_conversations:
unread = True
elif os.path.isfile(app.conversationpath + "/" + dirname + "/unread"):
Conversation.unread_conversations[source_hash] = True
unread = True
if display_name == None and app_data: if display_name == None and app_data:
display_name = app_data.decode("utf-8") display_name = app_data.decode("utf-8")
@@ -80,7 +98,7 @@ class Conversation:
trust_level = app.directory.trust_level(source_hash, display_name) trust_level = app.directory.trust_level(source_hash, display_name)
entry = (source_hash_text, display_name, trust_level, sort_name) entry = (source_hash_text, display_name, trust_level, sort_name, unread)
conversations.append(entry) conversations.append(entry)
except Exception as e: except Exception as e:
@@ -114,6 +132,7 @@ class Conversation:
self.source_known = False self.source_known = False
self.source_trusted = False self.source_trusted = False
self.source_blocked = False self.source_blocked = False
self.unread = False
self.__changed_callback = None self.__changed_callback = None
@@ -143,6 +162,11 @@ class Conversation:
message_path = self.messages_path + "/" + filename message_path = self.messages_path + "/" + filename
self.messages.append(ConversationMessage(message_path)) self.messages.append(ConversationMessage(message_path))
new_len = len(self.messages)
if new_len > old_len:
self.unread = True
if self.__changed_callback != None: if self.__changed_callback != None:
self.__changed_callback(self) self.__changed_callback(self)
@@ -156,6 +180,15 @@ class Conversation:
for purged_message in purged_messages: for purged_message in purged_messages:
self.messages.remove(purged_message) self.messages.remove(purged_message)
def clear_history(self):
purged_messages = []
for conversation_message in self.messages:
purged_messages.append(conversation_message)
conversation_message.purge()
for purged_message in purged_messages:
self.messages.remove(purged_message)
def register_changed_callback(self, callback): def register_changed_callback(self, callback):
self.__changed_callback = callback self.__changed_callback = callback

View File

@@ -44,7 +44,6 @@ class Node:
for page in self.servedpages: for page in self.servedpages:
request_path = "/page"+page.replace(self.app.pagespath, "") request_path = "/page"+page.replace(self.app.pagespath, "")
self.destination.register_request_handler( self.destination.register_request_handler(
request_path, request_path,
response_generator = self.serve_page, response_generator = self.serve_page,
@@ -55,6 +54,14 @@ class Node:
self.servedfiles = [] self.servedfiles = []
self.scan_files(self.app.filespath) self.scan_files(self.app.filespath)
for file in self.servedfiles:
request_path = "/file"+file.replace(self.app.filespath, "")
self.destination.register_request_handler(
request_path,
response_generator = self.serve_file,
allow = RNS.Destination.ALLOW_ALL
)
def scan_pages(self, base_path): def scan_pages(self, base_path):
files = [file for file in os.listdir(base_path) if os.path.isfile(os.path.join(base_path, file)) and file[:1] != "."] files = [file for file in os.listdir(base_path) if os.path.isfile(os.path.join(base_path, file)) and file[:1] != "."]
directories = [file for file in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, file)) and file[:1] != "."] directories = [file for file in os.listdir(base_path) if os.path.isdir(os.path.join(base_path, file)) and file[:1] != "."]
@@ -76,10 +83,10 @@ class Node:
self.scan_files(base_path+"/"+directory) self.scan_files(base_path+"/"+directory)
def serve_page(self, path, data, request_id, remote_identity, requested_at): def serve_page(self, path, data, request_id, remote_identity, requested_at):
RNS.log("Request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_VERBOSE) RNS.log("Page request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_VERBOSE)
file_path = path.replace("/page", self.app.pagespath, 1) file_path = path.replace("/page", self.app.pagespath, 1)
try: try:
RNS.log("Serving file: "+file_path, RNS.LOG_VERBOSE) RNS.log("Serving page: "+file_path, RNS.LOG_VERBOSE)
fh = open(file_path, "rb") fh = open(file_path, "rb")
response_data = fh.read() response_data = fh.read()
fh.close() fh.close()
@@ -90,6 +97,22 @@ class Node:
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR) RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
return None return None
# TODO: Improve file handling, this will be slow for large files
def serve_file(self, path, data, request_id, remote_identity, requested_at):
RNS.log("File request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_VERBOSE)
file_path = path.replace("/file", self.app.filespath, 1)
file_name = path.replace("/file/", "", 1)
try:
RNS.log("Serving file: "+file_path, RNS.LOG_VERBOSE)
fh = open(file_path, "rb")
file_data = fh.read()
fh.close()
return [file_name, file_data]
except Exception as e:
RNS.log("Error occurred while handling request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_ERROR)
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
return None
def serve_default_index(self, path, data, request_id, remote_identity, requested_at): def serve_default_index(self, path, data, request_id, remote_identity, requested_at):
RNS.log("Serving default index for request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_VERBOSE) RNS.log("Serving default index for request "+RNS.prettyhexrep(request_id)+" for: "+str(path), RNS.LOG_VERBOSE)

View File

@@ -54,6 +54,10 @@ class NomadNetworkApp:
self.pagespath = self.configdir+"/storage/pages" self.pagespath = self.configdir+"/storage/pages"
self.filespath = self.configdir+"/storage/files" self.filespath = self.configdir+"/storage/files"
self.downloads_path = os.path.expanduser("~/Downloads")
self.firstrun = False
if not os.path.isdir(self.storagepath): if not os.path.isdir(self.storagepath):
os.makedirs(self.storagepath) os.makedirs(self.storagepath)
@@ -89,7 +93,7 @@ class NomadNetworkApp:
else: else:
RNS.log("Could not load config file, creating default configuration file...") RNS.log("Could not load config file, creating default configuration file...")
self.createDefaultConfig() self.createDefaultConfig()
self.firstrun = True
if os.path.isfile(self.identitypath): if os.path.isfile(self.identitypath):
try: try:
@@ -127,7 +131,7 @@ class NomadNetworkApp:
try: try:
RNS.log("No peer settings file found, creating new...") RNS.log("No peer settings file found, creating new...")
self.peer_settings = { self.peer_settings = {
"display_name": "", "display_name": "Anonymous Peer",
"announce_interval": None, "announce_interval": None,
"last_announce": None, "last_announce": None,
} }
@@ -205,6 +209,18 @@ class NomadNetworkApp:
def conversations(self): def conversations(self):
return nomadnet.Conversation.conversation_list(self) return nomadnet.Conversation.conversation_list(self)
def conversation_is_unread(self, source_hash):
if bytes.fromhex(source_hash) in nomadnet.Conversation.unread_conversations:
return True
else:
return False
def mark_conversation_read(self, source_hash):
if bytes.fromhex(source_hash) in nomadnet.Conversation.unread_conversations:
nomadnet.Conversation.unread_conversations.pop(bytes.fromhex(source_hash))
if os.path.isfile(self.conversationpath + "/" + source_hash + "/unread"):
os.unlink(self.conversationpath + "/" + source_hash + "/unread")
def createDefaultConfig(self): def createDefaultConfig(self):
self.config = ConfigObj(__default_nomadnet_config__) self.config = ConfigObj(__default_nomadnet_config__)
self.config.filename = self.configpath self.config.filename = self.configpath
@@ -242,6 +258,10 @@ class NomadNetworkApp:
value = self.config["client"].as_bool(option) value = self.config["client"].as_bool(option)
self.enable_client = value self.enable_client = value
if option == "downloads_path":
value = self.config["client"]["downloads_path"]
self.downloads_path = os.path.expanduser(value)
if option == "user_interface": if option == "user_interface":
value = value.lower() value = value.lower()
if value == "none": if value == "none":
@@ -379,6 +399,7 @@ destination = file
enable_client = yes enable_client = yes
user_interface = text user_interface = text
downloads_path = ~/Downloads
[textui] [textui]
@@ -389,15 +410,15 @@ intro_time = 1
# valid colormodes are: # valid colormodes are:
# monochrome, 16, 88, 256 and 24bit # monochrome, 16, 88, 256 and 24bit
# #
# The default is a conservative 16 colors, # The default is a conservative 256 colors.
# but 256 colors can probably be used on # If your terminal does not support this,
# most terminals. Some terminals support # you can lower it. Some terminals support
# 24 bit color. # 24 bit color.
# colormode = monochrome # colormode = monochrome
colormode = 16 # colormode = 16
# colormode = 88 # colormode = 88
# colormode = 256 colormode = 256
# colormode = 24bit # colormode = 24bit
# By default, unicode glyphs are used. If # By default, unicode glyphs are used. If

View File

@@ -1 +1 @@
__version__ = "0.0.7" __version__ = "0.0.8"

View File

@@ -18,22 +18,22 @@ THEMES = {
THEME_DARK: { THEME_DARK: {
"urwid_theme": [ "urwid_theme": [
# Style name # 16-color style # Monochrome style # 88, 256 and true-color style # Style name # 16-color style # Monochrome style # 88, 256 and true-color style
('heading', 'light gray,underline', 'default', 'underline', 'g93,underline', 'default'), ("heading", "light gray,underline", "default", "underline", "g93,underline", "default"),
('menubar', 'black', 'light gray', 'standout', '#111', '#bbb'), ("menubar", "black", "light gray", "standout", "#111", "#bbb"),
('scrollbar', 'light gray', 'default', 'standout', '#444', 'default'), ("scrollbar", "light gray", "default", "standout", "#444", "default"),
('shortcutbar', 'black', 'light gray', 'standout', '#111', '#bbb'), ("shortcutbar", "black", "light gray", "standout", "#111", "#bbb"),
('body_text', 'white', 'default', 'default', '#ddd', 'default'), ("body_text", "white", "default", "default", "#ddd", "default"),
('error_text', 'dark red', 'default', 'default', 'dark red', 'default'), ("error_text", "dark red", "default", "default", "dark red", "default"),
('warning_text', 'yellow', 'default', 'default', '#ba4', 'default'), ("warning_text", "yellow", "default", "default", "#ba4", "default"),
('inactive_text', 'dark gray', 'default', 'default', 'dark gray', 'default'), ("inactive_text", "dark gray", "default", "default", "dark gray", "default"),
('buttons', 'light green,bold', 'default', 'default', '#00a533', 'default'), ("buttons", "light green,bold", "default", "default", "#00a533", "default"),
('msg_editor', 'black', 'light cyan', 'standout', '#111', '#0bb'), ("msg_editor", "black", "light cyan", "standout", "#111", "#0bb"),
("msg_header_ok", 'black', 'light green', 'standout', '#111', '#6b2'), ("msg_header_ok", "black", "light green", "standout", "#111", "#6b2"),
("msg_header_caution", 'black', 'yellow', 'standout', '#111', '#fd3'), ("msg_header_caution", "black", "yellow", "standout", "#111", "#fd3"),
("msg_header_sent", 'black', 'light gray', 'standout', '#111', '#ddd'), ("msg_header_sent", "black", "light gray", "standout", "#111", "#ddd"),
("msg_header_delivered", 'black', 'light blue', 'standout', '#111', '#28b'), ("msg_header_delivered", "black", "light blue", "standout", "#111", "#28b"),
("msg_header_failed", 'black', 'dark gray', 'standout', '#000', "#777"), ("msg_header_failed", "black", "dark gray", "standout", "#000", "#777"),
("msg_warning_untrusted", 'black', 'dark red', 'standout', '#111', 'dark red'), ("msg_warning_untrusted", "black", "dark red", "standout", "#111", "dark red"),
("list_focus", "black", "light gray", "standout", "#111", "#aaa"), ("list_focus", "black", "light gray", "standout", "#111", "#aaa"),
("list_off_focus", "black", "dark gray", "standout", "#111", "#777"), ("list_off_focus", "black", "dark gray", "standout", "#111", "#777"),
("list_trusted", "dark green", "default", "default", "#6b2", "default"), ("list_trusted", "dark green", "default", "default", "#6b2", "default"),
@@ -43,7 +43,7 @@ THEMES = {
("list_untrusted", "dark red", "default", "default", "#a22", "default"), ("list_untrusted", "dark red", "default", "default", "#a22", "default"),
("list_focus_untrusted", "black", "light gray", "standout", "#810", "#aaa"), ("list_focus_untrusted", "black", "light gray", "standout", "#810", "#aaa"),
("topic_list_normal", "white", "default", "default", "#ddd", "default"), ("topic_list_normal", "white", "default", "default", "#ddd", "default"),
('browser_controls', "light gray", 'default', 'default', '#bbb', 'default'), ("browser_controls", "light gray", "default", "default", "#bbb", "default"),
("progress_full", "black", "light gray", "standout", "#111", "#bbb"), ("progress_full", "black", "light gray", "standout", "#111", "#bbb"),
("progress_empty", "light gray", "default", "default", "#ddd", "default"), ("progress_empty", "light gray", "default", "default", "#ddd", "default"),
], ],
@@ -69,6 +69,7 @@ GLYPHS = {
("arrow_d", "\\/", "\u2193", "\u2193"), ("arrow_d", "\\/", "\u2193", "\u2193"),
("warning", "!", "\u26a0", "\uf12a"), ("warning", "!", "\u26a0", "\uf12a"),
("info", "i", "\u2139", "\ufb4d"), ("info", "i", "\u2139", "\ufb4d"),
("unread", "N", "\u2709", "\uf003 "),
("divider1", "-", "\u2504", "\u2504"), ("divider1", "-", "\u2504", "\u2504"),
("peer", "P", "\U0001F464", "\uf415"), ("peer", "P", "\U0001F464", "\uf415"),
("node", "N", "\U0001F5A5", "\uf502"), ("node", "N", "\U0001F5A5", "\uf502"),

View File

@@ -1,4 +1,5 @@
import RNS import RNS
import os
import time import time
import urwid import urwid
import nomadnet import nomadnet
@@ -6,9 +7,6 @@ import threading
from .MicronParser import markup_to_attrmaps from .MicronParser import markup_to_attrmaps
from nomadnet.vendor.Scrollable import * from nomadnet.vendor.Scrollable import *
# TODO: REMOVE
import os
class BrowserFrame(urwid.Frame): class BrowserFrame(urwid.Frame):
def keypress(self, size, key): def keypress(self, size, key):
if key == "ctrl w": if key == "ctrl w":
@@ -26,19 +24,20 @@ class BrowserFrame(urwid.Frame):
class Browser: class Browser:
DEFAULT_PATH = "/page/index.mu" DEFAULT_PATH = "/page/index.mu"
DEFAULT_TIMEOUT = 5 DEFAULT_TIMEOUT = 10
NO_PATH = 0x00 NO_PATH = 0x00
PATH_REQUESTED = 0x01 PATH_REQUESTED = 0x01
ESTABLISHING_LINK = 0x02 ESTABLISHING_LINK = 0x02
LINK_ESTABLISHED = 0x03 LINK_TIMEOUT = 0x03
REQUESTING = 0x04 LINK_ESTABLISHED = 0x04
REQUEST_SENT = 0x05 REQUESTING = 0x05
REQUEST_FAILED = 0x06 REQUEST_SENT = 0x06
REQUEST_TIMEOUT = 0x07 REQUEST_FAILED = 0x07
RECEIVING_RESPONSE = 0x08 REQUEST_TIMEOUT = 0x08
DONE = 0xFF RECEIVING_RESPONSE = 0x09
DISCONECTED = 0xFE DISCONECTED = 0xFE
DONE = 0xFF
def __init__(self, app, app_name, aspects, destination_hash = None, path = None, auth_identity = None, delegate = None): def __init__(self, app, app_name, aspects, destination_hash = None, path = None, auth_identity = None, delegate = None):
self.app = app self.app = app
@@ -56,10 +55,13 @@ class Browser:
self.response_progress = 0 self.response_progress = 0
self.response_size = None self.response_size = None
self.response_transfer_size = None self.response_transfer_size = None
self.saved_file_name = None
self.page_data = None self.page_data = None
self.displayed_page_data = None self.displayed_page_data = None
self.auth_identity = auth_identity self.auth_identity = auth_identity
self.display_widget = None self.display_widget = None
self.link_status_showing = False
self.link_target = None
self.frame = None self.frame = None
self.attr_maps = [] self.attr_maps = []
self.build_display() self.build_display()
@@ -80,13 +82,35 @@ class Browser:
path = self.path path = self.path
return RNS.hexrep(self.destination_hash, delimit=False)+":"+path return RNS.hexrep(self.destination_hash, delimit=False)+":"+path
def marked_link(self, link_target):
self.link_target = link_target
self.app.ui.loop.set_alarm_in(0.1, self.marked_link_job)
def marked_link_job(self, sender, event):
link_target = self.link_target
if link_target == None:
if self.link_status_showing:
self.browser_footer = self.make_status_widget()
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
self.link_status_showing = False
else:
self.link_status_showing = True
self.browser_footer = urwid.AttrMap(urwid.Pile([urwid.Divider(self.g["divider1"]), urwid.Text("Link to: "+str(link_target))]), "browser_controls")
self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
def handle_link(self, link_target): def handle_link(self, link_target):
if self.status >= Browser.DISCONECTED:
RNS.log("Browser handling link to: "+str(link_target), RNS.LOG_DEBUG) RNS.log("Browser handling link to: "+str(link_target), RNS.LOG_DEBUG)
try: try:
self.retrieve_url(link_target) self.retrieve_url(link_target)
except Exception as e: except Exception as e:
self.browser_footer = urwid.Text("Could not open link: "+str(e)) self.browser_footer = urwid.Text("Could not open link: "+str(e))
self.frame.contents["footer"] = (self.browser_footer, self.frame.options()) self.frame.contents["footer"] = (self.browser_footer, self.frame.options())
else:
RNS.log("Browser aleady hadling link, cannot handle link to: "+str(link_target), RNS.LOG_DEBUG)
def micron_released_focus(self): def micron_released_focus(self):
@@ -101,7 +125,8 @@ class Browser:
self.frame = BrowserFrame(self.browser_body, header=self.browser_header, footer=self.browser_footer) self.frame = BrowserFrame(self.browser_body, header=self.browser_header, footer=self.browser_footer)
self.frame.delegate = self self.frame.delegate = self
self.display_widget = urwid.AttrMap(urwid.LineBox(self.frame, title="Remote Node"), "inactive_text") self.linebox = urwid.LineBox(self.frame, title="Remote Node")
self.display_widget = urwid.AttrMap(self.linebox, "inactive_text")
def make_status_widget(self): def make_status_widget(self):
if self.response_progress > 0: if self.response_progress > 0:
@@ -146,14 +171,20 @@ class Browser:
self.browser_body = urwid.Filler(urwid.Text("Disconnected\n"+self.g["arrow_l"]+" "+self.g["arrow_r"], align="center"), "middle") self.browser_body = urwid.Filler(urwid.Text("Disconnected\n"+self.g["arrow_l"]+" "+self.g["arrow_r"], align="center"), "middle")
self.browser_footer = urwid.Text("") self.browser_footer = urwid.Text("")
self.browser_header = urwid.Text("") self.browser_header = urwid.Text("")
self.linebox.set_title("Remote Node")
else: else:
self.display_widget.set_attr_map({None: "body_text"}) self.display_widget.set_attr_map({None: "body_text"})
self.browser_header = self.make_control_widget() self.browser_header = self.make_control_widget()
self.linebox.set_title(self.app.directory.simplest_display_str(self.destination_hash))
if self.status == Browser.DONE: if self.status == Browser.DONE:
self.browser_footer = self.make_status_widget() self.browser_footer = self.make_status_widget()
self.update_page_display() self.update_page_display()
elif self.status == Browser.LINK_TIMEOUT:
self.browser_body = self.make_request_failed_widget()
self.browser_footer = urwid.Text("")
elif self.status <= Browser.REQUEST_SENT: elif self.status <= Browser.REQUEST_SENT:
if len(self.attr_maps) == 0: if len(self.attr_maps) == 0:
self.browser_body = urwid.Filler(urwid.Text("Retrieving\n["+self.current_url()+"]", align="center"), "middle") self.browser_body = urwid.Filler(urwid.Text("Retrieving\n["+self.current_url()+"]", align="center"), "middle")
@@ -177,7 +208,7 @@ class Browser:
def update_page_display(self): def update_page_display(self):
pile = urwid.Pile(self.attr_maps) pile = urwid.Pile(self.attr_maps)
self.browser_body = urwid.AttrMap(ScrollBar(Scrollable(pile), thumb_char="\u2503", trough_char=" "), "scrollbar") self.browser_body = urwid.AttrMap(ScrollBar(Scrollable(pile, force_forward_keypress=True), thumb_char="\u2503", trough_char=" "), "scrollbar")
def identify(self): def identify(self):
if self.link != None: if self.link != None:
@@ -239,6 +270,13 @@ class Browser:
raise ValueError("Malformed URL") raise ValueError("Malformed URL")
if destination_hash != None and path != None: if destination_hash != None and path != None:
if path.startswith("/file/"):
if destination_hash == self.destination_hash:
self.download_file(destination_hash, path)
else:
RNS.log("Cannot request file download from a node that is not currently connected.", RNS.LOG_ERROR)
RNS.log("The requested URL was: "+str(url), RNS.LOG_ERROR)
else:
self.set_destination_hash(destination_hash) self.set_destination_hash(destination_hash)
self.set_path(path) self.set_path(path)
self.load_page() self.load_page()
@@ -259,6 +297,33 @@ class Browser:
self.timeout = timeout self.timeout = timeout
def download_file(self, destination_hash, path):
if self.link != None and self.link.destination.hash == self.destination_hash:
# Send the request
self.status = Browser.REQUESTING
self.response_progress = 0
self.response_size = None
self.response_transfer_size = None
self.saved_file_name = None
self.update_display()
receipt = self.link.request(
path,
data = None,
response_callback = self.file_received,
failed_callback = self.request_failed,
progress_callback = self.response_progressed
)
if receipt:
self.last_request_receipt = receipt
self.last_request_id = receipt.request_id
self.status = Browser.REQUEST_SENT
self.update_display()
else:
self.link.teardown()
def load_page(self): def load_page(self):
load_thread = threading.Thread(target=self.__load) load_thread = threading.Thread(target=self.__load)
load_thread.setDaemon(True) load_thread.setDaemon(True)
@@ -269,7 +334,7 @@ class Browser:
# If an established link exists, but it doesn't match the target # If an established link exists, but it doesn't match the target
# destination, we close and clear it. # destination, we close and clear it.
if self.link != None and self.link.destination.hash != self.destination_hash: if self.link != None and self.link.destination.hash != self.destination_hash:
self.link.close() self.link.teardown()
self.link = None self.link = None
# If no link to the destination exists, we create one. # If no link to the destination exists, we create one.
@@ -305,14 +370,11 @@ class Browser:
self.link = RNS.Link(destination, established_callback = self.link_established, closed_callback = self.link_closed) self.link = RNS.Link(destination, established_callback = self.link_established, closed_callback = self.link_closed)
l_time = time.time() while self.status == Browser.ESTABLISHING_LINK:
while not self.status == Browser.LINK_ESTABLISHED: time.sleep(0.1)
now = time.time()
if now > l_time+self.timeout:
self.request_timeout()
return
time.sleep(0.25) if self.status != Browser.LINK_ESTABLISHED:
return
self.update_display() self.update_display()
@@ -321,6 +383,8 @@ class Browser:
self.response_progress = 0 self.response_progress = 0
self.response_size = None self.response_size = None
self.response_transfer_size = None self.response_transfer_size = None
self.saved_file_name = None
self.update_display() self.update_display()
receipt = self.link.request( receipt = self.link.request(
@@ -328,15 +392,17 @@ class Browser:
data = None, data = None,
response_callback = self.response_received, response_callback = self.response_received,
failed_callback = self.request_failed, failed_callback = self.request_failed,
progress_callback = self.response_progressed, progress_callback = self.response_progressed
timeout = self.timeout
) )
if receipt:
self.last_request_receipt = receipt self.last_request_receipt = receipt
self.last_request_id = receipt.request_id self.last_request_id = receipt.request_id
self.status = Browser.REQUEST_SENT self.status = Browser.REQUEST_SENT
self.update_display() self.update_display()
else:
self.link.teardown()
def link_established(self, link): def link_established(self, link):
@@ -346,11 +412,22 @@ class Browser:
def link_closed(self, link): def link_closed(self, link):
if self.status == Browser.DISCONECTED or self.status == Browser.DONE: if self.status == Browser.DISCONECTED or self.status == Browser.DONE:
self.link = None self.link = None
elif self.status == Browser.ESTABLISHING_LINK:
self.link_establishment_timeout()
else: else:
self.link = None self.link = None
self.status = Browser.REQUEST_FAILED self.status = Browser.REQUEST_FAILED
self.update_display() self.update_display()
def link_establishment_timeout(self):
self.status = Browser.LINK_TIMEOUT
self.response_progress = 0
self.response_size = None
self.response_transfer_size = None
self.link = None
self.update_display()
def response_received(self, request_receipt): def response_received(self, request_receipt):
try: try:
@@ -365,6 +442,30 @@ class Browser:
RNS.log("An error occurred while handling response. The contained exception was: "+str(e)) RNS.log("An error occurred while handling response. The contained exception was: "+str(e))
def file_received(self, request_receipt):
try:
file_name = request_receipt.response[0]
file_data = request_receipt.response[1]
file_destination = self.app.downloads_path+"/"+file_name
counter = 0
while os.path.isfile(file_destination):
counter += 1
file_destination = self.app.downloads_path+"/"+file_name+"."+str(counter)
fh = open(file_destination, "wb")
fh.write(file_data)
fh.close()
self.saved_file_name = file_destination.replace(self.app.downloads_path+"/", "", 1)
self.status = Browser.DONE
self.response_progress = 0
self.update_display()
except Exception as e:
RNS.log("An error occurred while handling file response. The contained exception was: "+str(e))
def request_failed(self, request_receipt=None): def request_failed(self, request_receipt=None):
if request_receipt != None: if request_receipt != None:
if request_receipt.request_id == self.last_request_id: if request_receipt.request_id == self.last_request_id:
@@ -394,15 +495,19 @@ class Browser:
def response_progressed(self, request_receipt): def response_progressed(self, request_receipt):
self.response_progress = request_receipt.progress self.response_progress = request_receipt.progress
self.response_time = request_receipt.response_time() self.response_time = request_receipt.get_response_time()
self.response_size = request_receipt.response_size self.response_size = request_receipt.response_size
self.response_transfer_size = request_receipt.response_transfer_size self.response_transfer_size = request_receipt.response_transfer_size
self.update_display() self.update_display()
def status_text(self): def status_text(self):
if self.response_transfer_size != None: if self.status == Browser.DONE and self.response_transfer_size != None:
if self.response_time != None:
response_time_str = "{:.2f}".format(self.response_time) response_time_str = "{:.2f}".format(self.response_time)
else:
response_time_str = "None"
stats_string = " "+self.g["page"]+size_str(self.response_size) stats_string = " "+self.g["page"]+size_str(self.response_size)
stats_string += " "+self.g["arrow_d"]+size_str(self.response_transfer_size)+" in "+response_time_str stats_string += " "+self.g["arrow_d"]+size_str(self.response_transfer_size)+" in "+response_time_str
stats_string += "s "+self.g["speed"]+size_str(self.response_transfer_size/self.response_time, suffix="b")+"/s" stats_string += "s "+self.g["speed"]+size_str(self.response_transfer_size/self.response_time, suffix="b")+"/s"
@@ -415,6 +520,8 @@ class Browser:
return "Path requested, waiting for path..." return "Path requested, waiting for path..."
elif self.status == Browser.ESTABLISHING_LINK: elif self.status == Browser.ESTABLISHING_LINK:
return "Establishing link..." return "Establishing link..."
elif self.status == Browser.LINK_TIMEOUT:
return "Link establishment timed out"
elif self.status == Browser.LINK_ESTABLISHED: elif self.status == Browser.LINK_ESTABLISHED:
return "Link established" return "Link established"
elif self.status == Browser.REQUESTING: elif self.status == Browser.REQUESTING:
@@ -428,7 +535,10 @@ class Browser:
elif self.status == Browser.RECEIVING_RESPONSE: elif self.status == Browser.RECEIVING_RESPONSE:
return "Receiving response..." return "Receiving response..."
elif self.status == Browser.DONE: elif self.status == Browser.DONE:
if self.saved_file_name == None:
return "Done"+stats_string return "Done"+stats_string
else:
return "Saved "+str(self.saved_file_name)+stats_string
elif self.status == Browser.DISCONECTED: elif self.status == Browser.DISCONECTED:
return "Disconnected" return "Disconnected"
else: else:

View File

@@ -1,5 +1,6 @@
import nomadnet import nomadnet
import urwid import urwid
import platform
class ConfigDisplayShortcuts(): class ConfigDisplayShortcuts():
def __init__(self, app): def __init__(self, app):
@@ -50,6 +51,12 @@ class EditorTerminal(urwid.WidgetWrap):
self.app = app self.app = app
self.parent = parent self.parent = parent
editor_cmd = self.app.config["textui"]["editor"] editor_cmd = self.app.config["textui"]["editor"]
# The "editor" alias is unavailable on Darwin,
# so we replace it with nano.
if platform.system() == "Darwin" and editor_cmd == "editor":
editor_cmd = "nano"
self.term = urwid.Terminal( self.term = urwid.Terminal(
(editor_cmd, self.app.configpath), (editor_cmd, self.app.configpath),
encoding='utf-8', encoding='utf-8',

View File

@@ -1,4 +1,5 @@
import RNS import RNS
import os
import time import time
import nomadnet import nomadnet
import LXMF import LXMF
@@ -19,7 +20,7 @@ class ConversationDisplayShortcuts():
def __init__(self, app): def __init__(self, app):
self.app = app self.app = app
self.widget = urwid.AttrMap(urwid.Text("[C-d] Send [C-k] Clear [C-w] Close [C-t] Editor Type [C-p] Purge"), "shortcutbar") self.widget = urwid.AttrMap(urwid.Text("[C-d] Send [C-k] Clear Editor [C-w] Close [C-t] Editor Type [C-p] Purge [C-x] Clear History"), "shortcutbar")
class ConversationsArea(urwid.LineBox): class ConversationsArea(urwid.LineBox):
def keypress(self, size, key): def keypress(self, size, key):
@@ -86,7 +87,6 @@ class ConversationsDisplay():
for conversation in self.app.conversations(): for conversation in self.app.conversations():
conversation_list_widgets.append(self.conversation_list_widget(conversation)) conversation_list_widgets.append(self.conversation_list_widget(conversation))
walker = urwid.SimpleFocusListWalker(conversation_list_widgets)
self.list_widgets = conversation_list_widgets self.list_widgets = conversation_list_widgets
self.ilb = IndicativeListBox( self.ilb = IndicativeListBox(
self.list_widgets, self.list_widgets,
@@ -316,17 +316,43 @@ class ConversationsDisplay():
self.ilb.select_item(ilb_position) self.ilb.select_item(ilb_position)
nomadnet.NomadNetworkApp.get_shared_instance().ui.loop.draw_screen() nomadnet.NomadNetworkApp.get_shared_instance().ui.loop.draw_screen()
if self.currently_displayed_conversation != None:
if self.app.conversation_is_unread(self.currently_displayed_conversation):
self.app.mark_conversation_read(self.currently_displayed_conversation)
try:
if os.path.isfile(self.app.conversationpath + "/" + self.currently_displayed_conversation + "/unread"):
os.unlink(self.app.conversationpath + "/" + self.currently_displayed_conversation + "/unread")
except Exception as e:
raise e
def display_conversation(self, sender=None, source_hash=None): def display_conversation(self, sender=None, source_hash=None):
if self.currently_displayed_conversation != None:
if self.app.conversation_is_unread(self.currently_displayed_conversation):
self.app.mark_conversation_read(self.currently_displayed_conversation)
self.currently_displayed_conversation = source_hash self.currently_displayed_conversation = source_hash
options = self.widget.options("weight", 1-ConversationsDisplay.list_width) options = self.widget.options("weight", 1-ConversationsDisplay.list_width)
self.widget.contents[1] = (self.make_conversation_widget(source_hash), options) self.widget.contents[1] = (self.make_conversation_widget(source_hash), options)
if source_hash == None: if source_hash == None:
self.widget.set_focus_column(0) self.widget.set_focus_column(0)
else: else:
if self.app.conversation_is_unread(source_hash):
self.app.mark_conversation_read(source_hash)
self.update_conversation_list()
self.widget.set_focus_column(1) self.widget.set_focus_column(1)
conversation_position = None
index = 0
for widget in self.list_widgets:
if widget.source_hash == source_hash:
conversation_position = index
index += 1
if conversation_position != None:
self.ilb.select_item(conversation_position)
def make_conversation_widget(self, source_hash): def make_conversation_widget(self, source_hash):
@@ -364,6 +390,7 @@ class ConversationsDisplay():
trust_level = conversation[2] trust_level = conversation[2]
display_name = conversation[1] display_name = conversation[1]
source_hash = conversation[0] source_hash = conversation[0]
unread = conversation[4]
g = self.app.ui.glyphs g = self.app.ui.glyphs
@@ -389,11 +416,17 @@ class ConversationsDisplay():
focus_style = "list_focus_untrusted" focus_style = "list_focus_untrusted"
display_text = symbol display_text = symbol
if display_name != None and display_name != "": if display_name != None and display_name != "":
display_text += " "+display_name display_text += " "+display_name
if trust_level != DirectoryEntry.TRUSTED: if trust_level != DirectoryEntry.TRUSTED:
display_text += " <"+source_hash+">" display_text += " <"+source_hash+">"
else:
if unread:
if source_hash != self.currently_displayed_conversation:
display_text += " "+g["unread"]
widget = ListEntry(display_text) widget = ListEntry(display_text)
urwid.connect_signal(widget, "click", self.display_conversation, conversation[0]) urwid.connect_signal(widget, "click", self.display_conversation, conversation[0])
@@ -544,6 +577,31 @@ class ConversationWidget(urwid.WidgetWrap):
urwid.WidgetWrap.__init__(self, self.display_widget) urwid.WidgetWrap.__init__(self, self.display_widget)
def clear_history_dialog(self):
def dismiss_dialog(sender):
self.dialog_open = False
self.conversation_changed(None)
def confirmed(sender):
self.dialog_open = False
self.conversation.clear_history()
self.conversation_changed(None)
dialog = DialogLineBox(
urwid.Pile([
urwid.Text("Clear conversation history\n", align="center"),
urwid.Columns([("weight", 0.45, urwid.Button("Yes", on_press=confirmed)), ("weight", 0.1, urwid.Text("")), ("weight", 0.45, urwid.Button("No", on_press=dismiss_dialog))])
]), title="?"
)
dialog.delegate = self
bottom = self.messagelist
overlay = urwid.Overlay(dialog, bottom, align="center", width=34, valign="middle", height="pack", left=2, right=2)
self.frame.contents["body"] = (overlay, self.frame.options())
self.frame.set_focus("body")
def toggle_editor(self): def toggle_editor(self):
if self.full_editor_active: if self.full_editor_active:
self.frame.contents["footer"] = (self.minimal_editor, None) self.frame.contents["footer"] = (self.minimal_editor, None)
@@ -559,7 +617,7 @@ class ConversationWidget(urwid.WidgetWrap):
if allowed: if allowed:
self.frame.contents["footer"] = (self.minimal_editor, None) self.frame.contents["footer"] = (self.minimal_editor, None)
else: else:
warning = urwid.AttrMap(urwid.Padding(urwid.Text(g["info"]+" You cannot currently communicate with this peer, since it's identity keys are unknown", align="center")), "msg_header_caution") warning = urwid.AttrMap(urwid.Padding(urwid.Text(g["info"]+" You cannot currently communicate with this peer, since it's identity keys are not known", align="center")), "msg_header_caution")
self.frame.contents["footer"] = (warning, None) self.frame.contents["footer"] = (warning, None)
def toggle_focus_area(self): def toggle_focus_area(self):
@@ -584,6 +642,8 @@ class ConversationWidget(urwid.WidgetWrap):
self.conversation_changed(None) self.conversation_changed(None)
elif key == "ctrl t": elif key == "ctrl t":
self.toggle_editor() self.toggle_editor()
elif key == "ctrl x":
self.clear_history_dialog()
else: else:
return super(ConversationWidget, self).keypress(size, key) return super(ConversationWidget, self).keypress(size, key)

View File

@@ -61,14 +61,16 @@ class SelectText(urwid.Text):
return True return True
class GuideEntry(urwid.WidgetWrap): class GuideEntry(urwid.WidgetWrap):
def __init__(self, app, reader, topic_name): def __init__(self, app, parent, reader, topic_name):
self.app = app self.app = app
self.parent = parent
self.reader = reader self.reader = reader
self.last_keypress = None self.last_keypress = None
self.topic_name = topic_name
g = self.app.ui.glyphs g = self.app.ui.glyphs
widget = ListEntry(topic_name) widget = ListEntry(topic_name)
urwid.connect_signal(widget, "click", self.display_topic, topic_name) urwid.connect_signal(widget, "click", self.display_topic, self.topic_name)
style = "topic_list_normal" style = "topic_list_normal"
focus_style = "list_focus" focus_style = "list_focus"
@@ -79,7 +81,20 @@ class GuideEntry(urwid.WidgetWrap):
markup = TOPICS[topic] markup = TOPICS[topic]
attrmaps = markup_to_attrmaps(markup, url_delegate=None) attrmaps = markup_to_attrmaps(markup, url_delegate=None)
topic_position = None
index = 0
for topic in self.parent.topic_list:
widget = topic._original_widget
if widget.topic_name == self.topic_name:
topic_position = index
index += 1
if topic_position != None:
self.parent.ilb.select_item(topic_position)
self.reader.set_content_widgets(attrmaps) self.reader.set_content_widgets(attrmaps)
self.reader.focus_reader()
def micron_released_focus(self): def micron_released_focus(self):
self.reader.focus_topics() self.reader.focus_topics()
@@ -89,17 +104,20 @@ class TopicList(urwid.WidgetWrap):
self.app = app self.app = app
g = self.app.ui.glyphs g = self.app.ui.glyphs
self.first_run_entry = GuideEntry(self.app, self, guide_display, "First Run")
self.topic_list = [ self.topic_list = [
GuideEntry(self.app, guide_display, "Introduction"), GuideEntry(self.app, self, guide_display, "Introduction"),
# GuideEntry(self.app, guide_display, "Conversations"), GuideEntry(self.app, self, guide_display, "Hosting a Node"),
GuideEntry(self.app, guide_display, "Markup"), GuideEntry(self.app, self, guide_display, "Markup"),
GuideEntry(self.app, guide_display, "First Run"), self.first_run_entry,
GuideEntry(self.app, guide_display, "Credits & Licenses"), GuideEntry(self.app, self, guide_display, "Credits & Licenses"),
] ]
self.ilb = IndicativeListBox( self.ilb = IndicativeListBox(
self.topic_list, self.topic_list,
initialization_is_selection_change=False, initialization_is_selection_change=False,
highlight_offFocus="list_off_focus"
) )
urwid.WidgetWrap.__init__(self, urwid.LineBox(self.ilb, title="Topics")) urwid.WidgetWrap.__init__(self, urwid.LineBox(self.ilb, title="Topics"))
@@ -118,7 +136,7 @@ class GuideDisplay():
self.app = app self.app = app
g = self.app.ui.glyphs g = self.app.ui.glyphs
topic_text = urwid.Text("\nNo topic selected", align="left") topic_text = urwid.Text("\n No topic selected", align="left")
self.left_area = TopicList(self.app, self) self.left_area = TopicList(self.app, self)
self.right_area = urwid.LineBox(urwid.Filler(topic_text, "top")) self.right_area = urwid.LineBox(urwid.Filler(topic_text, "top"))
@@ -135,6 +153,10 @@ class GuideDisplay():
self.shortcuts_display = GuideDisplayShortcuts(self.app) self.shortcuts_display = GuideDisplayShortcuts(self.app)
self.widget = self.columns self.widget = self.columns
if self.app.firstrun:
entry = self.left_area.first_run_entry
entry.display_topic(entry.display_topic, entry.topic_name)
def set_content_widgets(self, new_content): def set_content_widgets(self, new_content):
options = self.columns.options(width_type="weight", width_amount=1-GuideDisplay.list_width) options = self.columns.options(width_type="weight", width_amount=1-GuideDisplay.list_width)
pile = urwid.Pile(new_content) pile = urwid.Pile(new_content)
@@ -149,6 +171,9 @@ class GuideDisplay():
def focus_topics(self): def focus_topics(self):
self.columns.focus_position = 0 self.columns.focus_position = 0
def focus_reader(self):
self.columns.focus_position = 1
TOPIC_INTRODUCTION = '''>Nomad Network TOPIC_INTRODUCTION = '''>Nomad Network
@@ -195,11 +220,111 @@ If no nodes exist on a network, all peers will still be able to communicate dire
''' '''
TOPIC_HOSTING = '''>Hosting a Node
To host a node on the network, you must enable it in the configuration file, by setting `*enable_node`* directive to `*yes`*. You should also configure the other node-related parameters such as the node name and announce interval settings. Once node hosting has been enabled in the configuration, Nomad Network will start hosting your node as soon as the program is lauched, and other peers on the network will be able to connect and interact with content on your node.
By default, no content is defined, apart from a short placeholder home page. To learn how to add your own content, read on.
>>Pages
Nomad Network nodes can host pages similar to web pages, that other peers can read and interact with. Pages are written in a compact markup language called `*micron`*. To learn how to write formatted pages with micron, see the `*Markup`* section of this guide (which is, itself, written in micron). Pages can be linked arbitrarily with hyperlinks, that can also link to pages (or other resources) on other nodes.
To add pages to your node, place micron files in the `*pages`* directory of your Nomad Network programs `*storage`* directory. By default, the path to this will be `!~/.nomadnetwork/storage/pages`!. You should probably create the file `!index.mu`! first, as this is the page that will get served by default to a connecting peer.
Pages are static in this version, but the next release of Nomad Network will add the ability to use a preprocessor such as PHP, bash, Python (or whatever you prefer) to generate dynamic pages.
>>Files
Like pages, you can place files you want to make available in the `!~/.nomadnetwork/storage/files`! directory. To let a peer download a file, you should create a link to it in one of your pages.
>>Links and URLs
Links to pages and resources in Nomad Network use a simple URL format. Here is an example:
`!1385edace36466a6b3dd:/page/index.mu`!
The first part is the 10 byte destination address of the node (represented as readable hexadecimal), followed by the `!:`! character. Everything after the `!:`! represents the request path.
By convention, Nomad Network nodes maps all hosted pages under the `!/page`! path, and all hosted files under the `!/file`! path. You can create as many subdirectories for pages and files as you please, and they will be automatically mapped to corresponding request paths.
You can omit the destination address of the node, if you are reffering to a local page or file. You must still keep the `!:`! character. In such a case, the URL to a page could look like this:
`!:/page/other_page.mu`!
The URL to a local file could look like this:
`!:/file/document.pdf`!
Links can be inserted into micron documents. See the `*Markup`* section of this guide for info on how to do so.
'''
TOPIC_CONVERSATIONS = '''>Conversations TOPIC_CONVERSATIONS = '''>Conversations
Conversations in Nomad Network Conversations in Nomad Network
''' '''
TOPIC_FIRST_RUN = '''>First Time Information
Hi there. This first run message will only appear once. It contains a few pointers on getting started with Nomad Network, and getting the most out of the program.
You're currently located in the guide section of the program. I'm sorry I had to drag you here by force, but it will only happen this one time, I promise. If you ever get lost, return here and peruse the list of topics you see on the left. I will do my best to fill it with answers to mostly anything about Nomad Network.
To get the most out of Nomad Network, you will need a terminal that supports UTF-8 and at least 256 colors, ideally true-color. If your terminal supports true-color, you can go to the `![ Config ]`! menu item, launch the editor and change the configuration.
If you don't already have a Nerd Font installed (see https://www.nerdfonts.com/), I also highly recommend to do so, since it will greatly expand the amount of glyphs, icons and graphics that Nomad Network can use. Once you have your terminal set up with a Nerd Font, go to the `![ Config ]`! menu item and enable Nerd Fonts in the configuration instead of normal unicode glyphs.
Nomad Network expects that you are already connected to some form of Reticulum network. That could be as simple as the default UDP-based demo interface on your local ethernet network. This short guide won't go into any details on building, but you will find other entries in the guide that deal with network setup and configuration.
At least, if Nomad Network launches, it means that it is connected to a running Reticulum instance, that should in turn be connected to `*something`*, which should get you started.
For more some more information, you can also read the `*Introduction`* section of this guide.
Now go out there and explore. This is still early days. See what you can find and create.
>>>>>>>>>>>>>>>
-\u223f
<
'''
TOPIC_LICENSES = '''>Thanks, Acknowledgements and Licenses
This program uses various other software components, without which Nomad Network would not have been possible. Sincere thanks to the authors and contributors of the following projects
>>>
- `!Cryptography.io`! by `*pyca`*
https://cryptography.io/
BSD License
- `!Urwid`! by `*Ian Ward`*
http://urwid.org/
LGPL-2.1 License
- `!Additional Urwid Widgets`! by `*AFoeee`*
https://github.com/AFoeee/additional_urwid_widgets
MIT License
- `!Scrollable`! by `*rndusr`*
https://github.com/rndusr/stig/blob/master/stig/tui/scroll.py
GPLv3 License
- `!Configobj`! by `*Michael Foord`*
https://github.com/DiffSK/configobj
BSD License
- `!Reticulum Network Stack`! by `*unsignedmark`*
https://github.com/markqvist/Reticulum
MIT License
- `!LXMF`! by `*unsignedmark`*
https://github.com/markqvist/LXMF
MIT License
'''
TOPIC_MARKUP = '''>Outputting Formatted Text TOPIC_MARKUP = '''>Outputting Formatted Text
@@ -398,6 +523,36 @@ You can use `B5d5`F222 color `f`B333 `Ff00f`Ff80o`Ffd0r`F9f0m`F0f2a`F0fdt`F07ft`
`` ``
>Links
Links to pages, files or other resources can be created with the \\`[ tag, which should always be terminated with a closing ]. You can create links with and without labels, it is up to you to control the formatting of links with other tags. Although not strictly necessary, it is good practice to at least format links with underlining.
Here's a few examples:
`Faaa
`=
Here is a link without any label: `[1385edace36466a6b3dd:/page/index.mu]
This is a `[labeled link`1385edace36466a6b3dd:/page/index.mu] to the same page, but it's hard to see if you don't know it
Here is `F00a`_`[a more visible link`1385edace36466a6b3dd:/page/index.mu]`_`f
`=
``
The above markup produces the following output:
`Faaa`B333
Here is a link without any label: `[1385edace36466a6b3dd:/page/index.mu]
This is a `[labeled link`1385edace36466a6b3dd:/page/index.mu] to the same page, but it's hard to see if you don't know it
Here is `F00f`_`[a more visible link`1385edace36466a6b3dd:/page/index.mu]`_`f
``
When links like these are displayed in the built-in browser, clicking on them or activating them using the keyboard will cause the browser to load the specified URL.
>Literals >Literals
To display literal content, for example source-code, or blocks of text that should not be interpreted by micron, you can use literal blocks, specified by the \\`= tag. Below is the source code of this entire document, presented as a literal block. To display literal content, for example source-code, or blocks of text that should not be interpreted by micron, you can use literal blocks, specified by the \\`= tag. Below is the source code of this entire document, presented as a literal block.
@@ -409,69 +564,11 @@ To display literal content, for example source-code, or blocks of text that shou
TOPIC_MARKUP += TOPIC_MARKUP.replace("`=", "\\`=") + "[ micron source for document goes here, we don't want infinite recursion now, do we? ]\n\\`=" TOPIC_MARKUP += TOPIC_MARKUP.replace("`=", "\\`=") + "[ micron source for document goes here, we don't want infinite recursion now, do we? ]\n\\`="
TOPIC_MARKUP += "\n`=\n\n>Closing Remarks\n\nIf you made it all the way here, you should be well equipped to write documents and pages using micron. Thank you for staying with me.\n\n`c\U0001F332\n" TOPIC_MARKUP += "\n`=\n\n>Closing Remarks\n\nIf you made it all the way here, you should be well equipped to write documents and pages using micron. Thank you for staying with me.\n\n`c\U0001F332\n"
TOPIC_FIRST_RUN = '''>First Time Information
Hi there. This first run message will only appear once. It contains a few pointers on getting started with Nomad Network, and getting the most out of the program.
You're currently located in the guide section of the program. I'm sorry I had to drag you here by force, but it will only happen this one time, I promise. If you ever get lost, return here and peruse the list of topics you see on the left. I will do my best to fill it with answers to mostly anything about Nomad Network.
To get the most out of Nomad Network, you will need a terminal that supports UTF-8 and at least 256 colors, ideally true-color.
By default, Nomad Network starts in low-color mode. It does this for the sake of compatibility, but it does look rather ugly. If your terminal supports true-color or just 256 colors, you should go to the `![ Config ]`! menu item, launch the editor and change the configuration to use a high-color mode.
If you don't already have a Nerd Font installed (see https://www.nerdfonts.com/), I also highly recommend to do so, since it will greatly expand the amount of glyphs, icons and graphics that Nomad Network can use.
Nomad Network expects that you are already connected to some form of Reticulum network. That could be as simple as the default UDP-based demo interface on your local ethernet network. This short guide won't go into any details on building, but you will find other entries in the guide that deal with network setup and configuration.
At least, if Nomad Network launches, it means that it is connected to a running Reticulum instance, that should in turn be connected to `*something`*, which should get you started.
For more some more information, you can also read the `*Introduction`* section of this guide.
Now go out there and explore. This is still early days. See what you can find and create.
>>>>>>>>>>>>>>>
-\u223f
<
'''
TOPIC_LICENSES = '''>Thanks, Acknowledgements and Licenses
This program uses various other software components, without which Nomad Network would not have been possible. Sincere thanks to the authors and contributors of the following projects
>>>
- `!Cryptography.io`! by `*pyca`*
https://cryptography.io/
BSD License
- `!Urwid`! by `*Ian Ward`*
http://urwid.org/
LGPL-2.1 License
- `!Additional Urwid Widgets`! by `*AFoeee`*
https://github.com/AFoeee/additional_urwid_widgets
MIT License
- `!Scrollable`! by `*rndusr`*
https://github.com/rndusr/stig/blob/master/stig/tui/scroll.py
GPLv3 License
- `!Configobj`! by `*Michael Foord`*
https://github.com/DiffSK/configobj
BSD License
- `!Reticulum Network Stack`! by `*unsignedmark`*
https://github.com/markqvist/Reticulum
MIT License
- `!LXMF`! by `*unsignedmark`*
https://github.com/markqvist/LXMF
MIT License
'''
TOPICS = { TOPICS = {
"Introduction": TOPIC_INTRODUCTION, "Introduction": TOPIC_INTRODUCTION,
"Conversations": TOPIC_CONVERSATIONS, "Conversations": TOPIC_CONVERSATIONS,
"Hosting a Node": TOPIC_HOSTING,
"Markup": TOPIC_MARKUP, "Markup": TOPIC_MARKUP,
"First Run": TOPIC_FIRST_RUN, "First Run": TOPIC_FIRST_RUN,
"Credits & Licenses": TOPIC_LICENSES, "Credits & Licenses": TOPIC_LICENSES,

View File

@@ -21,6 +21,9 @@ class SubDisplays():
self.log_display = LogDisplay(self.app) self.log_display = LogDisplay(self.app)
self.guide_display = GuideDisplay(self.app) self.guide_display = GuideDisplay(self.app)
if app.firstrun:
self.active_display = self.guide_display
else:
self.active_display = self.conversations_display self.active_display = self.conversations_display
def active(self): def active(self):

View File

@@ -393,6 +393,17 @@ class LinkableText(urwid.Text):
return None return None
def peek_link(self):
item = self.find_item_at_pos(self._cursor_position)
if item != None:
if isinstance(item, LinkSpec):
if self.delegate != None:
self.delegate.marked_link(item.link_target)
else:
if self.delegate != None:
self.delegate.marked_link(None)
def keypress(self, size, key): def keypress(self, size, key):
part_positions = [0] part_positions = [0]
parts = [] parts = []
@@ -449,6 +460,9 @@ class LinkableText(urwid.Text):
if focus and (self.delegate == None or now < self.delegate.last_keypress+self.key_timeout): if focus and (self.delegate == None or now < self.delegate.last_keypress+self.key_timeout):
c = urwid.CompositeCanvas(c) c = urwid.CompositeCanvas(c)
c.cursor = self.get_cursor_coords(size) c.cursor = self.get_cursor_coords(size)
if self.delegate != None:
self.peek_link()
return c return c
def get_cursor_coords(self, size): def get_cursor_coords(self, size):

View File

@@ -31,7 +31,7 @@ class Scrollable(urwid.WidgetDecoration):
def selectable(self): def selectable(self):
return True return True
def __init__(self, widget): def __init__(self, widget, force_forward_keypress = False):
"""Box widget that makes a fixed or flow widget vertically scrollable """Box widget that makes a fixed or flow widget vertically scrollable
TODO: Focusable widgets are handled, including switching focus, but TODO: Focusable widgets are handled, including switching focus, but
@@ -49,6 +49,7 @@ class Scrollable(urwid.WidgetDecoration):
self._forward_keypress = None self._forward_keypress = None
self._old_cursor_coords = None self._old_cursor_coords = None
self._rows_max_cached = 0 self._rows_max_cached = 0
self.force_forward_keypress = force_forward_keypress
self.__super.__init__(widget) self.__super.__init__(widget)
def render(self, size, focus=False): def render(self, size, focus=False):
@@ -127,7 +128,7 @@ class Scrollable(urwid.WidgetDecoration):
def keypress(self, size, key): def keypress(self, size, key):
# Maybe offer key to original widget # Maybe offer key to original widget
if self._forward_keypress: if self._forward_keypress or self.force_forward_keypress:
ow = self._original_widget ow = self._original_widget
ow_size = self._get_original_widget_size(size) ow_size = self._get_original_widget_size(size)

View File

@@ -23,6 +23,6 @@ setuptools.setup(
entry_points= { entry_points= {
'console_scripts': ['nomadnet=nomadnet.nomadnet:main'] 'console_scripts': ['nomadnet=nomadnet.nomadnet:main']
}, },
install_requires=['rns>=0.2.3', 'lxmf>=0.0.8', 'urwid>=2.1.2'], install_requires=['rns>=0.2.4', 'lxmf>=0.0.9', 'urwid>=2.1.2'],
python_requires='>=3.6', python_requires='>=3.6',
) )