Alternatively, join us on Discord.

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

July 19, 2016, 05:38:29 pm Last Edit: July 22, 2016, 10:22:28 pm by 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



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

    DJ 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.

    Unicorn

    Yup, that it exactly why, to lessen the hassle. Anyways, anyone have an idea for a name?



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

    DJ Omnimaga

    BBCode2wiki?

    Envoyé de mon Nexus 5 en utilisant Tapatalk


    Unicorn

    July 22, 2016, 04:08:09 am #4 Last Edit: July 22, 2016, 08:04:58 pm by Unicorn
    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



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

    Unicorn

    July 22, 2016, 10:02:45 pm #5 Last Edit: July 22, 2016, 10:24:53 pm by Unicorn
    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



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

    DJ Omnimaga

    July 22, 2016, 10:59:34 pm #6 Last Edit: July 22, 2016, 11:02:26 pm by DJ Omnimaga
    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

    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...



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

    DJ Omnimaga

    I use Windows 7 64-bits. Maybe that's why?

    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.



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

    Unicorn

    July 23, 2016, 07:21:36 pm #10 Last Edit: July 23, 2016, 07:29:35 pm by Unicorn
    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



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

    aeTIos

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

    DJ Omnimaga

    July 24, 2016, 12:46:13 am #12 Last Edit: July 24, 2016, 12:49:44 am by DJ Omnimaga
    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.

    Unicorn

    Good, I'm glad that's fixed. Now, is there anything else I should do?



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

    DJ 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?

    Powered by EzPortal