bunch of stuff

separate_pages
quadrismegistus 4 years ago
parent fcde2f1e02
commit 161141cdc3

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

@ -41,20 +41,98 @@
height: self.texture_size[1]
font_style: 'H5'
halign: 'center'
height: '25'
size_hint_y: None
<PostImage>:
# height: '25'
size_hint_y: None
<PostGridLayout>:
cols: 1
size_hint: (1,None)
pos_hint: {'center_x':0.5, 'center_y':0}
md_bg_color: 1,1,0,1
height: self.minimum_height
<PostAuthorLayout>:
cols: 2
orientation: 'horizontal'
size_hint: (1,None)
# size_hint:(None,None)
# pos_hint:(None,None)
pos_hint: {'center_x':0.5, 'center_y':0}
# md_bg_color: 1,1,0,1
height: '100dp' #self.minimum_height
# radius:[20,]
# border_radius:20
<PostAuthorAvatar>:
size_hint:(None,None)
pos_hint:{'center_x':1,'x':1}
# padding:'10dp'
# canvas:
# Color:
# rgb: 1,0,0,1
# Line:
# width: 1
# rectangle: (self.x, self.y, self.width, self.height)
<PostAuthorLabel>:
id: post_author_label
text: ''
pos_hint: {'center_y':0.5, 'center_x':0.5}
# font_size:'100dp'
# font_style:'H5'
# font_style: 'custom'
#font_name: "Strengthen"
# height: '400'
size_hint_y: None
# size_hint_x: 100
text_color:1,0,0,1
theme_text_color: 'Custom'
halign: 'left'
padding: ('10dp','0dp')
<PostContent>:
id: post_content
text: ''
pos_hint: {'center_y':1}
font_style: 'Body1'
font_size:'58dp'
font_style:'H5'
#font_name: "Strengthen"
# height: '400'
size_hint_y: None
text_color:1,0,0,1
theme_text_color: 'Custom'
halign: 'left'
<PostCard>:
id: post
orientation: "vertical"
padding: "8dp"
size_hint: (0.9, 0.9)
padding: "20dp"
size_hint: (0.9, None)
pos_hint: {"center_x": .5, "center_y": .5}
md_bg_color: (1,0,0,1)
md_bg_color: (0,0,0,1)
height: self.minimum_height
radius:[20,]
border_radius:20
# canvas:
# Color:
# rgb: 1,0,0,1
# Line:
# width: 1
# rectangle: (self.x, self.y, self.width, self.height)
# # radius:[20,]
# # border_radius:20
@ -92,8 +170,8 @@ MyLayout:
background_hue: '500'
specific_text_color: 1,0,0,1
# right_action_items: [['radio-tower', partial(root.change_screen, 'feed')], ['account-group', partial(root.change_screen, 'people')], ['calendar', partial(root.change_screen, 'events')], ['message-processing-outline', partial(root.change_screen, 'messages')], ['bell-outline', partial(root.change_screen, 'notifications')]]
right_action_items: [['post-outline', partial(root.change_screen, 'feed')], ['message-processing-outline', partial(root.change_screen, 'messages')], ['bell-outline', partial(root.change_screen, 'notifications')]]
left_action_items: [[f"assets/fist2.png", partial(root.change_screen, 'feed')]]
right_action_items: [['post-outline', partial(root.change_screen, 'feed')], ['message-processing-outline', partial(root.change_screen, 'messages')], ['bell-outline', partial(root.change_screen, 'notifications')], ['account-circle-outline', partial(root.change_screen, 'notifications')]]
#left_action_items: [[f"assets/fist2.png", partial(root.change_screen, 'feed')]]
font_context: None
font_name: f'assets/Strengthen.ttf'
@ -148,7 +226,7 @@ MyLayout:
id: buttonbox
size_hint_y: None
adaptive_width: True
height: dp(56)
height: '56dp'
spacing: '10dp'
pos_hint: {'center_x': .5}

