lots of fixes!

pull/20/head
quadrismegistus 4 years ago
parent 29c6f31040
commit b1f5fe3e0e

BIN
app/.DS_Store vendored

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 333 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 KiB

@ -81,6 +81,7 @@ class MyLayout(MDBoxLayout):
self.scr_mngr.current = screen
def change_screen_from_uri(self,uri,*args):
self.app.uri=uri
screen_name = route(uri)
self.app.screen = screen_name
self.app.log(f'routing to {screen_name}')
@ -210,6 +211,12 @@ class MainApp(MDApp):
self.screen=screen
self.root.change_screen(screen,*args)
@property
def channel(self):
if not hasattr(self,'uri'): return None
if self.uri.count('/')<2: return None
return self.uri.split('/')[2]
def change_screen_from_uri(self,uri,*args):
self.uri=uri
self.log('CHANGING SCREEN',uri,'??')
@ -387,6 +394,7 @@ class MainApp(MDApp):
if not 'val' in d: continue
newdict = dict(d['val'].items())
newdict['timestamp']=float(d['time'])
newdict['to_name']=d['channel']
newdata.append(newdict)
# return index

@ -16,6 +16,7 @@
#:import rgb main.rgb
#:import COLOR_BG main.COLOR_BG
#:import BG_IMG main.BG_IMG
#:import COLOR_TEXT main.COLOR_TEXT
## CLASS DEFS
@ -36,7 +37,7 @@
<MyLabel>:
theme_text_color: 'Custom'
text_color: rgb(201,203,163)
text_color: rgb(*COLOR_TEXT)
# pos_hint: {'center_y': 0.5}
halign: 'center'
height: self.texture_size[1]
@ -163,7 +164,7 @@ MyLayout:
background_palette: 'Red'
theme_text_color:'Custom'
background_hue: '500'
right_action_items: [['earth', partial(root.change_screen, 'feed')],['email-receive-outline', partial(root.change_screen, 'messages')],['account-tie-voice-outline', partial(root.change_screen, 'profile')],['pencil-plus-outline', partial(root.change_screen, 'post')], ['wardrobe-outline', partial(root.change_screen, 'login')]]
right_action_items: [['card-text', partial(root.change_screen_from_uri, '/inbox/world')],['pencil-plus-outline', partial(root.change_screen, 'post')],['message-outline', partial(root.change_screen, 'messages')],['account-circle-outline', partial(root.change_screen, 'profile')],['exit-run', partial(root.change_screen, 'login')]]
#left_action_items: [[f"assets/fist2.png", partial(root.change_screen, 'feed')]]
# ['bell-outline', partial(root.change_screen, 'login')]

@ -146,7 +146,7 @@
# font_style:'H5'
#font_name: "Strengthen"
# height: '400'
#size_hint_y: 1
size_hint_y: 1
text_color:rgb(*COLOR_TEXT)
theme_text_color: 'Custom'
halign: 'left'

@ -63,7 +63,10 @@ class PostAuthorLabel(MDLabel):
# # raise Exception([item.disabled, item.text])
# except AttributeError:
# pass
self.parent.parent.parent.open_author_option()
try:
self.parent.parent.parent.open_author_option()
except AttributeError:
pass
#raise Exception(self.text)
# self.text = '!!!'
@ -104,6 +107,9 @@ class PostCard(MDCard):
# self.log('PostCard() got data: '+str(data))
self.author = data.get('author','[Anonymous]')
self.recipient = data.get('to_name','')
if not self.recipient:
self.recipient=self.app.channel
self.img_id = data.get('file_id','')
self.img_ext = data.get('file_ext','')
self.img_src=self.img_id[:3]+'/'+self.img_id[3:]+'.'+self.img_ext if self.img_id else ''
@ -137,7 +143,7 @@ class PostCard(MDCard):
self.author_label.text+='\n[size=14sp]to '+recip+'[/size]'
self.author_label.markup=True
self.author_label.font_size = '18sp'
self.author_avatar = author_avatar = PostAuthorAvatar(source='assets/avatar.jpg') #self.img_src)
self.author_avatar = author_avatar = PostAuthorAvatar(source=f'assets/avatars/{self.author}.png') #self.img_src)
self.author_section_layout.add_widget(author_avatar)
self.author_section_layout.add_widget(author_label)
# self.author_section_layout.add_widget(MDSeparator(height='1sp',size_hint=(None,None)))
@ -258,22 +264,3 @@ class FeedScreen(BaseScreen):
self.ids.post_carousel.add_widget(post_obj)
asyncio.create_task(go())
def on_pre_enter_test(self):
i=0
lim=5
with open('tweets.txt') as f:
for ln in f:
if ln.startswith('@') or ln.startswith('RT '): continue
i+=1
if i>lim: break
#post = Post(title=f'Marx Zuckerberg', content=ln.strip())
post = PostCard(
author='Marx Zuckerberg',
title='',
img_src='avatar.jpg',
content=ln.strip())
print(post)
self.ids.post_carousel.add_widget(post)

