Kirby Version Widget

Hey there! Initial offering of my first plugin.

Kirby Version Widget

Kirby dashboard widget displaying installed and latest version with link to changelog. Inspired (largely) by kirby version by Fabian Sperrle.

Built for my own use, free for anyone to use.

Screenshot

Installation

Copy the site folder in this repo to your site folder.

Roadmap

  • add logic to show widget only to certain users
  • make widget multi-lingual
  • Display only when update available?
2 Likes

Nice, you can display update when available with file_get_contents.
So the logic is you request file on specified url (for example http://pastebin.com/random and you request same file on http://localhost/version.txt (if it is same if not display error)
However i’m not sure does Kirby support that logic.
Simple function:

define('REMOTE_VERSION', 'http://pastebin.com/raw.php?i=dXn4ij0j'); // random file
define('VERSION', '1.0'); // file content you request
function update() {
// Update script
$script = file_get_contents(REMOTE_VERSION);
$version = VERSION;
if($version == $script) {
echo "You have the latest version!";
} else {
echo "There is update available!";
}};

Hey ! I’m not sure I understand where you get the version number contained in the pastebin file ?

If you want to let the user know there’s an update, you can change the file here https://github.com/Thiousi/kirby-version-widget/blob/master/site/widgets/version/template.php
to include an if statement that checks if $latest is different from $kirby (installed).

Does that make sense?

ah sorry sometimes even i can’t explaim what i’m thinking,
Well pastebin file is random( i used it for some script longtime ago), so you can use any file, i’m not sure how you display last and installed version.
So, imarge you have remote text file on kirby server (remote.txt) that file contans just number of kirby latest version 2.3.1 nothing else.
So you have local instalation of kirby that displays you version 2.3.0(another file), now when you code is like if both files are same you get “You have latest version.” if they are not,
you get "There is update available. I’m gona provide you screenshot cause i’m still not sure do you understand me :-D.
Remember remote.txt is remote file stored on kirby server, you are just reading it to compare with local file, or varible.

Right I understand what you mean now thanks for the clarification :slight_smile:

I actually check the rss feed of the official changelog to know which is the latest version !
The current version is given by an easy to use Kirby function.
All the logic (the whole 3 lines of it) are in the github repository:

$kirby = kirby(); // Gives the current version
	$rss = simplexml_load_file('http://getkirby.com/changelog/feed'); // Read the rss feed
	$data = array(
		'kirby' => $kirby::$version,
		'latest' => $rss->channel->item[0]->title, // Check the version number of the latest entry in the Kirby changelog
		'link' => $rss->channel->item[0]->link, // Get the link to the latest entry in the Kirby changelog
	); 

So to implement the logic in your code, you can reuse the code here and compare “kirby” and “latest” as defined in the widget. I’ll probably get to it myself one day… soon !

The used version number is also stored in the local version of Kirby.

You can query that one, and compare it against the one on Github, or so?

With Simple DOM (PHP) you can read / manipulate those values…

I’ve made a lot of apps (mobile) with this technique (scraping content and doing “something” with it…).

I’m getting the Kirby version exactly the way you’re pointing out with kirby::$version
:wink:

And I just added the explanations to the code on github:
https://github.com/Thiousi/kirby-version-widget/blob/master/site/widgets/version/version.php

1 Like

Alright,
I kind of had to update this plugin here so here comes Kirby Version Widget V… (and that’s when I realized my version widget doesn’t have a version number :head_bandage:)

The New Kirby Version Widget

Now featuring a different message if an update is available !

2 Likes

Something really cool happened over the past couple days as I was trying to cache the latest version of Kirby and found out I needed to do this with a custom caching mechanism!

I’ve pushed the widget to version 2.0 since the code has been rewritten quite a lot. Installation and instructions are all on Github.

I’ll be pushing this caching mechanism in a separate repo if any plugin dev needs to use it. It was a lot of fun developing it and I want to thank @lukasbestle who helped a lot towards the end and made sure my code wouldn’t send a nuke head to the white house! Thanks Lukas :slight_smile:

3 Likes