Compare commits
13 Commits
Author | SHA1 | Date |
---|---|---|
Castro0o | 9f61a1fe0b | 6 years ago |
Castro0o | d0b319143f | 6 years ago |
onebigear | c72f94af62 | 6 years ago |
Castro0o | 5ac93f07c4 | 6 years ago |
Castro0o | dee2e0f786 | 6 years ago |
bootje | 962d9a7e98 | 6 years ago |
Castro0o | 77d25461fa | 6 years ago |
Castro0o | 9573bb4984 | 6 years ago |
Rita Graça | afca511958 | 6 years ago |
Rita Graça | 47a19ea863 | 6 years ago |
Rita Graça | 145fc0573e | 6 years ago |
onebigear | 234ca09133 | 6 years ago |
onebigear | c6aa000aef | 6 years ago |
@ -0,0 +1,6 @@
|
||||
etherpad-api/api.key
|
||||
Jinja-prototype/index.html
|
||||
reader-scripts/**.html
|
||||
reader-scripts/**.css
|
||||
reader-scripts/**.md
|
||||
reader-scripts/**.pdf
|
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="style.css" />
|
||||
<title>{% block title %}{% endblock %}</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="content">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,9 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ mytitle }}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="box">
|
||||
{{ content }}
|
||||
</div>
|
||||
{% endblock %}
|
@ -0,0 +1,54 @@
|
||||
|
||||
# RENDER TEMPLATE:
|
||||
# http://jinja.pocoo.org/docs/2.10/intro/#basic-api-usage
|
||||
|
||||
from jinja2 import Template
|
||||
htmlfragment = """<h1 id='{{id}}'>
|
||||
{{ content }}
|
||||
</h1>
|
||||
"""
|
||||
template = Template(htmlfragment)
|
||||
title = template.render(content="XPuB tries JINJA (What??)",
|
||||
id="elementid")
|
||||
# print(htmlrendered)
|
||||
|
||||
|
||||
# CONTROL STRUCTURES: loops and if conditions
|
||||
# http://jinja.pocoo.org/docs/2.10/templates/#list-of-control-structures
|
||||
users_html = Template('''<ul>
|
||||
{% for user in users %}
|
||||
<li class="user" id="user_{{ user|lower }}">
|
||||
{% if user[0] == "A" %}
|
||||
<i>{{ user[0] }}</i>{{ user[1:] }}
|
||||
{% else %}
|
||||
<b>{{ user[0] }}</b>{{ user[1:] }}
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
''')
|
||||
|
||||
xpub1 = ["Pedro", "Rita", "Simon", "Artemis", "Bo", "Biyi", "Tancredi"]
|
||||
xpub2 = ["Tash", "Angeliki", "Alice", "Alex", "Joca", "Zalan"]
|
||||
# render the same template with 2 different lists, a string
|
||||
users_1 = users_html.render(users=xpub1)
|
||||
users_2 = users_html.render(users=xpub2)
|
||||
users_2 = users_html.render(users="xpub2")
|
||||
# print(users_1, users_2)
|
||||
|
||||
|
||||
# TEMPLATE-INHERITANCE
|
||||
# http://jinja.pocoo.org/docs/2.10/templates/#template-inheritance
|
||||
from jinja2 import FileSystemLoader
|
||||
from jinja2.environment import Environment
|
||||
|
||||
env = Environment() # loads templates from the file system
|
||||
env.loader = FileSystemLoader('.') # Loads templates from the current directory
|
||||
tmpl = env.get_template('child.html') # get the template # which itself inherit base.html template
|
||||
tmpl_render = tmpl.render(mytitle="xpUB",
|
||||
content=title + users_1 + users_2) # render the template
|
||||
print(tmpl_render)
|
||||
|
||||
# save
|
||||
with open("index.html", "w") as index:
|
||||
index.write(tmpl_render)
|
@ -0,0 +1,7 @@
|
||||
.box{ background: black;
|
||||
color:white;
|
||||
}
|
||||
|
||||
.user{color:yellow;
|
||||
text-decoration: underline;
|
||||
}
|
Binary file not shown.
@ -0,0 +1,199 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import logging
|
||||
from getpass import getpass
|
||||
from argparse import ArgumentParser
|
||||
|
||||
import slixmpp
|
||||
import ssl, os, requests, urllib
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
from urllib.parse import quote as urlquote, unquote as urlunquote
|
||||
|
||||
|
||||
def make_numbered_text(input_text,output_html):
|
||||
if not os.path.exists(output_html):
|
||||
|
||||
text = open(input_text, 'r') # open the txt file
|
||||
lines = text.readlines() # to divide the text into lines
|
||||
x = 1
|
||||
|
||||
with open(output_html, 'w') as new_html: # open the output_html with writing only as new_html
|
||||
new_html.write('<html><head><link rel="stylesheet" href="style.css" type="text/css"/><meta charset="utf-8"/></head><body>')
|
||||
new_html.write('<div id="wrapper">')
|
||||
for line in lines:
|
||||
new_html.write('<div class="shell" id="linenum-{}"><p class="linenumber" id="group-{}"><span class="number" id="number-{}">{} </span><span class="sentence" id="sentence-{}">{}</span></p></div>'.format(x, x, x, x, x, line))
|
||||
x = x + 1
|
||||
|
||||
new_html.write('</div></body></html>')
|
||||
print('I wrote a new file!', output_html)
|
||||
|
||||
|
||||
def insert_comment_at_line(output_html,comment,line_number):
|
||||
with open (output_html,'r') as f:
|
||||
text = f.read()
|
||||
html = BeautifulSoup(text,'html.parser')
|
||||
div_id = 'linenum-{}'.format(line_number)
|
||||
line = html.find('div',{'id' : div_id})
|
||||
print(line,comment,'#'+str(line_number)+'#')
|
||||
print(div_id)
|
||||
|
||||
if line:
|
||||
with open (output_html,'w') as f:
|
||||
new_comment = html.new_tag("comment")
|
||||
new_comment.string = comment
|
||||
line.append(new_comment)
|
||||
f.write(html.decode())
|
||||
|
||||
def insert_media_at_line(output_html,mediafile,line_number):
|
||||
with open (output_html,'r') as f:
|
||||
text = f.read()
|
||||
html = BeautifulSoup(text,'html.parser')
|
||||
div_id = 'linenum-{}'.format(line_number)
|
||||
line = html.find('div',{'id' : div_id})
|
||||
|
||||
if line:
|
||||
#notes to self write function to the detect media type
|
||||
with open (output_html,'w') as f:
|
||||
new_image = html.new_tag("img", src = mediafile)
|
||||
line.append(new_image)
|
||||
f.write(html.decode())
|
||||
|
||||
class MUCBot(slixmpp.ClientXMPP):
|
||||
def __init__(self, jid, password, room, nick, output):
|
||||
|
||||
slixmpp.ClientXMPP.__init__(self, jid, password)
|
||||
|
||||
self.room = room
|
||||
self.nick = nick
|
||||
self.output = output
|
||||
self.current_line = 0
|
||||
|
||||
self.add_event_handler("session_start", self.start) # moment that it logs on
|
||||
self.add_event_handler("groupchat_message", self.muc_message) # moment that someone start speaking someone
|
||||
|
||||
output = self.output
|
||||
if not os.path.exists(output):
|
||||
os.mkdir(output)
|
||||
|
||||
make_numbered_text('text.txt','annotated-reader.html')
|
||||
|
||||
|
||||
def start(self, event):
|
||||
|
||||
self.get_roster()
|
||||
self.send_presence()
|
||||
|
||||
# https://xmpp.org/extensions/xep-0045.html
|
||||
self.plugin['xep_0045'].join_muc(self.room,
|
||||
self.nick,
|
||||
# If a room password is needed, use:
|
||||
# password=the_room_password,
|
||||
wait=True)
|
||||
|
||||
def muc_message(self, msg):
|
||||
|
||||
# Always check that a message is not the bot itself, otherwise you will create an infinite loop responding to your own messages.
|
||||
if msg['mucnick'] != self.nick:
|
||||
|
||||
# Check if an OOB URL is included in the stanza (which is how an image is sent)
|
||||
# (OOB object - https://xmpp.org/extensions/xep-0066.html#x-oob)
|
||||
if len(msg['oob']['url']) > 0:
|
||||
# UPLOADED IMAGE
|
||||
# Send a reply
|
||||
self.send_message(mto=msg['from'].bare,
|
||||
mbody="Really? Oke. I'll add your photo for you, {}.".format(msg['mucnick']),
|
||||
mtype='groupchat')
|
||||
|
||||
# Save the image to the output folder
|
||||
url = msg['oob']['url'] # grep the url in the message
|
||||
# urlunquote is like url to filename
|
||||
filename = os.path.basename(urlunquote(url)) # grep the filename in the url
|
||||
output = self.output
|
||||
# if not os.path.exists(output):
|
||||
# os.mkdir(output)
|
||||
output_path = os.path.join(output, filename)
|
||||
|
||||
u = urllib.request.urlopen(url) # read the image data
|
||||
new_html = open(output_path, 'wb') # open the output file
|
||||
new_html.write(u.read()) # write image to file
|
||||
new_html.close() # close the output file
|
||||
|
||||
# Add image to stream
|
||||
img = output_path
|
||||
insert_media_at_line('annotated-reader.html',img,self.current_line)
|
||||
|
||||
else:
|
||||
# TEXT MESSAGE
|
||||
for word in msg['body'].split():
|
||||
if word.startswith("#line"):
|
||||
self.current_line = int(word[5:])
|
||||
self.send_message(mto=msg['from'].bare,
|
||||
mbody="I've set the current line number to {}.".format(self.current_line),
|
||||
mtype='groupchat')
|
||||
|
||||
elif word == "#comment":
|
||||
self.send_message(mto=msg['from'].bare,
|
||||
mbody="Really? Oke. I'll add your comment that for you, {}.".format(msg['mucnick']),
|
||||
mtype='groupchat')
|
||||
|
||||
insert_comment_at_line('annotated-reader.html',msg['body'], self.current_line)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Setup the command line arguments.
|
||||
parser = ArgumentParser() # making your own command line - ArgumentParser.
|
||||
|
||||
# output verbosity options.
|
||||
parser.add_argument("-q", "--quiet", help="set logging to ERROR",
|
||||
action="store_const", dest="loglevel",
|
||||
const=logging.ERROR, default=logging.INFO)
|
||||
parser.add_argument("-d", "--debug", help="set logging to DEBUG",
|
||||
action="store_const", dest="loglevel",
|
||||
const=logging.DEBUG, default=logging.INFO)
|
||||
|
||||
# JID and password options.
|
||||
parser.add_argument("-j", "--jid", dest="jid", # jid = user
|
||||
help="JID to use")
|
||||
parser.add_argument("-p", "--password", dest="password",
|
||||
help="password to use")
|
||||
parser.add_argument("-r", "--room", dest="room",
|
||||
help="MUC room to join")
|
||||
parser.add_argument("-n", "--nick", dest="nick",
|
||||
help="MUC nickname") # MUC = multi user chat
|
||||
|
||||
# output folder for images
|
||||
parser.add_argument("-o", "--output", dest="output",
|
||||
help="output folder, this is where the files are stored",
|
||||
default="./output/", type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Setup logging.
|
||||
logging.basicConfig(level=args.loglevel,
|
||||
format='%(levelname)-8s %(message)s')
|
||||
|
||||
if args.jid is None:
|
||||
args.jid = input("User: ")
|
||||
if args.password is None:
|
||||
args.password = getpass("Password: ")
|
||||
if args.room is None:
|
||||
args.room = input("MUC room: ")
|
||||
if args.nick is None:
|
||||
args.nick = input("MUC nickname: ")
|
||||
if args.output is None:
|
||||
args.output = input("Output folder: ")
|
||||
|
||||
# Setup the MUCBot and register plugins. Note that while plugins may
|
||||
# have interdependencies, the order in which you register them does
|
||||
# not matter.
|
||||
xmpp = MUCBot(args.jid, args.password, args.room, args.nick, args.output)
|
||||
xmpp.register_plugin('xep_0030') # Service Discovery
|
||||
xmpp.register_plugin('xep_0045') # Multi-User Chat
|
||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
||||
xmpp.register_plugin('xep_0066') # Process URI's (files, images)
|
||||
|
||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||
xmpp.connect()
|
||||
xmpp.process()
|
||||
|
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
*{
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
|
||||
}
|
||||
|
||||
linenumber{
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
body{
|
||||
font-size: 20px;
|
||||
line-height: 1.5em
|
||||
}
|
||||
|
||||
#linenum-:before {
|
||||
width: 50%;
|
||||
}
|
||||
comment{
|
||||
background-color: black;
|
||||
color:white;
|
||||
float: right;
|
||||
|
||||
}
|
||||
|
||||
img{
|
||||
max-width: 30%;
|
||||
float: right;
|
||||
|
||||
}
|
||||
|
||||
img:hover{
|
||||
max-width: 400px;
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
text = open('text.txt', 'r') # open the txt file
|
||||
lines = text.readlines() # to divide the text into lines
|
||||
lines_noempty = [ ]
|
||||
x = 1
|
||||
|
||||
new_html = open('annotated-reader.html', 'a+')
|
||||
|
||||
|
||||
for line in lines:
|
||||
if line is not "\n": # if line is not empty,
|
||||
outputfile = open('text_num.txt', 'a+')
|
||||
outputfile.write('{0} {1} '.format(x, line))
|
||||
new_html.write('<div id="{}"><linenumber>{}</linenumber><sentence>{}</sentence></div>'.format(x, x, line))
|
||||
|
||||
x = x + 1
|
||||
|
||||
new_html.close()
|
Binary file not shown.
@ -0,0 +1,254 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
Slixmpp: The Slick XMPP Library
|
||||
Copyright (C) 2010 Nathanael C. Fritz
|
||||
This file is part of Slixmpp.
|
||||
|
||||
See the file LICENSE for copying permission.
|
||||
"""
|
||||
|
||||
# Code source: https://git.poez.io/slixmpp/tree/examples/muc.py
|
||||
|
||||
# To run this bot:
|
||||
# $ python3 streambot.py --jid username@yourdomainname.ext --password password --room channel@groups.domainname.ext --nick nickname --output ./output/
|
||||
# python3 streambot.py --jid rita@please.undo.undo.it --room paranodal.activity@groups.please.undo.undo.it --nick test --output ./output/
|
||||
|
||||
|
||||
import logging
|
||||
from getpass import getpass
|
||||
from argparse import ArgumentParser
|
||||
|
||||
import slixmpp
|
||||
import ssl, os, requests, urllib
|
||||
import os, sys
|
||||
from PIL import Image
|
||||
|
||||
#idea of class is important: like creating your own concepts, names, etc. like a library
|
||||
class MUCBot(slixmpp.ClientXMPP):
|
||||
|
||||
def __init__(self, jid, password, room, nick, output, outputparanodal):
|
||||
slixmpp.ClientXMPP.__init__(self, jid, password)
|
||||
|
||||
self.room = room
|
||||
self.nick = nick
|
||||
self.output = output
|
||||
self.outputparanodal = outputparanodal
|
||||
self.tmp = None
|
||||
|
||||
|
||||
# The session_start event will be triggered when
|
||||
# the bot establishes its connection with the server
|
||||
# and the XML streams are ready for use. We want to
|
||||
# listen for this event so that we we can initialize
|
||||
# our roster.
|
||||
self.add_event_handler("session_start", self.start)
|
||||
|
||||
# The groupchat_message event is triggered whenever a message
|
||||
# stanza is received from any chat room. If you also also
|
||||
# register a handler for the 'message' event, MUC messages
|
||||
# will be processed by both handlers.
|
||||
self.add_event_handler("groupchat_message", self.muc_message)
|
||||
|
||||
|
||||
def start(self, event):
|
||||
"""
|
||||
Process the session_start event.
|
||||
|
||||
Typical actions for the session_start event are
|
||||
requesting the roster and broadcasting an initial
|
||||
presence stanza.
|
||||
"""
|
||||
|
||||
self.get_roster()
|
||||
self.send_presence()
|
||||
|
||||
# https://xmpp.org/extensions/xep-0045.html
|
||||
self.plugin['xep_0045'].join_muc(self.room,
|
||||
self.nick,
|
||||
# If a room password is needed, use:
|
||||
# password=the_room_password,
|
||||
wait=True)
|
||||
|
||||
def muc_message(self, msg):
|
||||
"""
|
||||
Process incoming message stanzas from any chat room. Be aware
|
||||
that if you also have any handlers for the 'message' event,
|
||||
message stanzas may be processed by both handlers, so check
|
||||
the 'type' attribute when using a 'message' event handler.
|
||||
|
||||
Whenever the bot's nickname is mentioned, respond to
|
||||
the message.
|
||||
|
||||
IMPORTANT: Always check that a message is not from yourself,
|
||||
otherwise you will create an infinite loop responding
|
||||
to your own messages.
|
||||
|
||||
This handler will reply to messages that mention
|
||||
the bot's nickname.
|
||||
|
||||
Arguments:
|
||||
msg -- The received message stanza. See the documentation
|
||||
for stanza objects and the Message stanza to see
|
||||
how it may be used.
|
||||
"""
|
||||
|
||||
# Some inspection commands
|
||||
print('......,.......................')
|
||||
print('Message:{}'.format(msg))
|
||||
# print('\nMessage TYPE:{}'.format(msg['type']))
|
||||
# print('\nMessage body:{}'.format(msg['body']))
|
||||
print('Message OOB:{}'.format(msg['oob']))
|
||||
print('Message OOB URL:{}'.format(msg['oob']['url']))
|
||||
# print('\nMessage MUCK NICK:{}'.format(msg['mucnick']))
|
||||
|
||||
|
||||
# Always check that a message is not the bot itself, otherwise you will create an infinite loop responding to your own messages.
|
||||
if msg['mucnick'] != self.nick:
|
||||
#
|
||||
#Check if an OOB URL is included in the stanza (which is how an image is sent)
|
||||
#(OOB object - https://xmpp.org/extensions/xep-0066.html#x-oob)
|
||||
print(len(msg['oob']['url']))
|
||||
if len(msg['oob']['url']) > 0:
|
||||
|
||||
# Save the image to the output folder
|
||||
url = msg['oob']['url'] # grep the url in the message
|
||||
self.tmp = url
|
||||
|
||||
#Send a reply
|
||||
|
||||
self.send_message(mto=msg['from'].bare,
|
||||
mbody="Please put hashtag!",
|
||||
mtype='groupchat')
|
||||
|
||||
|
||||
# Include messages in the stream (only when '#' is used in the message. creates a folder for each #)
|
||||
for word in msg['body'].split():
|
||||
if word.startswith('#'):
|
||||
if self.tmp:
|
||||
url = self.tmp
|
||||
print('URL:', url)
|
||||
folder = word.replace('#', '')
|
||||
filename = os.path.basename(url) # grep the filename in the url
|
||||
if not os.path.exists(folder):
|
||||
os.mkdir(folder)
|
||||
output_path = os.path.join(folder, filename)
|
||||
u = urllib.request.urlopen(url) # read the image data
|
||||
f = open(output_path, 'wb') # open the output file
|
||||
f.write(u.read()) # write image to file
|
||||
f.close() # close the output file
|
||||
|
||||
# Add image to stream and resizes it
|
||||
img = '<img class="image" src="{}" width="400">'.format(filename)
|
||||
stream = 'index.html'
|
||||
stream_path = os.path.join(folder, stream)
|
||||
f = open(stream_path, 'a+')
|
||||
f.write(img+'\n')
|
||||
f.close()
|
||||
else:
|
||||
folder = word.replace('#', '')
|
||||
self.send_message(mto=msg['from'].bare,
|
||||
mbody="Be aware {} ! You are creating a hashtag called {}.".format(msg['mucnick'], folder),
|
||||
mtype='groupchat')
|
||||
message = '<p class="message">{}</p>'.format(msg['body'])
|
||||
if not os.path.exists(folder):
|
||||
os.mkdir("{}".format(folder))
|
||||
stream = 'index.html'
|
||||
stream_path = os.path.join(folder, stream)
|
||||
f = open(stream_path, 'a+')
|
||||
message = message.replace(word, '')
|
||||
f.write(message+'\n')
|
||||
f.close()
|
||||
|
||||
#adds content to index.htm
|
||||
path = "."
|
||||
with os.scandir(path) as it:
|
||||
for entry in it:
|
||||
if not entry.name.startswith('.') and not entry.is_file():
|
||||
a = entry.name
|
||||
print(a)
|
||||
#note that the 'w' writes, the 'a' appends
|
||||
f = open('index.htm','w')
|
||||
message = """<html>
|
||||
<head></head>
|
||||
<body>
|
||||
<p>The archive</p>
|
||||
<p> See the categories: </p>
|
||||
"""
|
||||
f.write(message)
|
||||
f.close()
|
||||
|
||||
#appends the name of the folder and link to index
|
||||
for a in os.listdir('.'):
|
||||
if os.path.isdir(a):
|
||||
f = open('index.htm','a')
|
||||
message = """
|
||||
<a href="./{}/index.html">{}</a>
|
||||
""".format(a, a)
|
||||
f.write(message)
|
||||
f.close()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Setup the command line arguments.
|
||||
parser = ArgumentParser()
|
||||
|
||||
# output verbosity options.
|
||||
parser.add_argument("-q", "--quiet", help="set logging to ERROR",
|
||||
action="store_const", dest="loglevel",
|
||||
const=logging.ERROR, default=logging.INFO)
|
||||
parser.add_argument("-d", "--debug", help="set logging to DEBUG",
|
||||
action="store_const", dest="loglevel",
|
||||
const=logging.DEBUG, default=logging.INFO)
|
||||
|
||||
# JID and password options.
|
||||
parser.add_argument("-j", "--jid", dest="jid",
|
||||
help="JID to use")
|
||||
parser.add_argument("-p", "--password", dest="password",
|
||||
help="password to use")
|
||||
parser.add_argument("-r", "--room", dest="room",
|
||||
help="MUC room to join")
|
||||
parser.add_argument("-n", "--nick", dest="nick",
|
||||
help="MUC nickname")
|
||||
|
||||
# output folder for images
|
||||
parser.add_argument("-o", "--output", dest="output",
|
||||
help="output folder, this is where the files are stored",
|
||||
default="./output/", type=str)
|
||||
|
||||
# output folder for images
|
||||
parser.add_argument("-op", "--outputpara", dest="outputparanodal",
|
||||
help="outputparanodal folder, this is where the files are stored",
|
||||
default="./outputparanodal/", type=str)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Setup logging.
|
||||
logging.basicConfig(level=args.loglevel,
|
||||
format='%(levelname)-8s %(message)s')
|
||||
|
||||
if args.jid is None:
|
||||
args.jid = input("User: ")
|
||||
if args.password is None:
|
||||
args.password = getpass("Password: ")
|
||||
if args.room is None:
|
||||
args.room = input("MUC room: ")
|
||||
if args.nick is None:
|
||||
args.nick = input("MUC nickname: ")
|
||||
if args.output is None:
|
||||
args.output = input("Output folder: ")
|
||||
|
||||
# Setup the MUCBot and register plugins. Note that while plugins may
|
||||
# have interdependencies, the order in which you register them does
|
||||
# not matter.
|
||||
xmpp = MUCBot(args.jid, args.password, args.room, args.nick, args.output, args.outputparanodal)
|
||||
xmpp.register_plugin('xep_0030') # Service Discovery
|
||||
xmpp.register_plugin('xep_0045') # Multi-User Chat
|
||||
xmpp.register_plugin('xep_0199') # XMPP Ping
|
||||
xmpp.register_plugin('xep_0066') # Process URI's (files, images)
|
||||
|
||||
|
||||
# Connect to the XMPP server and start processing XMPP stanzas.
|
||||
xmpp.connect()
|
||||
xmpp.process()
|
@ -0,0 +1,78 @@
|
||||
import urllib.request
|
||||
import urllib.parse
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
# REQUIRES: Etherpad API KEY stored in api.key
|
||||
|
||||
with open('api.key', 'r') as apikey_f:
|
||||
apikey = apikey_f.read()
|
||||
|
||||
pad_urlbase = "https://pad.xpub.nl/api/1/" # xpub pad
|
||||
pad_urlmethods = {"get": "getText",
|
||||
"set": "setText",
|
||||
"authors": "listAuthorsOfPad"}
|
||||
|
||||
# see more methods in: https://etherpad.org/doc/v1.5.7/#index_http_api
|
||||
|
||||
|
||||
def createurl(urlbase, urlmethods, method, pad, key, text=''):
|
||||
# creates well formated urls
|
||||
# to query/edit the etherpad
|
||||
url_vars = {'apikey': key, 'padID': pad}
|
||||
if len(text) > 0: # if no text is input
|
||||
url_vars['text'] = text
|
||||
url_vars_dict = urllib.parse.urlencode(url_vars)
|
||||
url = "{base}{method}?{vars}".format(base=urlbase,
|
||||
method=urlmethods[method],
|
||||
vars=url_vars_dict)
|
||||
return url
|
||||
|
||||
|
||||
def padrequest(url):
|
||||
# upon being invoked opens the url
|
||||
# and loads the JSON response
|
||||
# returning the text
|
||||
request = urllib.request.urlopen(url)
|
||||
request_read = request.read().decode('utf-8')
|
||||
request_dict = json.loads(request_read) # response to JSON dictionary
|
||||
return request_dict
|
||||
|
||||
|
||||
# GET TEXT FROM PAD
|
||||
# from foo pad https://pad.xpub.nl/p/foo
|
||||
# by creating url:
|
||||
url = createurl(urlbase=pad_urlbase,
|
||||
urlmethods=pad_urlmethods,
|
||||
method='get',
|
||||
pad='foo',
|
||||
key=apikey)
|
||||
response = padrequest(url) # requesting url and get response
|
||||
|
||||
print('----> get request', '\n',
|
||||
url, '\n',
|
||||
response['data']['text'])
|
||||
|
||||
|
||||
|
||||
|
||||
# ADD TEXT TO THE PAD
|
||||
# to foo pad (https://pad.xpub.nl/p/foo)
|
||||
|
||||
now = datetime.now().strftime("%Y-%m-%d %H:%M:%S") # using current time
|
||||
new_text = "this is now: " + now
|
||||
# added old_text + new_text to
|
||||
old_new_text = response['data']['text'] + '\n' + new_text
|
||||
|
||||
# by creating url: w/ set method and and text
|
||||
url = createurl(urlbase=pad_urlbase,
|
||||
urlmethods=pad_urlmethods,
|
||||
method='set',
|
||||
pad='foo',
|
||||
key=apikey,
|
||||
text=old_new_text)
|
||||
|
||||
# create a request
|
||||
response = padrequest(url)
|
||||
print('----> set URL', '\n', url)
|
@ -0,0 +1,9 @@
|
||||
|
||||
#!/bin/sh
|
||||
while true;
|
||||
do
|
||||
curl https://pad.xpub.nl/p/special_issue_8_jargoncss/export/txt > style.pdf.css
|
||||
curl https://pad.xpub.nl/p/special_issue_8_jargonhtml/export/txt > content.md
|
||||
pandoc --from markdown --to html content.md --output content.html
|
||||
sleep 5
|
||||
done;
|
@ -0,0 +1,196 @@
|
||||
_.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._JARGON FILE_.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._
|
||||
|
||||
is the router a node???????????????? yes
|
||||
|
||||
#network
|
||||
|
||||
* node (nodocentrism)
|
||||
* client - asks
|
||||
* server - answers, never initiates the communication
|
||||
* paranodal ("the paranodal is an atopia: a society without borders)
|
||||
* link
|
||||
|
||||
* computer networking
|
||||
* network infrastructure
|
||||
* communications network
|
||||
* DIY network
|
||||
* network architecture / *network topology
|
||||
* centralized
|
||||
* de-centralized
|
||||
* distributed
|
||||
* federated networks
|
||||
* scale
|
||||
* trust
|
||||
* peer-to-peer
|
||||
|
||||
|
||||
# communication protocols *protocol families / protocol suite
|
||||
|
||||
## Internet Protocol Suite
|
||||
|
||||
### application layer
|
||||
|
||||
### transport layer
|
||||
|
||||
### internet layer
|
||||
|
||||
### link layer
|
||||
|
||||
## TCP/IP
|
||||
are two protocols (TCP & IP) that allows to establish communication between computers. Now widely adopted as a network standard, its archetype is the Defense Data Network, developed as part of Department of Defense.
|
||||
|
||||
## TCP
|
||||
(Transmission Control Protocol)
|
||||
In the transport layer within the Internet Protocol Suite, TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network.
|
||||
|
||||
## UDP
|
||||
|
||||
(User Datagram Protocol) - In Transport Layer, Applications that do not require reliable data stream service may use the User Datagram
|
||||
Protocol (UDP), which provides a connectionless datagram service that emphasizes reduced **latency** over reliability.
|
||||
|
||||
## Latency
|
||||
|
||||
Time interval between stimulation and response.
|
||||
|
||||
## IP - (Internet Protocol) -
|
||||
|
||||
* (WAN, Wide Area Network) external IP (WAN); (LAN, Local Area Network) internal, local IP - 192.168.x.x
|
||||
* IPv4 / IPv6 -IPv4 is short for Internet Protocal version 4. IPv4 is a connectionless protocol for use on packet-switched networks. It operates on a best effort delivery model, in that it does not guarantee delivery, nor does it assure proper sequencing or avoidance of duplicate delivery. These aspects, including data integrity, are addressed by an upper layer transport protocol, such as the Transmission Control Protocol(TCP).
|
||||
|
||||
## MAC address
|
||||
|
||||
-media access control address A media access control address (MAC address) of a device is a unique identifier assigned to a network interface controller (NIC) for communications at the data link layer of a network segment. MAC addresses are used as a network address for most IEEE 802 network technologies, including Ethernet, Wi-Fi and Bluetooth.
|
||||
|
||||
#MAC address anonymization
|
||||
|
||||
-performs a one-way function on a MAC address so that the result may be used in tracking systems for reporting and the general public, while making it nearly impossible to obtain the original MAC address from the result. The idea is that this process allows companies like Google,[1] Apple[2] and iInside[3] - which track users movements via computer hardware to simultaneously preserve the identities of the people they are tracking, as well as the hardware itself.
|
||||
|
||||
#IP Addressing
|
||||
|
||||
-IPv4 uses 32-bit addresses which limits the address space to 4294967296 (2^32) addresses.
|
||||
|
||||
#DNS (Domain Name System) -
|
||||
|
||||
The Domain Name System (DNS) is a hierarchical decentralized naming system for computers, services, or other resources connected to the Internet or a private network. DNS is in the application layer within IP Suite.
|
||||
*8.8.8.8 / 8.8.4.4 / 4.4.4.4 - google DNS
|
||||
*openDNS -OpenDNS is a company and service that extends the Domain Name System (DNS) by adding features such as phishing protection and optional content filtering in addition to DNS lookup, if its DNS servers are used.
|
||||
Phishing - Phishing is the fraudulent attempt to obtain sensitive information such as usernames, passwords and credit card details by disguising as a trustworthy entity in an electronic communication. Typically carried out by email spoofing or instant messaging, it often directs users to enter personal information at a fake website, the look and feel of which are identical to the legitimate site.
|
||||
|
||||
#TLD (Top Level Domain) -
|
||||
|
||||
A top-level domain (TLD) is one of the domains at the highest level in the hierarchical Domain Name System of the Internet
|
||||
-country-code top-level domains (ccTLD)
|
||||
-generic top-level domains (gTLD)
|
||||
-sponsored top-level domains (sTLD)
|
||||
-unsponsored top-level domains
|
||||
-infrastructure top-level domain (.arpa)
|
||||
|
||||
#IDN (Internationalize Domain System)
|
||||
|
||||
- An internationalized domain name (IDN) is an Internet domain name that contains at least one label that is displayed in software applications, in whole or in part, in a language-specific script or alphabet, such as Arabic, Chinese, Cyrillic, Tamil, Hebrew or the Latin alphabet-based characters with diacritics or ligatures, such as French.
|
||||
|
||||
#HTTP (HyperText Transfer Protocol)
|
||||
|
||||
- The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative, hypermediainformation systems. HTTP is the foundation of data communication for the World Wide Web, where hypertextdocuments include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen. HTTP was developed to facilitate hypertext and the World Wide Web. Developed by Tim Berners-Lee
|
||||
Tim Berners-Lee is an English engineer and computer scientist, best known as the inventor of the World Wide Web. Development of HTTP was initiated by Tim Berners-Lee at CERN in 1989. Development of HTTP standards was coordinated by the Internet Engineering Task Force (IETF) and the World Wide Web Consortium (W3C), culminating in the publication of a series of Requests for Comments (RFCs).
|
||||
|
||||
#HTTP is an application layer protocol designed within the framework of the Internet protocol suite. Its definition presumes an underlying and reliable transport layer protocol, and Transmission Control Protocol (TCP) is commonly used. However, HTTP can be adapted to use unreliable protocols such as the User Datagram Protocol (UDP), for example in HTTPU and Simple Service Discovery Protocol (SSDP).
|
||||
|
||||
#HTTPS (HyperText Transfer Protocol over Secure Socket Layer) - Hypertext Transfer Protocol Secure (HTTPS) is an extension of the Hypertext Transfer Protocol (HTTP) for secure communication over a computer network, and is widely used on the Internet. In HTTPS, the communication protocol is encrypted using Transport Layer Security (TLS), or, formerly, its predecessor, Secure Sockets Layer (SSL). The protocol is therefore also often referred to as HTTP over TLS, or HTTP over SSL.
|
||||
|
||||
#SSL (Secure Socket Layer) - SSL (Secure Sockets Layer) is the standard security technology for establishing an encrypted link between a web server and a browser. This link ensures that all data passed between the web server and browsers remain private and integral. On application layer on IP Suite.
|
||||
|
||||
#TLS Transport Layer Security - Transport Layer Security (TLS), and its now-deprecated predecessor, Secure Sockets Layer (SSL), are
|
||||
cryptographic protocols designed to provide communications security over a computer network.
|
||||
|
||||
#SSH (Secure Shell) - Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. Typical applications include remote command-line login and remote command execution, but any network service can be secured with SSH. On application layer of IP Suite.
|
||||
|
||||
#FTP (File Transfer Protocol) -The File Transfer Protocol (FTP) is a standard network protocol used for the transfer of computer files between a client and server on a computer network. For secure transmission that protects the username and password, and encrypts the content, FTP is often secured with SSL/TLS (FTPS) or replaced with SSH File Transfer Protocol (SFTP).
|
||||
|
||||
#SFTP (SSH File Transfer Protocol) -In computing, the SSH File Transfer Protocol (also Secure File Transfer Protocol, or SFTP) is a network protocol that provides file access, file transfer, and file management over any reliable data stream.
|
||||
|
||||
#SCP - Secure Copy Protocol (SCP) is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. It is based on the Secure Shell (SSH) protocol. "SCP" commonly refers to both the Secure Copy Protocol and the program itself.
|
||||
|
||||
#XMPP (Extensible Messaging and Presence Protocol) - Extensible Messaging and Presence Protocol (XMPP) is a communication protocol for message-oriented middlewarebased on XML (Extensible Markup Language). It enables the near-real-time exchange of structured yet extensible data between any two or more network entities. Originally named Jabber, the protocol was developed by the homonym open-source community in 1999 for near real-time instant messaging (IM), presence information, and contact listmaintenance. Designed to be extensible, the protocol has been used also for publish-subscribe systems, signalling for VoIP, video, file transfer, gaming, the Internet of Things (IoT) applications such as the smart grid, and social networking services. On application layer of Internet Protocal Suite.
|
||||
|
||||
#OMEMO -OMEMO is an extension to the Extensible Messaging and Presence Protocol (XMPP, "Jabber") for multi-client end-to-end encryption developed by Andreas Straub. According to Straub, OMEMO uses the Double Ratchet Algorithm "to provide multi-end to multi-end encryption, allowing messages to be synchronized securely across multiple clients, even if some of them are offline".
|
||||
#wireless
|
||||
*wifi
|
||||
*bluetooth
|
||||
|
||||
#internet -
|
||||
#web (www) -
|
||||
|
||||
#network packet - A network packet is a formatted unit of data carried by a packet-switched network. A package has a maximum size of 150kb.
|
||||
#Packet Structure
|
||||
|
||||
|
||||
#Router - just another computer, splitting up the network into multiple routes. A router is a networking device that forwards data packets between computer networks. Routers perform the traffic directing functions on the Internet. Data sent through the internet, such as a web page or email, is in the form of data packets. A packet is typically forwarded from one router to another router through the networks that constitute an internetwork until it reaches its destination node.
|
||||
A router is connected to two or more data lines from different networks. When a data packet comes in on one of the lines, the router reads the network address information in the packet to determine the ultimate destination. Then, using information in its routing table or routing policy, it directs the packet to the next network on its journey.
|
||||
The most familiar type of routers are home and small office routers that simply forward IP packets between the home computers and the Internet. An example of a router would be the owner's cable or DSL router, which connects to the Internet through an Internet service provider (ISP). More sophisticated routers, such as enterprise routers, connect large business or ISP networks up to the powerful core routers that forward data at high speed along the optical fiber lines of the Internet backbone. Though routers are typically dedicated hardware devices, software-based routers also exist.
|
||||
#Residential Gateway - home and small office routers A Residential Gateway is a small consumer-grade router which provides network access between LAN hosts to a WAN via a modem. The modem may or may not be integrated into the hardware of the Residential Gateway.
|
||||
|
||||
Multiple devices have been described as "residential gateways":
|
||||
* Cable modem - A cable modem is a type of network bridge that provides bi-directional data communication via radio frequency channelson a hybrid fibre-coaxial (HFC) and radio frequency over glass (RFoG) infrastructure. Cable modems are primarily used to deliver broadband Internet access in the form of cable Internet, taking advantage of the high bandwidth of a HFC and RFoG network. They are commonly deployed in Australia, Europe, Asia and America.
|
||||
DSL modem - A digital subscriber line (DSL) modem is a device used to connect a computer or router to a telephone line which provides the digital subscriber line service for connectivity to the Internet, which is often called DSL broadband.
|
||||
* Wireless router -A wireless router is a device that performs the functions of a router and also includes the functions of a wireless access point. It is used to provide access to the Internet or a private computer network. Depending on the manufacturer and model, it can function in a wired local area network, in a wireless-only LAN, or in a mixed wired and wireless network.
|
||||
* Voice over internet protocol (VoIP) analog telephone adapter TBC!
|
||||
* Wireless access point TBC!
|
||||
* Wired router TBC!
|
||||
|
||||
#Modem - A modem is a hardware device that converts data between transmission media so that it can be transmitted from computer to computer (historically over copper telephone wires). The goal is to produce a signal that can be transmitted easily and decoded to reproduce the original digital data. Modems can be used with any means of transmitting analog signals, from light-emitting diodes to radio. A common type of modem is one that turns the digital data of a computer into modulated electrical signal for transmission over telephone lines and demodulated by another modem at the receiver side to recover the digital data.
|
||||
#Firewall
|
||||
#Modem & Router specification - While the router and modem are often separate entities, it has been more common for the modem and router to be combined into a single device. This type of hybrid device (sometimes called a gateway) is offered by some ISPs to simplify the setup process.
|
||||
|
||||
routes - No server/node has a map of the full network. But every computer knows about its neighbours.
|
||||
|
||||
#List_of_TCP_and_UDP_port_numbers
|
||||
ssh (22), http (80), https (443) ftp 20 21
|
||||
*internal port (high port ?) - from LAN
|
||||
*external port (low port ?) - from WAN
|
||||
*physical port - the actual port in the router
|
||||
|
||||
*port mapping/port forwarding - In computer networking, port forwarding or port mapping is an application of network address translation (NAT) that redirects a communication request from one address and port number combination to another while the packets are traversing a network gateway, such as a router or firewall.
|
||||
|
||||
encoding
|
||||
dependencies
|
||||
ISP (Internet Server Provider)
|
||||
WAN (Wide Area Network)
|
||||
LAN (Local Area Network)
|
||||
*LAN party :)
|
||||
WLAN
|
||||
subnet mask - the maximum quantity of the network 255.255.255.0, but can be changed (enlarged or linked to another router)
|
||||
gateway - the router of your router (of the WAN). a hardware somewhere where all your data pass through.
|
||||
mirroring - hosts contents for someone else, also for pirate and political purpose
|
||||
dropping
|
||||
pi hole - block adds in the network level
|
||||
NAT - network translation Network address translation (NAT) is a method of remapping one IP address space into another by modifying network address information in the IP header of packets while they are in transit across a traffic routing device
|
||||
apache(2)
|
||||
openSSH
|
||||
openWRT
|
||||
DHCP binding - static DHCP - seting for a static IP
|
||||
VPN
|
||||
DSL
|
||||
cryptography
|
||||
*end-to-end encryption
|
||||
*OWS
|
||||
data
|
||||
information
|
||||
General Purpose Computer
|
||||
Sub-Network
|
||||
Overloading Server
|
||||
DHC Client
|
||||
SNTP Protocol
|
||||
Framasoft, Chatons, Disroot, Indiehost, Autistici/Inventati, Anachaserver
|
||||
hostname
|
||||
url - protocol://subdomain.domain(name).TLD http://www.ciao.com
|
||||
html
|
||||
serving
|
||||
denial-of-service attack
|
||||
browser
|
||||
netcat
|
||||
Tor Onion browser
|
||||
|
||||
|
||||
_.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._.-*-._
|
||||
|
@ -0,0 +1,22 @@
|
||||
import os, requests, urllib
|
||||
from markdown import markdown
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
url = "https://pad.xpub.nl/p/jargon-file.test/export/txt"
|
||||
data = urllib.request.urlopen(url).read() #bytes object
|
||||
string = data.decode()
|
||||
# print(string)
|
||||
|
||||
html = markdown(string)
|
||||
# print(html)
|
||||
|
||||
soup = BeautifulSoup(html)
|
||||
headers = soup.find_all('h1')
|
||||
# print(headers)
|
||||
|
||||
cmd = '#network'
|
||||
query = cmd.replace('#','')
|
||||
for header in soup('h1'):
|
||||
if query in header.string:
|
||||
print(header.string)
|
||||
print('---')
|
Loading…
Reference in New Issue