Join us on Discord!
You can help CodeWalrus stay online by donating here.

BBCode to Wiki Markup - Name [Ruby]

Started by Unicorn, July 19, 2016, 05:38:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Unicorn

I've found that we need a program to convert BBCode (The formatting that the forum uses) to Wiki Markup (The formatting that most of the community wikis use). It will make it easy to bring tutorials written on the forum into the wiki.

I will be using Ruby to write it, with Shoesfor a gui. It will not support images, tables, lists, fonts, and colors right away, if ever. It will definitely support code, bold, italics, underlines, and urls.

The one problem I have is figuring out how to distribute it. Using Ocra, the gem that lets you package your script into a .exe file doesn't quite work, and I'm unsure how I would be able to host it online.

Here's an example that uses all of the converted functions:

BBCtoWiki Example

Wassup! This is an example![/b]
Strike this text, it makes no sense!
And don't forget an image!

Lets indent this code, as well!
    codecodecode codecodecode codecodecode
    codecodecode codecodecode
    codecodecode
    codecodecode
    codecodecode codecodecode codecodecode

    ---------------------------------------------------------------------
    That was the post, here's the BBC:

    [size=24]BBCtoWiki Example[/size]

    [i]Wassup! [b]This is an example![/i][/b]
    [s]Strike this text, it makes no sense![/s]
    [size=12]And don't forget an image![/size]
    [img]https://codewalr.us/Themes/CodeWalrus/images/english/smflogo.png[/img]
    Lets indent this code, as well!
    [list][code]codecodecode codecodecode codecodecode
    codecodecode codecodecode
    codecodecode
    codecodecode
    codecodecode codecodecode codecodecode

    [/list][/code]
    -------------------------------------------------------------------
    And here is the Wiki Markup:

    == BBCtoWiki Example ======

    ''Wassup! ''''This is an example!'''''
    <strike>Strike this text, it makes no sense!</strike>
    ==== And don't forget an image! ======
    https://codewalr.us/Themes/CodeWalrus/images/english/smflogo.png
    Lets indent this code, as well!
    <blockquote><pre>codecodecode codecodecode codecodecode
    codecodecode codecodecode
    codecodecode
    codecodecode
    codecodecode codecodecode codecodecode
    </pre>
    </blockquote>

    ----------------------------------------------
    Go here to see an example of the Wiki Markup: https://www.cemetech.net/learn/Bbcodeconvertexample
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Dream of Omnimaga

    That would definitively be useful. I always wondered if such tool was available before, because I once wanted to convert a post to a TI-Story page and it was a major hassle.

    I can't help, but hopefully someone can. Just make sure before copying tutorials to ask the author's permission before uploading it elsewhere, though.
    • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
    • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

    Unicorn

    Yup, that it exactly why, to lessen the hassle. Anyways, anyone have an idea for a name?
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Dream of Omnimaga

    BBCode2wiki?

    Envoyé de mon Nexus 5 en utilisant Tapatalk

    • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
    • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

    Unicorn

    #4
    Oh yes, anyone have an idea for a name?

    So I've made alot of progress. I have something of a gui, and teh program supports converting Bold text, strikethroughs, italics, images, lists (they get turned into those lines "----"), and code.

    Here's the code:


    require 'shoes'
    Shoes.app(title: "BBCode to Wiki Markup", width: 1000, height: 750, resizable: true) do
      background white
      @BBC = edit_box top: 60, left: 35, width: 940, height: 250
      @Convert = button "Convert", top: 340, left: 450
      @Convert.click do
        bbcode = @BBC.text
            bbcode.gsub! "[b]", "''''"
            bbcode.gsub! "[/b]", "'''"
            bbcode.gsub! "[i]", "''"
            bbcode.gsub! "[/i]", "''"
            bbcode.gsub! "[scode]", "<code>"
            bbcode.gsub! "[s/code]", "</code>"
            bbcode.gsub! "[s]", "<strike>"
            bbcode.gsub! "[/s]", "</strike>"
            bbcode.gsub! "[img]", ""
            bbcode.gsub! "[/img]", ""
            bbcode.gsub! "[list]", "----"
            bbcode.gsub! "[/list]", ""
        edit_box "#{bbcode}", top:400, left: 35, width: 940, height: 250
      end
      @quitB = button "Quit", top: 700, left: 455
      @quitB.click {exit}
      end


    EDIT: I fixed it! I had to use gsub! instead of sub!.

    A video, converting Bold text: https://usercontent.irccloud-cdn.com/file/irXNiRHG/Screencast%202016-07-21%2017%3A10%3A23.mp4

    It can convert the entirety of this post: https://www.cemetech.net/forum/viewtopic.php?t=12725&highlight=
    Example: https://www.cemetech.net/learn/Bbcodeconvertexample

    I'm going to work on headers, and maybe change up the list tag a little.

    Download Below
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Unicorn

    #5
    So I've added text sizes and tweaked the code conversion, so check out the examples.

    See the OP for an example! https://codewalr.us/index.php?topic=1467.msg41898#msg41898

    Any more ideas for other tags? I could include smilies...

    Download Below
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Dream of Omnimaga

    #6
    By the way, does this support Wikidot syntax too? It would be a nice addition for cross-posting BASIC tricks or posts into TI-BD wiki or to post TI community doc in TI-Story, which are both hosted on Wikidot.

    Other than that, Does this need dependencies other than Shoes? Because when I run this, once Shoes is downloaded, it takes about 1 minute to load and it takes over 15% CPU (I have a quad-core) during that time.

    EDIT: It doesn't seem to convert much so far. Does it only support PhpBB syntax? I tried converting this post, btw https://codewalr.us/index.php?topic=28.0
    • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
    • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

    Unicorn

    So yeah, urls, aren't implemented yet, and colors don't work. I also need to implement underlining.

    It shouldn't take to long, I'm not sure, on linux its fast...
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Dream of Omnimaga

    I use Windows 7 64-bits. Maybe that's why?
    • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
    • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

    Unicorn

    Quote from: DJ Omnimaga on July 23, 2016, 12:21:37 AM
    I use Windows 7 64-bits. Maybe that's why?

    Does it open the window right away, but then freeze? It does that for me when on Windows 10. I guess I'll have to package it a different way.
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Unicorn

    #10
    OK, heres another thing to try, @DJ Omnimaga

    Use the same .exe, but shoes is already included in the application, you won't have to download it. You also might want to uninstall shoes before running it. And I made urls work :P

    http://www.mediafire.com/download/616o23g0c9hphsn/BBCtoWIKI.zip
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    aetios

    How about BBC2WM for a name. BBCode to Wiki Markup.
    ceci n'est pas une signature

    Dream of Omnimaga

    #12
    Quote from: Unicorn on July 23, 2016, 02:50:02 AM
    Quote from: DJ Omnimaga on July 23, 2016, 12:21:37 AM
    I use Windows 7 64-bits. Maybe that's why?

    Does it open the window right away, but then freeze? It does that for me when on Windows 10. I guess I'll have to package it a different way.
    YEs it opens a window right away. It just remains blank like if it had frozen for about a minute. I'll try your other download link now.

    EDIT: The new version seems to open much faster now.
    • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
    • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

    Unicorn

    Good, I'm glad that's fixed. Now, is there anything else I should do?
    • Calculators owned: I own all of them: PICKACHUP TI 84+ CSE TI 83+ SE TI something something ??? ??? ??? ??? ???
    • Consoles, mobile devices and vintage computers owned: PICKACHUP ??? ??? ??? ??? ???



    ??? ??? ??? ??? ???

    Dream of Omnimaga

    Maybe there could be options to choose the formating style, such as, for example, if the user wants underline-bold text to be converted to big text and bold text to medium text or if he prefers that they are converted to something else?
    • Calculators owned: TI-82 Advanced Edition Python TI-84+ TI-84+CSE TI-84+CE TI-84+CEP TI-86 TI-89T cfx-9940GT fx-7400G+ fx 1.0+ fx-9750G+ fx-9860G fx-CG10 HP 49g+ HP 39g+ HP 39gs (bricked) HP 39gII HP Prime G1 HP Prime G2 Sharp EL-9600C
    • Consoles, mobile devices and vintage computers owned: Huawei P30 Lite, Moto G 5G, Nintendo 64 (broken), Playstation, Wii U

    Powered by EzPortal