@ -1,5 +1,7 @@
#:import ProfileScreen screens.profile.profile.ProfileScreen
#:import COLOR_TEXT main.COLOR_TEXT
#:import COLOR_LOGO main.COLOR_LOGO
#:import COLOR_CARD main.COLOR_CARD
#:import rgb main.rgb
<ProfileScreen>:
@ -23,17 +25,17 @@
adaptive_height: True
# height:'200dp'
# width:'300dp'
# md_bg_color:0,0,0,1
# md_bg_color:rgb(*COLOR_CARD)
pos_hint: {'center_x':0.5, 'y':0} #,'top':0.25}
# radius:[20,]
# border_radius:20
canvas:
Color:
rgb: 0,0,0,1
Line:
width: 2
# rectangle: (self.x, self.y, self.width, self.height)
circle: (self.center_x, self.center_y, min(self.width, self.height) / 2) #(self.x, self.x, self.width)
# canvas:
# Color:
# rgb: rgb(*COLOR_BG)
# Line:
# width: 2
# # rectangle: (self.x, self.y, self.width, self.height)
# circle: (self.center_x, self.center_y, min(self.width, self.height) / 2) #(self.x, self.x, self.width)
<LayoutCover>:
cols:1
@ -41,7 +43,7 @@
size_hint:None,None
# height:'200dp'
# width:'300dp'
md_bg_color:0,0,0,1
md_bg_color:rgb(*COLOR_CARD)
# height: '500dp'
pos_hint: {'center_x':0.5,'center_y':0.5} #,'y':0.8}
# radius:[20,]
@ -53,7 +55,7 @@
# size: self.size
# # source: self.source
Color:
rgb: 0,0,0,1
rgb: rgb(*COLOR_CARD)
Line:
width: 2
rectangle: (self.x, self.y, self.width, self.height)
@ -62,10 +64,11 @@
<AuthorInfoLayout>:
cols:1
orientation:'vertical'
size_hint:0.6666,None
md_bg_color:0,0,0,1
size_hint:None,None
md_bg_color:rgb(*COLOR_CARD)
# width: '300dp'
height: self.minimum_height
width: '500sp'
pos_hint: {'center_x':0.5,'center_y':0.5}
spacing:'10sp'
radius:[20,]

@ -21,9 +21,6 @@ from misc import *
img_src = 'assets/avatar.jpg' #cache/img/1e6/587e880344d1e88cec8fda65b1148.jpeg'
# img_src = '/home/ryan/Pictures/Harrier.jpeg'
cover_img_src='assets/cover.jpg' #cache/img/60d/9de00e52e4758ade5969c50dc053f.jpg'
class ProfileAvatar(Image):
def on_touch_down(self, touch):
@ -201,6 +198,7 @@ class ProfileScreen(BaseScreen):
def make_profile_img(self,width,do_crop=True,circ_img=None,bw=False,circularize=True):
img_src = f'assets/avatars/{self.app.username}.png'
circ_img = circularize_img(img_src,width,do_crop=do_crop,bw=bw,circularize=circularize)
@ -216,10 +214,10 @@ class ProfileScreen(BaseScreen):
avatar_layout.add_widget(avatar)
return (circ_img,byte,avatar,avatar_layout)
def on_pre_enter(self, width=200):
def on_pre_enter(self, width=300):
# query author info
if not self.username: self.username=self.app.username
#if not self.username: self.username=self.app.username
# @TODO
if not self.clock_scheduled:
@ -248,21 +246,23 @@ class ProfileScreen(BaseScreen):
## author info
self.author_info_layout = AuthorInfoLayout()
self.app.name_irl = 'Marx Zuckerberg'
#self.app.name_irl = 'Marx Zuckerberg'
self.app.name_irl = 'Komrade @'+self.app.username
if hasattr(self.app,'name_irl'):
self.author_name_irl = AuthorName(text=self.app.name_irl)
self.author_name_irl.font_name = 'assets/font.otf'
self.author_name_irl.font_size = '28sp'
self.author_info_layout.add_widget(self.author_name_irl)
self.author_name = AuthorUsername(text='@'+self.username)
self.author_name = AuthorUsername(text='@'+self.app.username)
self.author_name.font_name = 'assets/font.otf'
self.author_name.font_size = '20sp'
self.author_info_layout.add_widget(self.author_name)
# self.author_info_layout.add_widget(self.author_name)
## AUTHOR DESCRIPTION
self.author_desc = AuthorDesc(text='Blogging bad takes since 1999. Writing on abstraction as literary & capitalist form')
self.author_desc = AuthorDesc(text='... etc ...')
self.author_desc.font_name='assets/font.otf'
self.author_desc.font_size='18sp'
# self.author_desc.halign='left'
@ -271,26 +271,26 @@ class ProfileScreen(BaseScreen):
self.author_pronouns = AuthorPronouns(label='he/him',icon='gender-transgender')
## AUTHOR PLACE
self.author_place = AuthorPlace(label='UK',icon='map-marker-outline')
self.author_place = AuthorPlace(label='Earth',icon='map-marker-outline')
## Website
self.author_website = AuthorWebsite(label='ryanheuser.org', icon='link-variant')
self.author_website = AuthorWebsite(label='website.org', icon='link-variant')
## Followers
self.follower_layout = FollowerLayout()
self.author_followers = AuthorFollowers(label='13 followers',icon='account-arrow-left')
self.author_following = AuthorFollowing(label='777 following',icon='account-arrow-right')
# self.author_followers = AuthorFollowers(label='13 followers',icon='account-arrow-left')
self.author_following = AuthorFollowing(label='13 komrades',icon='account-multiple')
## add to layout
self.author_info_layout.add_widget(self.author_desc)
self.author_info_layout.add_widget(self.author_pronouns)
self.author_info_layout.add_widget(self.author_place)
self.author_info_layout.add_widget(self.author_website)
# self.author_info_layout.add_widget(self.author_website)
self.follower_layout.add_widget(self.author_following)
self.follower_layout.add_widget(self.author_followers)
# self.follower_layout.add_widget(self.author_followers)
self.author_info_layout.add_widget(self.follower_layout)
# class AuthorPlace(MDLabel): pass

