Month: June 2015

Update Second Crack from filethingie

This blog post describes how to set up a filethingie installation and create a plugin to update your posts. It assumes that you already have a shell script in place to start the update of your blog.

Disclaimer: you are yourself responsible for securing the access to filethingie and the command to update secondcrack.
For the first step simply point the filethingie basepath to the second crack basepath. I use:

/srv/http/webapps/siteroot
- cache
- drafts
- htdocs
    filethingie
- media
- pages
- posts
- secondcrack
- templates
update.sh

In the filethingie config.php I have set the basepath to:

$ft["settings"]["DIR"]               = "../.."; // Your default directory.  Do NOT include a trailing slash!

From there I can manage all the folders and upload new files.

Files to create/update to update Second Crack

plugins/secondcrack.plugin.php

When in the filethingie root, create plugins/secondcrack.plugin.php

<?php
function ft_secondcrack_info() {
    return array(
        'name' => 'Secondcrack pugin',
        'settings' => array(
            'updatecommand' => array('description' => 'The command to update the blog', 'default' => '')
        )
    );
}

function ft_secondcrack_page($act) {
    global $ft;
    if ($act === 'secondcrack') {
        set_time_limit(0);
        $command = $ft['plugins']['secondcrack']['settings']['updatecommand'];
        $result = shell_exec($command);
        return 'Command run! Output: <i>' . htmlentities($result) . '</i>';
    }
}

function ft_secondcrack_secondary_menu() {
    return '<a href="' . ft_get_self() . '?act=secondcrack">Update Secondcrack</a>';
}

config.php

$ft['plugins']['secondcrack'] = array(
'settings' => array('updatecommand' => '[the updatecomand]')
);

Replace [the updatecommand] with the command you use to update secondcrack. I have created a small update.sh shell script that I placed in the root of the folder.

update.sh

#!/bin/sh

cd /srv/http/webapps/siteroot
/usr/bin/php ./secondcrack/engine/update.php >> /var/log/secondcrack.log 2>&1

echo "CLI: Executed update command for secondcrack."

This script assumes that there is a folder called secondcrack in the siteroot where the engine can be invoked.

Leave a Comment

Amazon SNS custom platform specific payloads for apns

The SNS documentation explains that you can specify custom payloads per platform, by specifying the platform now. The APNS sandbox and production APNS require different keys.

APNS and APNS_SANDBOX are separate platforms when specifying the payloads. Additional pitfall was that I was specifying the default message, which is automatically converted into {aps: alert: “message” }}, so messages were coming in at the iOS client, but not the ones I was expecting.

Also, the payload for each application must be json, but properly escaped.

##Example payload from the documentation

{
    "default": "This is the default message which must be present when publishing a message to a topic. The default message will only be used if a message is not present for one of the notification platforms.",
    "APNS": "{\"aps\":{\"alert\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\"} }",
    "GCM": "{\"data\":{\"message\":\"Check out these awesome deals!\",\"url\":\"www.amazon.com\"}}",
    "ADM": "{ \"data\": { \"message\": \"Check out these awesome deals!\",\"url\":\"www.amazon.com\" }}"
}

When using APNS in sandbox mode you need to specify APNS_SANDBOX instead of APNS, this is not clear from the documentation as you can see in the example.

The list of Applications in the Console will also make this more clear, see the screenshot below:

Leave a Comment