diff --git a/controllers/controllers.php b/controllers/controllers.php index 119fea6..4d721e2 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -80,12 +80,20 @@ $app->get('/new', function() use($app) { 'tz_offset' => $tz_offset, 'date_str' => $date_str, 'time_str' => $time_str, - 'enable_appcache' => true + 'enable_array_micropub' => $user->enable_array_micropub )); $app->response()->body($html); } }); +$app->post('/prefs/enable-h-food', function() use($app){ + if($user=require_login($app)) { + $user->enable_array_micropub = 1; + $user->save(); + } + $app->redirect('/new', 302); +}); + $app->post('/prefs', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); @@ -136,7 +144,7 @@ $app->get('/add-to-home', function() use($app) { if($user=require_login($app)) { if(array_key_exists('start', $params)) { $_SESSION['add-to-home-started'] = true; - + $token = JWT::encode(array( 'user_id' => $_SESSION['user_id'], 'me' => $_SESSION['me'], @@ -189,7 +197,7 @@ $app->post('/post', function() use($app) { $now = new DateTime(); $now->setTimeZone(new DateTimeZone($entry->timezone)); $published = $now->format('c'); - } + } } @@ -228,11 +236,21 @@ $app->post('/post', function() use($app) { $mp_request = array( 'h' => 'entry', 'published' => $published, - 'p3k-food' => $entry->content, - 'p3k-type' => $type, + 'created' => $published, 'location' => k($params, 'location'), 'summary' => $text_content ); + if($user->enable_array_micropub) { + $mp_request[$verb] = [ + 'type' => 'h-food', + 'properties' => [ + 'name' => $entry->content + ] + ]; + } else { + $mp_request['p3k-food'] = $entry->content; + $mp_request['p3k-type'] = $type; + } $r = micropub_post($user->micropub_endpoint, $mp_request, $user->access_token); $request = $r['request']; @@ -289,12 +307,14 @@ $app->get('/map.png', function() use($app) { $app->response()->body($img); }); +/* $app->get('/teacup.appcache', function() use($app) { $content = partial('appcache'); $app->response()['Content-type'] = 'text/cache-manifest'; $app->response()->body($content); }); +*/ $app->get('/:domain', function($domain) use($app) { $params = $app->request()->params(); @@ -372,5 +392,3 @@ $app->get('/:domain/:entry', function($domain, $entry_id) use($app) { 'domain' => '[a-zA-Z0-9\.-]+\.[a-z]+', 'entry' => '\d+' )); - - diff --git a/views/appcache.php b/views/appcache.php index 4bcbc5d..d3979b1 100644 --- a/views/appcache.php +++ b/views/appcache.php @@ -1,5 +1,4 @@ CACHE MANIFEST -/new /bootstrap/css/bootstrap.min.css /bootstrap/css/bootstrap-theme.css /bootstrap/css/bootstrap-theme.css.map @@ -12,4 +11,4 @@ CACHE MANIFEST NETWORK: * -# v29 +# v31 diff --git a/views/new-post.php b/views/new-post.php index d682e94..e58f642 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -5,7 +5,7 @@

Date

- + @@ -26,7 +26,7 @@
- + micropub_endpoint): ?> @@ -51,6 +51,19 @@ access token String of length access_token) ?>access_token) > 0) ? (', ending in ' . substr($this->access_token, -7) . '') : '' ?> (should be greater than length 0) + enable_array_micropub): ?> + + ate or drank + +

The parameter named ate or drank will include an h-food object corresponding to the item you tapped.

+
ate[type]=h-food&ate[properties][name]=Coffee
+ + + + + h-food +
+ p3k-food The button you tap (or your custom text) will be sent to your Micropub endpoint in a field named p3k-food @@ -59,6 +72,7 @@ p3k-type Will be either drink or eat depending on the type of entry + @@ -133,14 +147,14 @@ $(function(){ } else if(err.code == 3) { location_error("Timed out getting location"); } - + // Load the entry buttons with no location context load_entry_buttons(); }); } function set_location_enabled(enabled) { - localforage.setItem('location-enabled', {enabled: enabled}); + localforage.setItem('location-enabled', {enabled: enabled}); } function get_location_enabled(callback) { localforage.getItem('location-enabled', function(err,val){ @@ -176,7 +190,7 @@ $(function(){ } }); - // This loads the buttons with or without location + // This loads the buttons with or without location function load_entry_buttons(coords) { var latitude = coords ? coords.latitude : ''; var longitude = coords ? coords.longitude : ''; @@ -216,13 +230,13 @@ $(function(){ function onUpdateReady() { // Show the notice that says there is a new version of the app - $("#new_version_available").show(); + $("#new_version_available").show(); } window.applicationCache.addEventListener('updateready', onUpdateReady); if(window.applicationCache.status === window.applicationCache.UPDATEREADY) { onUpdateReady(); - } + } });