@ -282,7 +282,8 @@ class Api(object):
# encrypt?
encrypt_for_pubkey_b = serialize_pubkey(encrypt_for_pubkey)
time_b=base64.b64encode(str(timestamp).encode('utf-8')) #.encode()
#time_b=base64.b64encode(str(timestamp).encode('utf-8')) #.encode()
time_b=str(timestamp).encode('utf-8')
msg=value_bytes
# whole binary package
@ -340,11 +341,15 @@ class Api(object):
### NEW FIRST LINE: Try to decrypt!
val=None
key_used=None
for keyname,privkey in self.keys.items():
self.log(keyname,privkey,'??')
try:
# clicked!
val = aes_rsa_decrypt(encrypted_payload,privkey,*decryption_tools)
#self.log('decrypted =',val)
key_used=keyname
# this must mean this was the recipient
self.log(f'unlocked using key {keyname}!')
break
except ValueError as e:
self.log(keyname,'did not work!') #,privkey,pubkey)
@ -375,8 +380,9 @@ class Api(object):
# private_key=self.private_key_global
WDV={
'time':float(base64.b64decode(time_b).decode()),
'val':base64.b64decode(msg),
'time':float(time_b.decode('utf-8')),
'val':msg.decode('utf-8'),
'channel':key_used
# 'to':receiver_pubkey_b,
# 'from':sender_pubkey_b,
# 'sign':signature
@ -459,7 +465,7 @@ class Api(object):
def jsonize_dat(dat_dict):
if type(dat_dict)==dict and 'val' in dat_dict:
self.log('is this json???',dat_dict['val'],'???')
dat_dict['val']=json.loads(dat_dict['val'].decode('utf-8'))
dat_dict['val']=json.loads(dat_dict['val'])
#dat_dict['val']=json.loads(base64.b64decode(dat_dict['val']).decode('utf-8'))
return dat_dict
@ -494,6 +500,7 @@ class Api(object):
if type(val)!=str:
val=json.dumps(value)
bval=val.encode('utf-8')
return bval
self.log(f'api.set_json({key}, {value} ...)')
@ -645,7 +652,10 @@ class Api(object):
async def append_data(self,uri,bdata):
self.log(f'appending to uri {uri}')
self.log(f'appending to uri {uri}, data {bdata}')
if type(bdata)!=bytes and type(bdata)==str:
bdata=bdata.encode('utf-8')
self.log(f'--> encoded bdata to {bdata}')
# get blob so far
sofar = await self.get(uri,decode_data=False)
@ -653,9 +663,10 @@ class Api(object):
# get sofar
self.log(f'sofar = {sofar}')
newval = sofar+BSEP+sofar
newval = bdata if sofar is None else sofar+BSEP+bdata
self.log(f'newval = {newval}')
res = await self.set(key,new,encode_data=False)
res = await self.set(uri,newval,encode_data=False)
if res:
length = newval.count(BSEP)+1
return {'success':'Length increased to %s' % length}
@ -737,6 +748,7 @@ class Api(object):
# ## add to inbox
post_id = get_random_id()
self.load_keys()
author_privkey = self.keys[data.get('author')]
self.log('ADDING TO CHANNEL??',channel)
@ -815,7 +827,9 @@ class Api(object):
index = await self.get(uri,decode_data=False)
self.log(f'api.get_post_ids(uri={uri}) <-- api.get()',index)
if not index: return []
index = json.loads(base64.b64decode(index).decode())
#index = json.loads(base64.b64decode(index).decode())
index = [x.decode('utf-8') for x in index.split(BSEP)]
if index is None: return []
if type(index)!=list: index=[index]

Loading…
Cancel
Save