Redirect old-forum and wiki search results to Pheonix as appropriate.
#5
(05-19-2022, 05:21 AM)Pete Wrote: Looks like a useful plugin.
I made my own in QB64...

I added support for the wiki links, and some options. 
Not as compact and elegant as Pete's code, but it works!

Code: (Select All)
' Opens google qb64.rip links in mirror site.
' https://staging.qb64phoenix.com/showthread.php?tid=429

' DATE         WHO-DONE-IT   DID-WHAT
' 2022-05-18   Pete          Created QB64.org URL redirector.
' 2022-07-22   madscijr      Added options menu and support for wiki.

Const FALSE = 0
Const TRUE = Not FALSE

Dim in$
Dim iCount%: iCount% = 0
Dim oldURL$
Dim parse$
Dim newURL$
Dim bUpdateClipboard%
Dim sOpenBrowser$
Dim sValue$
Dim sMessage$
Dim iPos%

bUpdateClipboard% = TRUE
sOpenBrowser$ = "c"
sMessage$ = ""

Cls
Do
    Cls
    Print "---------------------------------------------------"
    Print "QB64.org link updater by Pete, modified by madscijr"
    Print "Links converted today: " + _Trim$(Str$(iCount%))
    Print "---------------------------------------------------"
    Print "Copy old link to clipboard and press ENTER, or select an option:"
    Print
    If bUpdateClipboard% = TRUE Then sValue$ = "<---" Else sValue$ = ""
    Print "c = copies new link to clipboard......" + sValue$
    If bUpdateClipboard% = FALSE Then sValue$ = "<---" Else sValue$ = ""
    Print "d = do not update clipboard .........." + sValue$
    If sOpenBrowser$ = "g" Then sValue$ = "<---" Else sValue$ = ""
    Print "g = navigates to new link in Chrome..." + sValue$
    If sOpenBrowser$ = "f" Then sValue$ = "<---" Else sValue$ = ""
    Print "f = navigates to new link in Firefox.." + sValue$
    If sOpenBrowser$ <> "g" And sOpenBrowser$ <> "f" Then sValue$ = "<---" Else sValue$ = ""
    Print "n = don't navigate to new link........" + sValue$
    Print "q = quit"

    If Len(sMessage$) > 0 Then
        Print sMessage$
        sMessage$ = ""
    Else
        Print
    End If

    Input "Enter option, or ENTER to convert link and/or navigate"; in$
    in$ = LCase$(_Trim$(in$))
    sMessage$ = Chr$(13)

    If LCase$(_Trim$(in$)) = "c" Then
        bUpdateClipboard% = TRUE
        sMessage$ = sMessage$ + "Clipboard updating: ENABLED" + Chr$(13)
    ElseIf LCase$(_Trim$(in$)) = "d" Then
        bUpdateClipboard% = FALSE
        sMessage$ = sMessage$ + "Clipboard updating: DISABLED" + Chr$(13)
    ElseIf LCase$(_Trim$(in$)) = "g" Then
        sOpenBrowser$ = "g"
        sMessage$ = sMessage$ + "Navigate to new URL: Chrome" + Chr$(13)
    ElseIf LCase$(_Trim$(in$)) = "f" Then
        sOpenBrowser$ = "f"
        sMessage$ = sMessage$ + "Navigate to new URL: Firefox" + Chr$(13)
    ElseIf LCase$(_Trim$(in$)) = "n" Then
        sOpenBrowser$ = "n"
        sMessage$ = sMessage$ + "Navigate to new URL: DISABLED" + Chr$(13)
    ElseIf LCase$(_Trim$(in$)) = "q" Then
        Exit Do
    Else
        If Len(_Clipboard$) Then
            oldURL$ = LCase$(_Clipboard$)

            ' FORUMS:
            ' OLD: https://www.qb64.org/forum/index.php?topic={topic}
            ' NEW: https://qb64forum.alephc.xyz/index.php?topic={topic}

            ' WIKI:
            ' OLD: http://www.qb64.org/wiki/{topic}
            ' NEW: https://qb64phoenix.com/qb64wiki/index.php/{topic}

            If InStr(oldURL$, "/www.qb64.org/forum/index.php") > 0 Then
                ' URL IS FROM FORUMS...
                If InStr(oldURL$, "?topic=") > 0 Then
                    sMessage$ = sMessage$ + "Detected forum link." + Chr$(13)
                    parse$ = Mid$(oldURL$, InStr(oldURL$, "index"))
                    newURL$ = "https://qb64forum.alephc.xyz/" + parse$
                Else
                    sMessage$ = sMessage$ + "Detected forum link, no topic." + Chr$(13)
                    ' GOTO THE ROOT FORUMS URL
                    newURL$ = "https://qb64forum.alephc.xyz/index.php"
                End If
                iCount% = iCount% + 1
            ElseIf InStr(oldURL$, "/www.qb64.org/wiki") > 0 Then
                ' URL IS FROM WIKI...
                If InStr(oldURL$, "/www.qb64.org/wiki/") > 0 Then
                    sMessage$ = sMessage$ + "Detected wiki link." + Chr$(13)
                    iPos% = _InStrRev(oldURL$, "/wiki/")
                    If iPos% > 0 Then
                        parse$ = Right$(oldURL$, Len(oldURL$) - (iPos% + 5))
                    End If
                    newURL$ = "https://qb64phoenix.com/qb64wiki/index.php/" + parse$
                Else
                    sMessage$ = sMessage$ + "Detected wiki link, no topic." + Chr$(13)
                    ' GOTO THE ROOT WIKI URL
                    newURL$ = "https://qb64phoenix.com/qb64wiki/index.php"
                End If
                iCount% = iCount% + 1
            Else
                sMessage$ = sMessage$ + "Link not recognized." + Chr$(13)
                newURL$ = ""
            End If

            If Len(newURL$) > 0 Then
                sMessage$ = sMessage$ + "Converted, new URL is:" + Chr$(13) + newURL$ + Chr$(13)

                If sOpenBrowser$ = "g" Then
                    sMessage$ = sMessage$ + "Opening new link in Chrome." + Chr$(13)
                    Shell _DontWait "chrome " + newURL$
                ElseIf sOpenBrowser$ = "f" Then
                    sMessage$ = sMessage$ + "Opening new link in Firefox." + Chr$(13)
                    Shell _DontWait "firefox " + newURL$
                End If

                If bUpdateClipboard% = TRUE Then
                    sMessage$ = sMessage$ + "Copying new link to clipboard." + Chr$(13)
                    _Clipboard$ = newURL$
                End If
            End If
        Else
            sMessage$ = sMessage$ + "Clipboard is empty!" + Chr$(13)
        End If
    End If
Loop

'System
End
Reply


Messages In This Thread
RE: Redirect old-forum and wiki search results to Pheonix as appropriate. - by madscijr - 07-22-2022, 06:06 PM



Users browsing this thread: 5 Guest(s)