Giter VIP home page Giter VIP logo

kirby3-micropublisher's People

Contributors

fabianmichael avatar sebastiangreger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

u3kjkxr8es antons

kirby3-micropublisher's Issues

Sending a request to endpoint causes error, if access_token is not set

The plugin currently does not check, if the key access_token, causing the script to to thro an error instead of warning about missing/empty token:

Whoops\Exception\ErrorException: Undefined index: access_token in file site/plugins/kirby3-micropublisher/classes/Micropublisher.php on line 22

Properly process files uploaded as multipart form data

Hey,

I am trying around to use different templates for a simple note or an image post. I tried different variations but couldn't get it working with

'identify' => [
                'unique' => null,
                'has' => ['photo', 'files.photo', 'files[photo]'],
                'hasnot' => null,
            ],

(I always used on of the strings in 'has' not all together)

Is it possible to identify posts by existing files?

I also tried to write a file to a field:

            'files' => [
                'photo' => ['image', true, 'hero'],
            ],

The image is uploaded, the note created, but there is no hero in the markdown. I am using micropub.rocks for testing.

"Invalid Requests" from Quill/IA Writer to Kirby

So, I'm relatively new to PHP, but fluent enough to have a Kirby 3 site that I'm testing with this (wonderful) plugin. I used Quill and IA Writer to test how it works. The plugin ultimately works in converting the title and text to a file in Kirby, but it's failing to convert the slugs and tag, and sending odd errors within Quill and IA Writer as well.

Kirby Config

Here's my Kirby config first, in case there's something obviously wrong. It's mostly taken from the example above, and with no post types configured.

    'sgkirby.micropublisher.jwtkey' => '##################,
    'sgkirby.micropublisher.default.template' => 'note',
    'sgkirby.micropublisher.default.parent' => 'notes',
    'sgkirby.micropublisher.default.status' => 'listed',
    'sgkirby.micropublisher.default.slug' => 'default-slug',
    'sgkirby.micropublisher.default.render' => [
        'name'		=> [ 'title', 'No title' ],
        'content'	=> [ 'text', '' ],
        'category'	=> [ 'tags', null ],
        'published'	=> [ 'date', strftime( '%F %T' ), 'datetime' ],
    ],

Case 1: Quill to Kirby

I tested Quill with Micropub, and know it works. Here's a picture of my entry via skill, and here's the raw request returned by MicropubRocks from when I sent it.

POST https://micropub.rocks/client/Et7Ddf1nrzPUGhaO/micropub HTTP/1.1
Content-Type: application/x-www-form-urlencoded
Content-Length: 230
Accept: application/json
Authorization: Bearer abxTTE1jD6bNhfVlZtYgfipb7zcidcsXK4NKGN6fEUcgeRRAY875uSKb3OayIYZ7yV0q6dmn7JrI0EMaKXHcydR4Ydje87aY352AcfOrS5utRfbP9FD0rIM7YxuiURLl
Host: micropub.rocks

h=entry&
access_token=abxTTE1jD6bNhfVlZtYgfipb7zcidcsXK4NKGN6fEUcgeRRAY875uSKb3OayIYZ7yV0q6dmn7JrI0EMaKXHcydR4Ydje87aY352AcfOrS5utRfbP9FD0rIM7YxuiURLl&
content=%23+Hello+World%0A%0AGoodbye+World&
category%5B%5D=test&
mp-slug=test-send`

When I try to send this same thing to Kirby, however, I'm informed that "Something went wrong! Your Micropub endpoint indicated that something went wrong creating the post." The specific data that came back was this:

HTTP/1.1 500 Internal Server Error
Date: Fri, 18 Sep 2020 20:38:50 GMT
Server: Apache
Upgrade: h2,h2c
Connection: Upgrade, close
Vary: Accept-Encoding
Transfer-Encoding: chunked
Content-Type: application/json; charset=UTF-8

{"status":"error","exception":"Kirby\\Exception\\PermissionException","code":"error.page.changeStatus.permission","message":"The status for this page cannot be changed","details":[],"file":"kirby\/src\/Cms\/PageRules.php","line":129}

What's interesting, a file was created in Kirby. In /content/1_notes/1600461530, a note.txt file was created, as follows:

Title: No title

----

Text:

# Hello World

Goodbye World

----

Tags: 

So it worked, but didn't work.

Case 2: IA Writer to Kirby

I also tried putting a similar file into both Micropub Rocks and Kirby via IA Writer.

CleanShot 2020-09-18 at 14 49 48@2x

I tried publishing to Micropub. I received this error message, making it seem like something had gone wrong.

CleanShot 2020-09-18 at 14 49 18@2x

And indeed, Micropub immediately informed me that IA Writer is doing something wonky. "The request was not a form-encoded request. Ensure you are sending a proper form-encoded request with valid parameters." The raw request reads as follows:

POST https://micropub.rocks/client/V8ZkRvdK2v7erCW8/micropub HTTP/2.0
Authorization: Bearer eFAJ0xOUisikkhGb2P8Gl0SYG769phew1Yy47umoOWiVK4GPFS1Gqt3ajUhs7plDkla9LlgtgYXI8Nq69ZwyHzoRKscXvrFZiFflzKCqMEfUUExLrxUy7bMiQUwgYD9y
Accept-Language: en-us
User-Agent: iA%20Writer/56102 CFNetwork/1128.0.1 Darwin/19.6.0 (x86_64)
Accept-Encoding: gzip, deflate, br
Content-Length: 201
Accept-Charset: utf-8
Content-Type: application/json
Accept: application/json
Host: micropub.rocks

{"type":["h-entry"],"properties":{"name":["Hello World"],"content":[{"html":"<h1>Hello World<\/h1>\n\n<p>Goodbye World<\/p>\n\n<p><span class=\"hashtag\">#test<\/span><\/p>"}],"post-status":["draft"]}}

Undeterred, I tried to publish to Kirby. And though I received the same "Your request was invalid" error message in IA Writer, it seemed to (partially) work in Kirby. A file was created with the slug 1_notes/1600462155. The `note.txt file rendered as follows:

Title: Hello World

----

Text:

# Hello World

Goodbye World

<span class="hashtag">#test</span>

----

Tags: 

Questions

A few issues here, with the caveat that I'm relatively new to this, so please be kind if I've made some rookie mistakes or overlooked things.

  1. Quill worked great with Micropub Rocks, but gave an error with Kirby. Yet, it also kind of worked–minus the slugs and tags (both of which were specified). What happened?
  2. IA Writer gave an error with Micropub Rocks, and with Kirby, yet it too (kind of) worked–again, minus the slug (which should have been the default, I think?) and the tags (which were not specified).
  3. Why does the slug not convert properly from either Quill or IA Writer? With Quill, I think it should have been 1_notes/test-send (since that's what I put into the Quill). Instead, it came out as1_notes/1600461530.
  4. Why do the tags not convert properly from Quill? It was specified in the Quill bank, but didn't make it over in either instance. I have a vague suspicion I don't have the config.php set up properly here, and perhaps should change the [ 'tags', null ], to something like [ 'tags', 'category' ]?

Also, I should add that while I didn't expect the tags to convert from IA Writer, it would be cool if there was a way to recognize the hashtags within the text itself and shift them from the text block to the tags block. Some kind of setting that says, "expect hashtags in the block and convert/move them appropriately."

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.