Browse Source

Fixed some path issues, Task title displays URL.

master
Alec Murphy 5 years ago
parent
commit
8ed9638874
  1. 28
      Uriel.HC
  2. 76
      uriel.py

28
Uriel.HC

@ -8,6 +8,7 @@
#define URIEL_THUMB_BMP "/Tmp/UrielThumb.bmp"
#define URIEL_VERSION "Uriel/0.2"
Bool URIEL_INSTANCE=FALSE;
U8 URIEL_USER_AGENT[64];
StrCpy(URIEL_USER_AGENT, URIEL_VERSION);
StrCpy(URIEL_USER_AGENT+StrLen(URIEL_USER_AGENT), " (");
@ -68,19 +69,24 @@ U0 U_Browser(U8 *url)
};
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
MemSetU8(ToI64(HGFS_BUF)+size, 0x0, 1);
WinMax;
CDoc *page = DocNew();
DocPrintPartial(page,HGFS_BUF);
DocClear;
DocInsDoc(DocPut,page);
DocTop;
DocDel(page);
while (TRUE) {
cmd = GetStr;
if (StrCmp(cmd,"x")==0) { break; };
}
Free(cmd);
DocBottom;
if (URIEL_INSTANCE==FALSE) {
StrCpy(Fs->task_title, HGBD_PARAM_BUF+128);
URIEL_INSTANCE=TRUE;
while (TRUE) {
cmd = GetStr;
if (StrCmp(cmd,"x")==0) { break; };
};
Free(cmd);
URIEL_INSTANCE=FALSE;
} else {
StrCpy(Fs->parent_task->task_title, HGBD_PARAM_BUF+128);
};
}
U0 U_HistNav(I64 index)
@ -96,21 +102,15 @@ U0 U_HistNav(I64 index)
PopUpOk("Bad URL.");
return;
};
StrCpy(Fs->parent_task->task_title, HGBD_PARAM_BUF+128);
BlkRead(HGBD,HGFS_BUF,1,(size/BLK_SIZE)+1);
MemSetU8(ToI64(HGFS_BUF)+size, 0x0, 1);
WinMax;
CDoc *page = DocNew();
DocPrintPartial(page,HGFS_BUF);
DocClear;
DocInsDoc(DocPut,page);
DocTop;
DocDel(page);
while (TRUE) {
cmd = GetStr;
if (StrCmp(cmd,"x")==0) { break; };
}
Free(cmd);
DocBottom;
}
U0 U_Download(U8 *url)

76
uriel.py

@ -4,6 +4,7 @@ import re
URIEL_GETPAGE = 0x10
URIEL_NAVBACK = 0x11
URIEL_NAVFWD = 0x12
URIEL_STR_SIZE = 144
URIEL_THUMB = 0x13
URIEL_DOWNLOAD = 0x14
@ -51,13 +52,25 @@ def UrielGetPage():
else:
netloc = url_comp.netloc
Uriel.rel.netloc = url_comp.netloc
if url_comp.path != '':
if url_comp.path.find('/') != -1:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
if url_comp.scheme == '' or url_comp.netloc == '':
if url_comp.path[:1] != '/':
path = Uriel.rel.path + url_comp.path
Uriel.rel.path += url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = Uriel.rel.path + url_comp.path
url = scheme + "://" + netloc + urllib.quote(path)
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
url = scheme + "://" + post_scheme
pagedata = subprocess.Popen('wget -q -O - -U "' + Uriel.user_agent + '" "' + url + '" 2>/dev/null', shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
filedata = UrielPreProcess(pagedata, url)
filesize = len(filedata)
@ -82,6 +95,8 @@ def UrielGetPage():
ZeroParamBuf()
os.lseek(HGBD,0,os.SEEK_SET)
os.write(HGBD,str(filesize))
os.lseek(HGBD,128,os.SEEK_SET)
os.write(HGBD,str(url)[:URIEL_STR_SIZE])
os.lseek(HGBD,BLK_SIZE,os.SEEK_SET)
os.write(HGBD,filedata)
logger.info("[Uriel] navigate to " + url)
@ -110,17 +125,32 @@ def UrielNavBack():
netloc = Uriel.rel.netloc
else:
netloc = url_comp.netloc
if url_comp.path != '':
if url_comp.path.find('/') != -1:
path = url_comp.path
if url_comp.scheme == '' or url_comp.netloc == '':
if url_comp.path[:1] != '/':
path = Uriel.rel.path + url_comp.path
Uriel.rel.path += url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = Uriel.rel.path + url_comp.path
url = scheme + "://" + netloc + urllib.quote(path)
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
url = scheme + "://" + post_scheme
filesize = len(filedata)
if filesize>0:
ZeroParamBuf()
os.lseek(HGBD,0,os.SEEK_SET)
os.write(HGBD,str(filesize))
os.lseek(HGBD,128,os.SEEK_SET)
os.write(HGBD,str(url)[:URIEL_STR_SIZE])
os.lseek(HGBD,BLK_SIZE,os.SEEK_SET)
os.write(HGBD,filedata)
logger.info("[Uriel] history navigate back to " + url)
@ -149,17 +179,32 @@ def UrielNavFwd():
netloc = Uriel.rel.netloc
else:
netloc = url_comp.netloc
if url_comp.path != '':
if url_comp.path.find('/') != -1:
path = url_comp.path
if url_comp.scheme == '' or url_comp.netloc == '':
if url_comp.path[:1] != '/':
path = Uriel.rel.path + url_comp.path
Uriel.rel.path += url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = Uriel.rel.path + url_comp.path
url = scheme + "://" + netloc + urllib.quote(path)
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
url = scheme + "://" + post_scheme
filesize = len(filedata)
if filesize>0:
ZeroParamBuf()
os.lseek(HGBD,0,os.SEEK_SET)
os.write(HGBD,str(filesize))
os.lseek(HGBD,128,os.SEEK_SET)
os.write(HGBD,str(url)[:URIEL_STR_SIZE])
os.lseek(HGBD,BLK_SIZE,os.SEEK_SET)
os.write(HGBD,filedata)
logger.info("[Uriel] history navigate fwd to " + url)
@ -191,12 +236,25 @@ def UrielThumb():
netloc = Uriel.rel.netloc
else:
netloc = url_comp.netloc
if url_comp.path != '':
if url_comp.path.find('/') != -1:
path = url_comp.path
if url_comp.scheme == '' or url_comp.netloc == '':
if url_comp.path[:1] != '/':
path = Uriel.rel.path + url_comp.path
Uriel.rel.path += url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = url_comp.path
Uriel.rel.path = url_comp.path[:url_comp.path.rfind('/')+1]
else:
path = Uriel.rel.path + url_comp.path
url = scheme + "://" + netloc + urllib.quote(path)
post_scheme = netloc + "/" + urllib.quote(path)
post_scheme = post_scheme.replace('//','/')
url = scheme + "://" + post_scheme
tmp_thumb = '/tmp/' + str(uuid.uuid4()) + '.bmp'
while os.path.exists(tmp_thumb):
tmp_thumb = '/tmp/' + str(uuid.uuid4()) + '.bmp'

Loading…
Cancel
Save