omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    A "Post to Forums" workflow for Editorial/Pythonista?

    Editorial
    4
    11
    6147
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RainmanNoodles
      RainmanNoodles last edited by

      I agree, this would be a really nice thing to have. There are two ways I came up with that might work.

      First, there's the easy way, which is launching the forums in Safari. You could ideally just encode the title/text into the URL, and you could even have a popup to choose the option in the General/Share Code/Questions menu. The problem is that the forum page doesn't support this. I'm not sure what software is used, or if it's custom. Some forms allow you to do this, though. In fact, you can already choose the popup option here. Try for example https://omz-forums.appspot.com/pythonista/new?category=Questions and you'll see that option already is selected. I tried to replicate it but I'm not sure which conditions dictate when this can and can't be done. The benefit to this option would be that you'd be using the official site and you'd be authenticated in Safari. (Bonus points for passing those parameters through the login page if you're not already logged in)

      The second way is basically to build a custom client. This would be the most seamless way to do it, and it could post without ever leaving Pythonista or Editorial. The disadvantage is that you'd be posting blind, i.e. you wouldn't be able to see the website's preview and you'd have to ensure your Markdown was perfect before posting. That's a good reason to do the website redirect. If there was an official API for the forum it would be easier. But it might also open things up to spam if you had the ability to easily automate posts like that.

      A third way would be copying the text to the clipboard and just opening the new post URL - it does require pasting it in but it's almost as good as the other options.

      Maybe we could get the URL parameter parsing added to the post pages so we could send the title and contents.

      1 Reply Last reply Reply Quote 0
      • TutorialDoctor
        TutorialDoctor last edited by

        That example will suffice for now. I can just do a quick copy to clipboard. I wonder if a little javascriot can find the posting area and the submit button?

        Thanks.

        1 Reply Last reply Reply Quote 0
        • RainmanNoodles
          RainmanNoodles last edited by

          The problem with using JavaScript is that using Safari you can't control anything after the URL is passed to it. It would be possible to use a Safari extension to directly access the DOM, but it would require a separate app, and the Workflow app can only do Action extensions.

          You could also open it in the app's built-in browser, but you'd have to authenticate separately. I prefer to keep authentications within Safari whenever possible.

          1 Reply Last reply Reply Quote 0
          • RainmanNoodles
            RainmanNoodles last edited by

            Okay, I've figured it out, for now at least. And it doesn't need the clipboard! First, download this Editorial workflow. The workflow sends the content to the forum page; make sure you're logged into the forums in Safari. Now, you need the JavaScript bookmarklet. Create any bookmark and then edit it. Copy and paste the following code into the bookmark's URL field:

            javascript:var urls = window.location.href.split('?'); if (urls.length > 1) { var params = urls[1].split('&'); for (x=0; x<params.length; x++) {var p = params[x].split('='); if (p.length == 2) {if (p[0] == 'omztitle') {var title=decodeURIComponent(p[1]); var titlebox=document.getElementsByName('title')[0]; titlebox.value=title;} else if (p[0] == 'omzcontent') {var content=decodeURIComponent(p[1]); var contentbox = document.getElementById('wmd-input'); contentbox.value=content}}}}
            

            (Make sure to get the entire line - it's a long one.) You can also drag <a href="javascript:var urls = window.location.href.split('?'); if (urls.length > 1) { var params = urls[1].split('&'); for (x=0; x<params.length; x++) {var p = params[x].split('='); if (p.length == 2) {if (p[0] == 'omztitle') {var title=decodeURIComponent(p[1]); var titlebox=document.getElementsByName('title')[0]; titlebox.value=title;} else if (p[0] == 'omzcontent') {var content=decodeURIComponent(p[1]); var contentbox = document.getElementById('wmd-input'); contentbox.value=content}}}}">THIS LINK</a> to your Bookmarks from the desktop version of Safari and sync it over - it's easier.

            Then, to post, just name your file with the desired title and type out your post. Trigger the workflow and wait for the page to load. Then, run the bookmark and you should see your content filled out.

            If we can get that JavaScript added to the forum website, the workflow will work without the bookmarklet. ;)

            1 Reply Last reply Reply Quote 0
            • TutorialDoctor
              TutorialDoctor last edited by

              Thanks Rainman! I might be able to use this with the new Workflow app also.

              1 Reply Last reply Reply Quote 0
              • ClareMacrae
                ClareMacrae last edited by

                I've been experimenting with the 'Evaluate JavaScript' action, and it works well in the built-in browser.

                If you were happy to use the built-in browser to do your post, you could:

                • Change the 'Open URL' step in the workflow, to use 'In-App Browser'
                • Make sure that the same 'Open URL' step has 'Wait until Loaded' turned on
                • Add a new 'Evaluate JavaScript' action, and paste in the JavaScript from RainmanNoodles' earlier post

                And I believe this would give you a single step, with no need to set up the JS bookmarklet in Safari.

                1 Reply Last reply Reply Quote 0
                • ClareMacrae
                  ClareMacrae last edited by

                  I've now published a modification to Rainman's workflow as Send to OMZ Forums in Built-in Browser, having confirmed that adding the JavaScript action to the workflow works fine in the built-in browser - with no need to set up a separate bookmarklet.

                  1 Reply Last reply Reply Quote 0
                  • TutorialDoctor
                    TutorialDoctor last edited by

                    Thanks Clare and Rainman! Clare, your version is what I was looking for.

                    1 Reply Last reply Reply Quote 0
                    • zrzka
                      zrzka last edited by

                      I just wrote this workflow to start discussion in Pythonista / Editorial forums.

                      1 Reply Last reply Reply Quote 0
                      • TutorialDoctor
                        TutorialDoctor last edited by

                        I will check it out. Thanks!

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post
                        Powered by NodeBB Forums | Contributors