sebastiangreger / kirby3-micropublisher Goto Github PK
View Code? Open in Web Editor NEWAn adaptable Micropub endpoint for Kirby3.
License: MIT License
An adaptable Micropub endpoint for Kirby3.
License: MIT License
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
Inspired by http://brendandawes.com/blog/emailtokirby - extending the Micropublisher plugin with "publish via email" would be a nice addition.
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.
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.
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' ],
],
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.
I also tried putting a similar file into both Micropub Rocks and Kirby via IA Writer.
I tried publishing to Micropub. I received this error message, making it seem like something had gone wrong.
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:
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_notes/test-send
(since that's what I put into the Quill). Instead, it came out as1_notes/1600461530
.[ '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."
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.