mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-02 22:21:21 +00:00
Fix wiki updates
Requires 'curl' to be system-wide available. Will show 'Cannot find curl' message if not found.
This commit is contained in:
parent
afcf38574d
commit
3660383f3c
|
@ -19,6 +19,7 @@ DIM SHARED windowSettingsSection$, colorSettingsSection$, customDictionarySectio
|
||||||
DIM SHARED mouseSettingsSection$, generalSettingsSection$, displaySettingsSection$
|
DIM SHARED mouseSettingsSection$, generalSettingsSection$, displaySettingsSection$
|
||||||
DIM SHARED colorSchemesSection$, debugSettingsSection$, iniFolderIndex$, DebugInfoIniWarning$, ConfigFile$
|
DIM SHARED colorSchemesSection$, debugSettingsSection$, iniFolderIndex$, DebugInfoIniWarning$, ConfigFile$
|
||||||
DIM SHARED idebaseTcpPort AS LONG, AutoAddDebugCommand AS _BYTE
|
DIM SHARED idebaseTcpPort AS LONG, AutoAddDebugCommand AS _BYTE
|
||||||
|
DIM SHARED wikiBaseAddress$
|
||||||
|
|
||||||
ConfigFile$ = "internal/config.ini"
|
ConfigFile$ = "internal/config.ini"
|
||||||
iniFolderIndex$ = STR$(tempfolderindex)
|
iniFolderIndex$ = STR$(tempfolderindex)
|
||||||
|
@ -217,6 +218,13 @@ IF result = 0 OR idedebuginfo <> 1 THEN
|
||||||
END IF
|
END IF
|
||||||
Include_GDB_Debugging_Info = idedebuginfo
|
Include_GDB_Debugging_Info = idedebuginfo
|
||||||
|
|
||||||
|
wikiBaseAddress$ = "https://wiki.qb64.org"
|
||||||
|
IF ReadConfigSetting(generalSettingsSection$, "WikiBaseAddress", value$) THEN
|
||||||
|
wikiBaseAddress$ = value$
|
||||||
|
ELSE WriteConfigSetting generalSettingsSection$, "WikiBaseAddress", wikiBaseAddress$
|
||||||
|
END IF
|
||||||
|
|
||||||
|
|
||||||
'Mouse settings ---------------------------------------------------------------
|
'Mouse settings ---------------------------------------------------------------
|
||||||
result = ReadConfigSetting(mouseSettingsSection$, "SwapMouseButton", value$)
|
result = ReadConfigSetting(mouseSettingsSection$, "SwapMouseButton", value$)
|
||||||
IF UCASE$(value$) = "TRUE" OR VAL(value$) = -1 THEN
|
IF UCASE$(value$) = "TRUE" OR VAL(value$) = -1 THEN
|
||||||
|
|
|
@ -49,6 +49,13 @@ FUNCTION Wiki$ (PageName$)
|
||||||
END IF
|
END IF
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
|
IF _SHELLHIDE("curl --version") <> 0 THEN
|
||||||
|
PCOPY 2, 0
|
||||||
|
result = idemessagebox("QB64", "Cannot find 'curl'.", "#Abort")
|
||||||
|
PCOPY 3, 0: SCREEN , , 3, 0
|
||||||
|
EXIT FUNCTION
|
||||||
|
END IF
|
||||||
|
|
||||||
IF Help_Recaching = 0 THEN
|
IF Help_Recaching = 0 THEN
|
||||||
a$ = "Downloading '" + PageName$ + "' page..."
|
a$ = "Downloading '" + PageName$ + "' page..."
|
||||||
IF LEN(a$) > 60 THEN a$ = LEFT$(a$, 57) + STRING$(3, 250)
|
IF LEN(a$) > 60 THEN a$ = LEFT$(a$, 57) + STRING$(3, 250)
|
||||||
|
@ -60,58 +67,36 @@ FUNCTION Wiki$ (PageName$)
|
||||||
PCOPY 3, 0
|
PCOPY 3, 0
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
url$ = "www.qb64.org/wiki/index.php?title=" + PageName2$ + "&action=edit"
|
url$ = CHR$(34) + wikiBaseAddress$ + "/index.php?title=" + PageName2$ + "&action=edit" + CHR$(34)
|
||||||
'when fetching from .org, look for name="wpTextbox1">
|
outputFile$ = Cache_Folder$ + "/" + PageName2$ + ".txt"
|
||||||
s1$ = "name=" + CHR$(34) + "wpTextbox1" + CHR$(34) + ">"
|
|
||||||
url2$ = url$
|
|
||||||
x = INSTR(url2$, "/")
|
|
||||||
IF x THEN url2$ = LEFT$(url$, x - 1)
|
|
||||||
c = _OPENCLIENT("TCP/IP:80:" + url2$)
|
|
||||||
IF c = 0 THEN
|
|
||||||
EXIT FUNCTION
|
|
||||||
END IF
|
|
||||||
e$ = CHR$(13) + CHR$(10)
|
|
||||||
url3$ = RIGHT$(url$, LEN(url$) - x + 1)
|
|
||||||
x$ = "GET " + url3$ + " HTTP/1.1" + e$
|
|
||||||
x$ = x$ + "Host: " + url2$ + e$ + e$
|
|
||||||
PUT #c, , x$
|
|
||||||
t! = TIMER
|
|
||||||
|
|
||||||
DO
|
'wiki text delimiters:
|
||||||
GET #c, , a2$
|
s1$ = "name=" + CHR$(34) + "wpTextbox1" + CHR$(34) + ">"
|
||||||
IF LEN(a2$) THEN
|
s2$ = "</textarea>"
|
||||||
a$ = a$ + a2$
|
|
||||||
IF INSTR(a$, "</body>") THEN
|
SHELL _HIDE "curl -o " + CHR$(34) + outputFile$ + CHR$(34) + " " + url$
|
||||||
CLOSE #c
|
fh = FREEFILE
|
||||||
s2$ = "</textarea>"
|
OPEN outputFile$ FOR BINARY AS #fh 'get new content
|
||||||
s1 = INSTR(a$, s1$): IF s1 = 0 THEN EXIT FUNCTION
|
a$ = SPACE$(LOF(fh))
|
||||||
s1 = s1 + LEN(s1$)
|
GET #fh, 1, a$
|
||||||
s2 = INSTR(a$, s2$): IF s2 = 0 THEN EXIT FUNCTION
|
CLOSE #fh
|
||||||
s2 = s2 - 1
|
|
||||||
IF s1 > s2 THEN EXIT FUNCTION
|
s1 = INSTR(a$, s1$)
|
||||||
a$ = MID$(a$, s1, s2 - s1 + 1)
|
IF s1 > 0 THEN
|
||||||
fh = FREEFILE
|
'clean up downloaded contents
|
||||||
E = 0
|
a$ = MID$(a$, s1 + LEN(s1$))
|
||||||
ON ERROR GOTO qberror_test
|
s2 = INSTR(a$, s2$)
|
||||||
OPEN Cache_Folder$ + "/" + PageName2$ + ".txt" FOR OUTPUT AS #fh 'clear old content
|
IF s2 > 0 THEN
|
||||||
ON ERROR GOTO qberror
|
a$ = LEFT$(a$, s2)
|
||||||
IF E = 0 THEN
|
|
||||||
CLOSE #fh
|
|
||||||
ON ERROR GOTO qberror_test
|
|
||||||
OPEN Cache_Folder$ + "/" + PageName2$ + ".txt" FOR BINARY AS #fh
|
|
||||||
ON ERROR GOTO qberror
|
|
||||||
IF E = 0 THEN
|
|
||||||
PUT #fh, , a$
|
|
||||||
CLOSE #fh
|
|
||||||
END IF
|
|
||||||
END IF
|
|
||||||
Wiki$ = a$
|
|
||||||
EXIT FUNCTION
|
|
||||||
END IF
|
|
||||||
END IF
|
END IF
|
||||||
_LIMIT 100
|
|
||||||
LOOP UNTIL ABS(TIMER - t!) > 20
|
OPEN outputFile$ FOR OUTPUT AS #fh 'clear old content
|
||||||
CLOSE #c
|
PRINT #fh, a$ 'save clean content
|
||||||
|
CLOSE #fh
|
||||||
|
END IF
|
||||||
|
|
||||||
|
Wiki$ = a$
|
||||||
|
EXIT FUNCTION
|
||||||
END FUNCTION
|
END FUNCTION
|
||||||
|
|
||||||
SUB Help_AddTxt (t$, col, link)
|
SUB Help_AddTxt (t$, col, link)
|
||||||
|
|
Loading…
Reference in a new issue