Updater 2.0
This commit is contained in:
parent
4aedf493c6
commit
b98b3670b4
1 changed files with 142 additions and 4 deletions
|
@ -68,12 +68,14 @@ def Open(win, filename, name):
|
|||
# try using it. ( the lbry3.vanwanet.com/speech/ is the
|
||||
# actuall link it redircts to )
|
||||
|
||||
filename = filename.replace("lbry://", "https://lbry3.vanwanet.com/speech/")
|
||||
|
||||
print("LBRY links: "+filename)
|
||||
filename = filename.replace("lbry://", "https://spee.ch/")
|
||||
print("REQUESTING: "+filename)
|
||||
http = urllib3.PoolManager()
|
||||
resp = http.request('GET', filename)
|
||||
print("FILE RECIEVED!")
|
||||
md = resp.data.decode('utf-8')
|
||||
|
||||
print("FILE CONVERTED")
|
||||
|
||||
|
||||
elif not filename.endswith(".md"):
|
||||
|
@ -355,6 +357,15 @@ def Open(win, filename, name):
|
|||
return(tree)
|
||||
|
||||
def search_convert(s):
|
||||
|
||||
# This function convers a chapter name into a link
|
||||
# such links are use in notabug.org to link to chapters
|
||||
# for example example.com/file.md#chapter-name
|
||||
# With this url it will load the example.com/file.md and
|
||||
# then skip to the "Chapter Name" chapter.
|
||||
|
||||
# This function transforms "Chapter Name" into "chapter-name"
|
||||
|
||||
l = " ./\|[]{}()?!@#$%^&*`~:;'\"=,<>"
|
||||
s = s.lower().replace(" ","-")
|
||||
r = ""
|
||||
|
@ -578,6 +589,7 @@ def draw(outlayer, win, name, x, y, width, height):
|
|||
newX = 10
|
||||
newY = 0
|
||||
|
||||
|
||||
for block in md:
|
||||
|
||||
# THE # HEADERS
|
||||
|
@ -882,6 +894,132 @@ def draw(outlayer, win, name, x, y, width, height):
|
|||
|
||||
############################################################################
|
||||
|
||||
# #########################################
|
||||
|
||||
# BEFORE WE GONNA END THE DRAWING OF THE
|
||||
# MARKDOWN. IF IT'S UPDATE INFORMATION WE
|
||||
# NEED TO GET THE USER A LIST OF FILES WITH
|
||||
# 2 BUTTONS. TO OPEN, TO VIEW IN NOTABUG
|
||||
# AND TO SEE HISTORY.
|
||||
|
||||
# #########################################
|
||||
|
||||
if "update_markdown_files" in win.current:
|
||||
files = win.current["update_markdown_files"]
|
||||
|
||||
tyleX = 50
|
||||
|
||||
for file in files:
|
||||
|
||||
if int(current_Y + win.scroll["markdown"] + 100) in range(0-100, win.current["h"]):
|
||||
|
||||
# Making the layer
|
||||
nodesurface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 170, 250)
|
||||
node = cairo.Context(nodesurface)
|
||||
node.select_font_face("Monospace", cairo.FONT_SLANT_NORMAL, cairo.FONT_WEIGHT_NORMAL)
|
||||
|
||||
|
||||
UI_elements.roundrect(node, win,
|
||||
0,
|
||||
0,
|
||||
170,
|
||||
250,
|
||||
10,
|
||||
fill=False)
|
||||
|
||||
node.clip()
|
||||
|
||||
# Background
|
||||
UI_color.set(node, win, "dark_overdrop")
|
||||
node.rectangle(0,0,170, 250)
|
||||
node.fill()
|
||||
|
||||
# Banner
|
||||
UI_color.set(node, win, "node_asset")
|
||||
node.rectangle(0,0,170, 20)
|
||||
node.fill()
|
||||
|
||||
# Outputting the layer
|
||||
layer.set_source_surface(nodesurface,
|
||||
tyleX-10,
|
||||
current_Y + win.scroll["markdown"] + 120)
|
||||
layer.paint()
|
||||
|
||||
# ICON
|
||||
UI_elements.image(layer, win, file,
|
||||
tyleX,
|
||||
current_Y + win.scroll["markdown"] + 140,
|
||||
150,
|
||||
150,
|
||||
cell="update_previews")
|
||||
# NAME
|
||||
UI_color.set(layer, win, "text_normal")
|
||||
layer.set_font_size(12)
|
||||
layer.move_to(tyleX,
|
||||
current_Y + win.scroll["markdown"] + 135)
|
||||
layer.show_text(file[file.rfind("/")+1:][:22])
|
||||
|
||||
# BUTTON
|
||||
def do():
|
||||
win.current["mdfs"]["failsafe"] = filename
|
||||
win.current["mdfs"][name] = file
|
||||
win.current["update_markdown_files"] = []
|
||||
layer.set_line_width(4)
|
||||
UI_elements.roundrect(layer, win,
|
||||
tyleX-10,
|
||||
current_Y + win.scroll["markdown"] + 120,
|
||||
170,
|
||||
200,
|
||||
10,
|
||||
button=do,
|
||||
tip=file,
|
||||
fill=False,
|
||||
offset=[x,y])
|
||||
|
||||
layer.stroke()
|
||||
layer.set_line_width(2)
|
||||
|
||||
# Two buttons for notabug version and history of the file
|
||||
|
||||
ntbg = "https://notabug.org/jyamihud/VCStudio/src/master/"
|
||||
|
||||
def do():
|
||||
oscalls.Open(ntbg+file)
|
||||
UI_elements.roundrect(layer, win,
|
||||
tyleX+35,
|
||||
current_Y + win.scroll["markdown"] + 120+205,
|
||||
40,
|
||||
40,
|
||||
10,
|
||||
button=do,
|
||||
tip=ntbg+file,
|
||||
icon="notabug",
|
||||
offset=[x,y])
|
||||
|
||||
ntbg = "https://notabug.org/jyamihud/VCStudio/commits/master/"
|
||||
|
||||
def do():
|
||||
oscalls.Open(ntbg+file)
|
||||
UI_elements.roundrect(layer, win,
|
||||
tyleX+75,
|
||||
current_Y + win.scroll["markdown"] + 120+205,
|
||||
40,
|
||||
40,
|
||||
10,
|
||||
button=do,
|
||||
tip=ntbg+file,
|
||||
icon="history",
|
||||
offset=[x,y])
|
||||
|
||||
tyleX = tyleX + 200
|
||||
|
||||
if tyleX > width-210:
|
||||
tyleX = 50
|
||||
|
||||
current_Y = current_Y + 270
|
||||
|
||||
current_Y = current_Y + 400
|
||||
|
||||
# Scroll
|
||||
UI_elements.scroll_area(outlayer, win, "markdown",
|
||||
x+0,
|
||||
|
|
Loading…
Reference in a new issue