Various improvements and additions.

This commit is contained in:
Markus Birth 2016-05-20 23:34:50 +02:00
parent a583351ac4
commit 944ad8ff37
9 changed files with 240 additions and 229 deletions

View File

@ -3,4 +3,4 @@
</Files>
RewriteEngine on
RewriteRule ^([^.]+)/?$ index.php?action=$1 [L,NC]
RewriteRule ^([^./]+)/?$ index.php?action=$1 [L,NC]

View File

@ -66,6 +66,24 @@
}
.mdl-layout a {
color: inherit !important;
text-decoration: inherit !important;
}
color: inherit !important;
text-decoration: inherit !important;
}
.mdl-list__item-avatar {
background-color: transparent !important;
color: rgb(117, 117, 117) !important;
}
.frs-selector li {
transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1);
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.frs-selector li:hover {
background-color: rgb(238, 238, 238);
cursor: pointer;
}

View File

@ -39,22 +39,70 @@ if (isset($_GET['code']) && $_GET['code']) {
exit(0);
}
if (isset($_SESSION['access_token']) && $_SESSION['access_token']) {
$tpl_done = false;
// route pages that work with and without login
if (isset($_GET['action'])) {
switch ($_GET['action']) {
case 'faq':
$tpl = $m->loadTemplate('faq_html');
$tpl_done = true;
break;
}
}
if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token']) {
// Authenticated
$client->setAccessToken($_SESSION['access_token']);
try {
$created = $_SESSION['access_token']['created'];
$expires = $_SESSION['access_token']['expires_in'];
$expire_stamp = intval($created) + intval($expires);
$data['session_created'] = $created;
$data['session_expires'] = $expires;
$data['session_time_left'] = ($expire_stamp) - time();
$client->setAccessToken($_SESSION['access_token']);
} catch (Exception $e) {
print_r($e);
$_SESSION['access_token'] = $client->refreshToken(null);
print_r($_SESSION['access_token']);
}
$data['auth_needed'] = false;
$oauth = new Google_Service_Oauth2($client);
$userdata = $oauth->userinfo->get();
$data['user']['name_first'] = $userdata->givenName;
$data['userdata'] = print_r($userdata, true);
try {
$oauth = new Google_Service_Oauth2($client);
$userdata = $oauth->userinfo->get();
} catch (Exception $e) {
print_r($e);
die();
}
$data['user'] = array(
'name_first' => $userdata->givenName,
'name_last' => $userdata->familyName,
'name' => $userdata->name,
'picture' => $userdata->picture,
'email' => $userdata->email,
'gender' => $userdata->gender,
);
// Check $userdata->verifiedEmail and deny if not verified.
if (!$userdata->verifiedEmail) {
$tpl = $m->loadTemplate('notverified_html');
$tpl_done = true;
}
// TODO: Check $userdata->verifiedEmail and deny if not verified.
$tpl = $m->loadTemplate('loggedin_html');
} else {
switch ($_GET['action']) {
case 'faq':
$tpl = $m->loadTemplate('faq_html');
break;
default:
if (!$tpl_done) {
$tpl = $m->loadTemplate('loggedin_html');
$tpl_done = true;
}
break;
}
} elseif (!$tpl_done) {
// Not authenticated
$data['auth_needed'] = true;
$data['auth_url'] = $client->createAuthUrl();

View File

@ -0,0 +1,21 @@
{{> html_head}}
{{> mdl_head}}
{{> mdl_content_head}}
<div class="frs-crumbs mdl-color-text--grey-500">
<a href="./">Fake Reservation System</a> &gt; FAQ
</div>
<h3>Frequently Asked Questions</h3>
<h4>What happens to my data?</h4>
<p>
Your data won't be stored on our servers. It is solely used to compose the mail.
After the mail is sent, your data is deleted from our servers.
</p>
{{> mdl_content_foot}}
{{> mdl_foot}}
{{> html_foot}}

View File

@ -3,215 +3,54 @@
{{> mdl_content_head}}
<div class="frs-crumbs mdl-color-text--grey-500">
Not Google &gt; Not Google Now &gt; Fake Reservation System
<a href="./">Fake Reservation System</a> &gt; Welcome
</div>
<h3>What is this?</h3>
{{# auth_needed}}
<p>
Some time ago, Google introduced features to highlight special items from your
mails, like hotel reservations, event tickets, car rentals and more.
</p>
<p>
Later, they added features to Google Now on Android smartphones so that you
get notified when to leave to catch your flight or event … or how to get to
your booked hotel and when the checkin opens.
</p>
<p>
And recently, they even added a feature to Google Search, that shows your
booked items when you search for similar things. All that from a mail in your
inbox.
</p>
<p>
A nice overview with sample images can be found on Google's Developer pages:<br/>
<a href="https://developers.google.com/gmail/markup/">https://developers.google.com/gmail/markup/</a>.
</p>
<p>
But while the needed data is easy to be added to confirmation mails, many
companies didn't do this yet. And sometimes, you don't even get any confirmation
by email. To make those things show up in Google Now, I made this tool.
</p>
<h3>What does it do?</h3>
<p>
After login with your Google account, you can select a type of reservation,
fill in all your details and send it to the mail address of your account.
We will add all the neccessary markup to the mail so that Google Now can
recognise it. This will make the events/reservations show up when you need
them.
</p>
<p>
To begin, please sign in:<br/>
<a href="{{auth_url}}"><img id="signin-button" src="img/btn_google_signin_dark_normal_web.png"/></a>
</p>
{{/ auth_needed}}
{{# userdata}}
<p>
<pre>{{userdata}}</pre>
</p>
{{/ userdata}}
<p>
Hello, world! ({{action}})
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
<p>
Hello, world!
</p>
{{> mdl_content_foot}}
{{> mdl_foot}}

View File

@ -3,19 +3,62 @@
{{> mdl_content_head}}
<div class="frs-crumbs mdl-color-text--grey-500">
Not Google &gt; Not Google Now &gt; Fake Reservation System
<a href="./">Fake Reservation System</a> &gt; Logged in
</div>
<h3>What is this?</h3>
{{# userdata}}
<p>
<pre>{{userdata}}</pre>
</p>
{{/ userdata}}
<h3>Select the type of reservation you want to create</h3>
<p>
Welcome, to the <strong>Fake Reservation System</strong>. Where you can book travels you'll never attend.
<ul class="frs-selector mdl-list">
<li class="mdl-list__item mdl-list__item--three-line" onclick="location.href='./event';">
<span class="mdl-list__item-primary-content">
<i class="material-icons mdl-list__item-avatar">event</i>
<span>Generic Event</span>
<span class="mdl-list__item-text-body">
Use this type to declare a reservation for one or more guests at an event.
Tickets may be declared as well.
</span>
</span>
</li>
<li class="mdl-list__item mdl-list__item--three-line" onclick="location.href='./flight';">
<span class="mdl-list__item-primary-content">
<i class="material-icons mdl-list__item-avatar">flight_takeoff</i>
<span>Flight Reservation</span>
<span class="mdl-list__item-text-body">
Use this type to declare a reservation for air travel.
</span>
</span>
</li>
<li class="mdl-list__item mdl-list__item--three-line" onclick="location.href='./hotel';">
<span class="mdl-list__item-primary-content">
<i class="material-icons mdl-list__item-avatar">hotel</i>
<span>Hotel Reservation</span>
<span class="mdl-list__item-text-body">
Use this type to declare a reservation for one or more guests at a hotel
or place of lodging.
</span>
</span>
</li>
<li class="mdl-list__item mdl-list__item--three-line" onclick="location.href='./rentalcar';">
<span class="mdl-list__item-primary-content">
<i class="material-icons mdl-list__item-avatar">directions_car</i>
<span>Rental Car Reservation</span>
<span class="mdl-list__item-text-body">
Use this type to declare a reservation for a rental car.
</span>
</span>
</li>
<li class="mdl-list__item mdl-list__item--three-line" onclick="location.href='./restaurant';">
<span class="mdl-list__item-primary-content">
<i class="material-icons mdl-list__item-avatar">restaurant</i>
<span>Restaurant Reservation</span>
<span class="mdl-list__item-text-body">
Use this type to declare a reservation for one or more guests at a
restaurant or other food establishment.
</span>
</span>
</li>
</ul>
</p>
{{> mdl_content_foot}}

View File

@ -0,0 +1,21 @@
{{> html_head}}
{{> mdl_head}}
{{> mdl_content_head}}
<div class="frs-crumbs mdl-color-text--grey-500">
<a href="./">Fake Reservation System</a> &gt; Logged in
</div>
<h3>Your email address is not verified!</h3>
<p>
To use this system, you must verify your Google email address first!
</p>
<p>
You can find more information at this address:<br/>
<a href="https://support.google.com/accounts/answer/63950">https://support.google.com/accounts/answer/63950</a>.
</p>
{{> mdl_content_foot}}
{{> mdl_foot}}
{{> html_foot}}

View File

@ -3,9 +3,8 @@
<footer class="frs-footer mdl-mini-footer">
<div class="mdl-mini-footer--left-section">
<ul class="mdl-mini-footer--link-list">
<li><a href="#">Help</a></li>
<li><a href="#">Privacy and Terms</a></li>
<li><a href="#">User Agreement</a></li>
<li><a href="./">Home</a></li>
<li><a href="faq">FAQ</a></li>
</ul>
</div>
</footer>

View File

@ -6,7 +6,7 @@
<!-- Navigation -->
<nav class="mdl-navigation">
{{# user.name_first}}
<span class="mdl-navigation__link mdl-color-text--grey-800">Hello, {{user.name_first}}!</span>
<span class="mdl-navigation__link mdl-color-text--grey-800">Hello, {{user.name_first}}!<span id="session_expires"></span></span>
{{/ user.name_first}}
<button id="frs-menu-top" class="mdl-button mdl-js-button mdl-button--icon">
<span class="material-icons">more_vert</span>
@ -19,3 +19,25 @@
</header>
<div class="frs-ribbon"></div>
<main class="frs-main mdl-layout__content">
<script>
var page_load_time = Math.floor(Date.now() / 1000);
var seconds_left = {{session_time_left}};
var expire_time = page_load_time + seconds_left;
function updateTimeLeft() {
var now = Math.floor(Date.now() / 1000);
var time_left = expire_time - now;
var obj = document.getElementById('session_expires');
var minutes = Math.floor(time_left / 60);
var seconds = time_left % 60;
if (minutes+seconds > 0) {
obj.innerHTML = ' (' + ('0' + minutes).slice(-2) + ':' + ('0' + seconds).slice(-2) + ')';
} else {
obj.innerHTML = '';
window.clearInterval(window.updateTimer);
}
}
var updateTimer = window.setInterval('updateTimeLeft();', 1000);
</script>