@ -24,6 +24,8 @@ from kivy.uix.image import Image, AsyncImage
import requests,json
from kivy.storage.jsonstore import JsonStore
from kivy.core.window import Window
from kivy.core.text import LabelBase
Window.size = (640, 1136) #(2.65 * 200, 5.45 * 200)
@ -42,34 +44,71 @@ class MyLayout(MDBoxLayout):
class MyBoxLayout(MDBoxLayout): pass
class MyLabel(MDLabel): pass
### POST CODE
class PostTitle(MDLabel): pass
class PostContent(MDLabel): pass
class PostGridLayout(GridLayout): pass
class PostImage(AsyncImage): pass
class PostContent(MDLabel):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.bind(width=lambda s, w: s.setter('text_size')(s, (w, None)))
self.bind(texture_size=self.setter('size'))
self.font_name='assets/overpass-mono-regular.otf'
#pass
class PostAuthorLayout(MDBoxLayout): pass
class PostAuthorLabel(MDLabel):
def __init__(self,**kwargs):
super().__init__(**kwargs)
self.bind(width=lambda s, w: s.setter('text_size')(s, (w, None)))
self.bind(texture_size=self.setter('size'))
self.font_name='assets/overpass-mono-regular.otf'
pass
class PostAuthorAvatar(AsyncImage): pass
class PostCard(MDCard):
def __init__(self, title = None, img_src = None, content = None):
def __init__(self, author = None, title = None, img_src = None, content = None):
super().__init__()
self.author = author
self.title = title
self.img_src = img_src
self.content = content
self.bind(minimum_height=self.setter('height'))
# pieces
author_section_layout = PostAuthorLayout()
author_label = PostAuthorLabel(text=self.author)
author_label.font_size = '28dp'
author_avatar = PostAuthorAvatar(source=self.img_src)
author_section_layout.add_widget(author_avatar)
author_section_layout.add_widget(author_label)
# author_section_layout.add_widget(author_avatar)
self.add_widget(author_section_layout)
# add to screen
#self.ids.post_title.text = self.title
#self.ids.post_content.text = self.content
#self.ids.post_img.source = self.img_src
title = PostTitle(text=self.title)
image = AsyncImage(source=self.img_src)
# image = PostImage(source=self.img_src)
content = PostContent(text=self.content)
#content = PostContent()
# add to screen
self.add_widget(title)
self.add_widget(image)
# self.add_widget(image)
self.add_widget(content)
#self.add_widget(layout)
#####
#### LOGIN
class ProtectedScreen(MDScreen):
def on_pre_enter(self):
global app
@ -104,22 +143,45 @@ class FeedScreen(ProtectedScreen):
if i>lim: break
#post = Post(title=f'Marx Zuckerberg', content=ln.strip())
post = PostCard(title='Marx Zuckerberg',img_src='avatar.jpg',content=ln.strip())
post = PostCard(author='Marx Zuckerberg',title='',img_src='avatar.jpg',content=ln.strip())
print(post)
root.ids.post_carousel.add_widget(post)
def get_tor_proxy_session():
session = requests.session()
# Tor uses the 9050 port as the default socks port
session.proxies = {'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
return session
def get_tor_python_session():
from torpy.http.requests import TorRequests
with TorRequests() as tor_requests:
with tor_requests.get_session() as s:
return s
from kivymd.font_definitions import theme_font_styles
class MainApp(MDApp):
title = 'Komrade'
api = 'http://localhost:5555/api'
#api = 'http://localhost:5555/api'
api = 'http://128.232.229.63:5555/api'
#api = 'http://komrades.net:5555/api'
logged_in=False
store = JsonStore('komrade.json')
login_expiry = 60 * 60 * 24 * 7 # once a week
#login_expiry = 5 # 5 seconds
def get_session(self):
return get_tor_proxy_session()
#return get_tor_python_session()
def build(self):
# bind
global app,root
app = self
self.root = root = Builder.load_file('main.kv')
@ -159,21 +221,27 @@ class MainApp(MDApp):
def login(self,un,pw):
url = self.api+'/login'
res = requests.post(url, json={'name':un, 'passkey':pw})
url = self.api+'/login'
if res.status_code==200:
self.do_login()
else:
self.root.ids.login_status.text=res.text
with self.get_session() as sess:
#res = requests.post(url, json={'name':un, 'passkey':pw})
res = sess.post(url, json={'name':un, 'passkey':pw})
if res.status_code==200:
self.do_login()
else:
self.root.ids.login_status.text=res.text
def register(self,un,pw):
url = self.api+'/register'
res = requests.post(url, json={'name':un, 'passkey':pw})
if res.status_code==200:
self.do_login()
else:
self.root.ids.login_status.text=res.text
url = self.api+'/register'
with self.get_session() as sess:
#res = requests.post(url, json={'name':un, 'passkey':pw})
res = sess.post(url, json={'name':un, 'passkey':pw})
if res.status_code==200:
self.do_login()
else:
self.root.ids.login_status.text=res.text

Binary file not shown.

After

Width:  |  Height:  |  Size: 224 KiB

@ -6,37 +6,43 @@ import struct
#hostname = 'ifconfig.me' # It's possible use onion hostname here as well
#port = 80
hostname = '128.232.229.63' #:5555'
#hostname = 'komrades.net'
hostname = '128.232.229.63'
port = 5555
#from torpy.http.requests import tor_requests_session
#with tor_requests_session() as s:
def try_torpy():
from torpy.http.requests import TorRequests
with TorRequests() as tor_requests:
with tor_requests.get_session() as s:
#with requests.Session() as s:
#res = s.get('http://'+hostname+':'+str(port) + '/api/followers/MrY')
#print(json.loads(res.text))
res = s.get('http://'+hostname+':'+str(port))
print(res,res.text)
from torpy.http.requests import TorRequests
with TorRequests() as tor_requests:
with tor_requests.get_session() as s:
#with requests.Session() as s:
#res = s.get('http://'+hostname+':'+str(port) + '/api/followers/MrY')
#print(json.loads(res.text))
res = s.get('http://'+hostname+':'+str(port))
print(res,res.text)
def try_proxy():
import requests
def get_tor_session():
session = requests.session()
# Tor uses the 9050 port as the default socks port
session.proxies = {'http': 'socks5://127.0.0.1:9050',
'https': 'socks5://127.0.0.1:9050'}
return session
# tor = TorClient()
# Make a request through the Tor connection
# IP visible through Tor
session = get_tor_session()
print(session.get("http://"+hostname+':'+str(port)).text)
# Above should print an IP different than your public IP
# Following prints your normal public IP
print(session.get("http://ifconfig.me").text)
# # # Choose random guard node and create 3-hops circuit
# # try:
# # with tor.create_circuit(3) as circuit:
# # # Create tor stream to host
# # with circuit.create_stream((hostname, port)) as stream:
# # # Now we can communicate with host
# # stream.send(b'GET / HTTP/1.0\r\nHost: %s\r\n\r\n' % hostname.encode())
# # recv = stream.recv(1024 * 10)
# # print(recv)
# # except struct.error as e:
# # print('struct error!?',e)
try_proxy()
#try_torpy()

@ -0,0 +1 @@
SSL_DISABLE=True
Loading…
Cancel
Save