Browse Source

tweaks to posting interface

pull/10/head
Aaron Parecki 7 years ago
parent
commit
f78a542017
4 changed files with 48 additions and 20 deletions
  1. +1
    -1
      controllers/auth.php
  2. +11
    -5
      controllers/controllers.php
  3. +3
    -3
      public/css/style.css
  4. +33
    -11
      views/new-post.php

+ 1
- 1
controllers/auth.php View File

@ -5,7 +5,7 @@ function buildRedirectURI() {
}
function clientID() {
return Config::$base_url;
return trim(Config::$base_url, '/'); // remove trailing slash from client_id
}
function build_url($parsed_url) {

+ 11
- 5
controllers/controllers.php View File

@ -146,10 +146,13 @@ $app->post('/post', function() use($app) {
if(k($params, 'drank')) {
$entry->content = $params['drank'];
} elseif(k($params, 'custom_caffeine')) {
$entry->content = $params['custom_caffeine'];
} elseif(k($params, 'custom_alcohol')) {
$entry->content = $params['custom_alcohol'];
$type = 'drink';
} elseif(k($params, 'custom_drank')) {
$entry->content = $params['custom_drank'];
$type = 'drink';
} elseif(k($params, 'custom_ate')) {
$entry->content = $params['custom_ate'];
$type = 'eat';
}
$entry->save();
@ -159,7 +162,8 @@ $app->post('/post', function() use($app) {
if($user->micropub_endpoint) {
$mp_request = array(
'h' => 'entry',
'content' => $entry->content,
'p3k-food' => $entry->content,
'p3k-type' => $type,
'location' => k($params, 'location')
);
@ -175,6 +179,8 @@ $app->post('/post', function() use($app) {
$user->micropub_success = 1;
$entry->micropub_success = 1;
$entry->canonical_url = $url;
} else {
$entry->micropub_success = 0;
}
$entry->save();

+ 3
- 3
public/css/style.css View File

@ -190,16 +190,16 @@ body {
}
.caffeine, .alcohol {
.entry-buttons {
margin-bottom: 10px;
list-style-type: none;
padding-left: 0;
max-width: 240px;
}
.caffeine li, .alcohol li {
.entry-buttons li {
margin-bottom: 6px;
}
.caffeine li input, .alcohol li input {
.entry-buttons li input {
width: 100%;
}

+ 33
- 11
views/new-post.php View File

@ -4,33 +4,42 @@
<form role="form" style="margin-top: 20px;" id="note_form" action="/post" method="post">
<h3>Caffeine</h3>
<ul class="caffeine">
<ul class="caffeine entry-buttons">
<?php foreach(caffeine_options() as $val): ?>
<li><input type="submit" name="drank" class="btn btn-default" value="<?= $val ?>"></li>
<?php endforeach; ?>
<li>
<input type="text" class="form-control" name="custom_caffeine" placeholder="Custom" style="width: 72%; float: left; margin-right: 2px;">
<input type="submit" class="btn btn-default" value="Post" style="width: 26%; float: right;">
</li>
</ul>
<br>
<h3>Alcohol</h3>
<ul class="alcohol">
<ul class="alcohol entry-buttons">
<?php foreach(alcohol_options() as $val): ?>
<li><input type="submit" name="drank" class="btn btn-default" value="<?= $val ?>"></li>
<?php endforeach; ?>
</ul>
<br>
<h3>Drank</h3>
<ul class="other entry-buttons">
<li>
<input type="text" class="form-control text-custom-drank" name="custom_drank" placeholder="Custom" style="width: 72%; float: left; margin-right: 2px;">
<input type="submit" class="btn btn-default btn-custom-drank" value="Post" style="width: 26%; float: right;">
</li>
</ul>
<br><br>
<h3>Ate</h3>
<ul class="other entry-buttons">
<li>
<input type="text" class="form-control" name="custom_alcohol" placeholder="Custom" style="width: 72%; float: left; margin-right: 2px;">
<input type="submit" class="btn btn-default" value="Post" style="width: 26%; float: right;">
<input type="text" class="form-control text-custom-ate" name="custom_ate" placeholder="Custom" style="width: 72%; float: left; margin-right: 2px;">
<input type="submit" class="btn btn-default btn-custom-ate" value="Post" style="width: 26%; float: right;">
</li>
</ul>
<br><br>
<div class="form-group">
<label for="note_location">Location</label>
<input type="checkbox" id="note_location_chk" value="">
<img src="/images/spinner.gif" id="note_location_loading" style="display: none;">
<h3>Location <input type="checkbox" id="note_location_chk" value=""><img src="/images/spinner.gif" id="note_location_loading" style="display: none;"></h3>
<input type="text" id="note_location_msg" value="" class="form-control" placeholder="" readonly="readonly">
<input type="hidden" id="note_location" name="location">
@ -75,6 +84,19 @@
<script>
$(function(){
$(".text-custom-ate").keydown(function(e){
if(e.keyCode == 13) {
$(".btn-custom-ate").click();
return false;
}
});
$(".text-custom-drank").keydown(function(e){
if(e.keyCode == 13) {
$(".btn-custom-drank").click();
return false;
}
});
function location_error(msg) {
$("#note_location_msg").val(msg);
$("#note_location_chk").removeAttr("checked");

Loading…
Cancel
Save