Compare commits
50 Commits
ec776f837e
...
issue-67
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1aee7cdc02 | ||
| ba3f2e954a | |||
|
|
fbffeec3a3 | ||
| 817b573258 | |||
|
|
d08bdc0893 | ||
| b052fa50db | |||
|
|
efad44ea57 | ||
| 23f3d647e0 | |||
|
|
954cadd874 | ||
| 2b33c35049 | |||
|
|
fcfc0bd58a | ||
| 31e65c4730 | |||
|
|
6fb933a86c | ||
| e76edbb531 | |||
|
|
081aa0f7a4 | ||
| 0afea8ead6 | |||
|
|
41b7d5778d | ||
|
|
cee945f561 | ||
| f806edb7b3 | |||
|
|
76ae18e82a | ||
|
|
23220819d5 | ||
| a839befc41 | |||
|
|
7a5e7a5d9d | ||
| 611628c753 | |||
|
|
4fdd43dc4e | ||
| 5512990704 | |||
|
|
9187702634 | ||
|
|
4b2dedc8f2 | ||
| a3e8c19795 | |||
|
|
178853874f | ||
|
|
0b3d25d013 | ||
| 42c61feff8 | |||
|
|
b4aa26ee17 | ||
| bfe04f94ca | |||
|
|
5d75992372 | ||
| dcbb7e21f3 | |||
|
|
db3f7772a6 | ||
| 625193e99e | |||
| 0df6753bd2 | |||
|
|
e5f44b92e4 | ||
|
|
283c5b905e | ||
| de000d0403 | |||
|
|
2f55d8491a | ||
| 6f29248e8b | |||
|
|
817479415f | ||
| b0ba390cb5 | |||
|
|
9f3c5a1487 | ||
| b66e08bc5b | |||
|
|
f82fbd0e5a | ||
| 556e7adfab |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,3 +7,4 @@
|
||||
Homestead.json
|
||||
Homestead.yaml
|
||||
.env
|
||||
database/printer.db
|
||||
|
||||
93
app/Http/Controllers/AirlyController.php
Normal file
93
app/Http/Controllers/AirlyController.php
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: k
|
||||
* Date: 10.02.2017
|
||||
* Time: 20:10
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
set_time_limit(-1);
|
||||
|
||||
use App\Paper\Airly;
|
||||
use App\Paper\Paper;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AirlyController extends Controller
|
||||
{
|
||||
|
||||
private $paper = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->paper = new Paper();
|
||||
}
|
||||
|
||||
/**
|
||||
* get:/airly_all
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
public function airly_all()
|
||||
{
|
||||
$airly = new Airly();
|
||||
$this->paper->sendImagePrint($airly->icon);
|
||||
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
|
||||
$airly->setStations(config('paper.airly.stations'));
|
||||
|
||||
foreach ($airly->getStations() as $stationId) {
|
||||
$stationInfo = $airly->getStationInfo($stationId);
|
||||
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
|
||||
$dataText = $airly->getInformationText($stationId);
|
||||
$this->paper->sendPrint('', $dataText);
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function airly_rzeczypospolitej()
|
||||
{
|
||||
$airly = new Airly();
|
||||
$this->paper->sendImagePrint($airly->icon);
|
||||
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
|
||||
$airly->setStations([config('paper.airly.rzeczypospolitej')]);
|
||||
|
||||
foreach ($airly->getStations() as $stationId) {
|
||||
$stationInfo = $airly->getStationInfo($stationId);
|
||||
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
|
||||
$dataText = $airly->getInformationText($stationId);
|
||||
$this->paper->sendPrint('', $dataText);
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function airly_grunwaldzka()
|
||||
{
|
||||
$airly = new Airly();
|
||||
$this->paper->sendImagePrint($airly->icon);
|
||||
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
|
||||
$airly->setStations([config('paper.airly.grunwaldzka')]);
|
||||
|
||||
foreach ($airly->getStations() as $stationId) {
|
||||
$stationInfo = $airly->getStationInfo($stationId);
|
||||
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
|
||||
$dataText = $airly->getInformationText($stationId);
|
||||
$this->paper->sendPrint('', $dataText);
|
||||
}
|
||||
return back();
|
||||
}
|
||||
|
||||
public function airly_sowinskiego()
|
||||
{
|
||||
$airly = new Airly();
|
||||
$this->paper->sendImagePrint($airly->icon);
|
||||
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
|
||||
$airly->setStations([config('paper.airly.sowinskiego')]);
|
||||
|
||||
foreach ($airly->getStations() as $stationId) {
|
||||
$stationInfo = $airly->getStationInfo($stationId);
|
||||
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
|
||||
$dataText = $airly->getInformationText($stationId);
|
||||
$this->paper->sendPrint('', $dataText);
|
||||
}
|
||||
return back();
|
||||
}
|
||||
}
|
||||
@@ -2,25 +2,134 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Paper\CinemaMultikino;
|
||||
use DiDom\Query;
|
||||
use Illuminate\Http\Request;
|
||||
use DiDom\Document;
|
||||
use App\Paper\InteractiveMenu;
|
||||
use App\Paper\Paper;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Keyboard extends Controller
|
||||
{
|
||||
|
||||
private $paper;
|
||||
|
||||
public function __construct()
|
||||
public function press(Request $request, $key)
|
||||
{
|
||||
$this->paper = new Paper();
|
||||
}
|
||||
|
||||
public function press($key)
|
||||
{
|
||||
$this->paper->sendPrint($key);
|
||||
$keyboardData = DB::table('keyboard')->where('key', $key)->first();
|
||||
|
||||
if (isset($keyboardData) && isset($keyboardData->action)) {
|
||||
|
||||
|
||||
$keyboardAction = explode('_', $keyboardData->action);
|
||||
|
||||
$redis = new \Redis();
|
||||
$redis->connect('127.0.0.1', 6379);
|
||||
if($keyboardAction[0] == 'interactivemenu' || $redis->get('interactivemenu')){
|
||||
$interactiveMenu = new InteractiveMenu();
|
||||
$interactiveMenu->pressed($key);
|
||||
return;
|
||||
}
|
||||
|
||||
switch ($keyboardAction[0]) {
|
||||
case 'settings':
|
||||
$settings = new Settings();
|
||||
$settings->printMappedKeys();
|
||||
|
||||
break;
|
||||
case 'airly':
|
||||
$airly = new AirlyController();
|
||||
switch ($keyboardAction[1]) {
|
||||
case 'all':
|
||||
$airly->airly_all();
|
||||
break;
|
||||
case 'rzeczypospolitej':
|
||||
$airly->airly_rzeczypospolitej();
|
||||
break;
|
||||
case 'grunwaldzka':
|
||||
$airly->airly_grunwaldzka();
|
||||
break;
|
||||
case 'sowinskiego':
|
||||
$airly->airly_sowinskiego();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'note':
|
||||
switch ($keyboardAction[1]) {
|
||||
case 'last':
|
||||
$main = new Main();
|
||||
$main->noteLast();
|
||||
break;
|
||||
case $keyboardAction[1] > 0:
|
||||
$main = new Main();
|
||||
$main->printNote((int)$keyboardAction[1]);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'repertoire':
|
||||
switch ($keyboardAction[1]) {
|
||||
case 'all':
|
||||
switch ($keyboardAction[2]) {
|
||||
case 'today':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->today_repertoire($request);
|
||||
break;
|
||||
case 'tomorrow':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->tomorrow_repertoire($request);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'helios':
|
||||
switch ($keyboardAction[2]) {
|
||||
case 'today':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->today_helios($request);
|
||||
break;
|
||||
case 'tomorrow':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->tomorrow_helios($request);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'multikino':
|
||||
switch ($keyboardAction[2]) {
|
||||
case 'today':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->today_multikino($request);
|
||||
break;
|
||||
case 'tomorrow':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->tomorrow_multikino($request);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'cinemacity':
|
||||
switch ($keyboardAction[2]) {
|
||||
case 'today':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->today_cinemacity($request);
|
||||
break;
|
||||
case 'tomorrow':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->tomorrow_cinemacity($request);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'gdynskiecentrumfilmowe':
|
||||
switch ($keyboardAction[2]) {
|
||||
case 'today':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->today_gdynskiecentrumfilmowe($request);
|
||||
break;
|
||||
case 'tomorrow':
|
||||
$repertoire = new Repertoire();
|
||||
$repertoire->tomorrow_gdynskiecentrumfilmowe($request);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
namespace App\Http\Controllers;
|
||||
set_time_limit(-1);
|
||||
|
||||
use App\Paper\Airly;
|
||||
use App\Paper\Paper;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
|
||||
use Mike42\Escpos\Printer;
|
||||
use Intervention\Image\ImageManagerStatic as Image;
|
||||
use Mike42\Escpos\EscposImage;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -34,6 +31,7 @@ class Main extends Controller
|
||||
* post::/printImage
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function imagePrint(Request $request)
|
||||
{
|
||||
@@ -51,7 +49,7 @@ class Main extends Controller
|
||||
|
||||
|
||||
$image = $image->greyscale()
|
||||
->resize(300, null, function ($constraint) {
|
||||
->resize(370, null, function ($constraint) {
|
||||
$constraint->aspectRatio();
|
||||
$constraint->upsize();
|
||||
});
|
||||
@@ -108,13 +106,10 @@ class Main extends Controller
|
||||
// Header("Content-type: image/png");
|
||||
imagepng($output, $fileName, 9); //to print to screen
|
||||
|
||||
|
||||
$connector = new FilePrintConnector("/dev/usb/lp0");
|
||||
$printer = new Printer($connector);
|
||||
$img = EscposImage::load($fileName, false);
|
||||
$printer->bitImage($img);
|
||||
$this->paper->getPrinter()->bitImage($img);
|
||||
|
||||
$printer->feed(4);
|
||||
$this->paper->getPrinter()->feed(4);
|
||||
|
||||
return back();
|
||||
}
|
||||
@@ -139,25 +134,30 @@ class Main extends Controller
|
||||
}
|
||||
|
||||
/**
|
||||
* get:/airly
|
||||
* get:/filte/{$filter?}
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @param null $filter
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function airly(Request $request)
|
||||
public function filterView(Request $request, $filter = 'empty')
|
||||
{
|
||||
$airly = new Airly();
|
||||
$this->paper->sendImagePrint($airly->icon);
|
||||
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
|
||||
$airly->setStations(config('paper.airly.stations'));
|
||||
|
||||
foreach ($airly->getStations() as $stationId) {
|
||||
$stationInfo = $airly->getStationInfo($stationId);
|
||||
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
|
||||
$dataText = $airly->getInformationText($stationId);
|
||||
$this->paper->sendPrint('', $dataText);
|
||||
}
|
||||
return back();
|
||||
|
||||
$notes = DB::select('SELECT *, CASE WHEN icon IS NULL
|
||||
THEN \'empty\'
|
||||
ELSE icon
|
||||
END AS new_icon FROM note WHERE type = "note" AND new_icon = :icon ORDER BY updated_at DESC', ['icon' => $filter]);
|
||||
$templates = DB::select('SELECT *, CASE WHEN icon IS NULL
|
||||
THEN \'empty\'
|
||||
ELSE icon
|
||||
END AS new_icon FROM note WHERE type = "template" AND new_icon = :icon ORDER BY updated_at DESC', ['icon' => $filter]);
|
||||
return view('list', [
|
||||
'filter' => $filter,
|
||||
'notes' => $notes,
|
||||
'templates' => $templates,
|
||||
'title' => $request->old('title'),
|
||||
'text' => $request->old('text'),
|
||||
'icon_selected' => $request->old('icon'),
|
||||
'icons' => $this->paper->getIcons()
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -168,15 +168,26 @@ class Main extends Controller
|
||||
*/
|
||||
public function printText(Request $request, $id)
|
||||
{
|
||||
$note = DB::table('note')->where('id', $id)->first();
|
||||
$this->paper->sendPrint($note->topic, $note->text, $note->icon);
|
||||
$note = $this->printNote($id);
|
||||
$request->session()->flash('print_status', 'Wydrukowano notatkę: ' . $note->topic . '!');
|
||||
return back();
|
||||
}
|
||||
|
||||
public function printNote($noteId)
|
||||
{
|
||||
$note = DB::table('note')->where('id', $noteId)->first();
|
||||
$this->paper->sendPrint($note->topic, $note->text, $note->icon);
|
||||
return $note;
|
||||
}
|
||||
|
||||
public function noteLast()
|
||||
{
|
||||
$note = DB::table('note')->orderBy('id', 'desc')->first();
|
||||
$this->printNote($note->id);
|
||||
}
|
||||
|
||||
private function templateReplace($input)
|
||||
{
|
||||
|
||||
return str_replace(['[d]', '[m]', '[y]', '[h]', '[i]', '[s]'],
|
||||
[date('d'), date('m'), date('Y'), date('H'), date('i'), date('s')],
|
||||
$input);
|
||||
@@ -191,7 +202,7 @@ class Main extends Controller
|
||||
* @param $slug
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||
*/
|
||||
public function edit(Request $request, $id, $slug)
|
||||
public function edit(Request $request, $id, $slug = null)
|
||||
{
|
||||
$note = DB::table('note')->where('id', $id)->first();
|
||||
if ($request->isMethod('post')) {
|
||||
@@ -205,11 +216,13 @@ class Main extends Controller
|
||||
'text' => $this->templateReplace($request->input('text')),
|
||||
'icon' => $request->input('icon'),
|
||||
'type' => self::NOTE,
|
||||
'private' => $request->input('private', 0),
|
||||
'created_at' => time(),
|
||||
'updated_at' => time()
|
||||
]);
|
||||
$note = DB::table('note')->where('id', $id)->first();
|
||||
} else {
|
||||
|
||||
DB::table('note')
|
||||
->where('id', $note->id)
|
||||
->update([
|
||||
@@ -217,6 +230,7 @@ class Main extends Controller
|
||||
'topic_slug' => str_slug($request->input('title'), '_'),
|
||||
'text' => $request->input('text'),
|
||||
'icon' => $request->input('icon'),
|
||||
'private' => $request->input('private',0),
|
||||
'updated_at' => time(),
|
||||
]);
|
||||
}
|
||||
@@ -227,6 +241,7 @@ class Main extends Controller
|
||||
return redirect()->route('list');
|
||||
} elseif ($request->exists('print')) {
|
||||
$this->paper->sendPrint($request->input('title'), $request->input('text'), $request->input('icon'));
|
||||
$request->session()->flash('print_status', 'Wydrukowano notatkę: ' . (strlen($request->input('title')) ? $request->input('title') : substr($request->input('text'), 0, 20)) . '!');
|
||||
}
|
||||
return redirect()->route('edit', ['id' => $note->id, 'slug' => $note->topic_slug]);
|
||||
} else {
|
||||
@@ -235,6 +250,7 @@ class Main extends Controller
|
||||
'text' => $note->text,
|
||||
'icon_selected' => $note->icon,
|
||||
'type' => $note->type,
|
||||
'private' => $note->private,
|
||||
'id' => $note->id,
|
||||
'icons' => $this->paper->getIcons(),
|
||||
'topic_slug' => $note->topic_slug,
|
||||
@@ -258,6 +274,7 @@ class Main extends Controller
|
||||
'text' => $request->input('text'),
|
||||
'icon' => $request->input('icon'),
|
||||
'type' => self::NOTE,
|
||||
'private' => $request->input('private',0),
|
||||
'created_at' => time(),
|
||||
'updated_at' => time()
|
||||
]);
|
||||
@@ -271,6 +288,7 @@ class Main extends Controller
|
||||
'text' => $request->input('text'),
|
||||
'icon' => $request->input('icon'),
|
||||
'type' => self::TEMPLATE,
|
||||
'private' => $request->input('private',0),
|
||||
'created_at' => time(),
|
||||
'updated_at' => time()
|
||||
]);
|
||||
|
||||
27
app/Http/Controllers/Plivo.php
Normal file
27
app/Http/Controllers/Plivo.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Paper\Paper;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Plivo extends Controller
|
||||
{
|
||||
/** @var Paper */
|
||||
private $paper;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->paper = new Paper();
|
||||
}
|
||||
|
||||
|
||||
public function recieveSms(Request $request)
|
||||
{
|
||||
if ($request->isMethod('post')) {
|
||||
$this->paper->sendPrint('SMS od '. $request->input('From'), $request->input('Text')."\n\n".date('d-m-Y H:i'), 'envelope-o');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
122
app/Http/Controllers/Settings.php
Normal file
122
app/Http/Controllers/Settings.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: k
|
||||
* Date: 10.02.2017
|
||||
* Time: 20:10
|
||||
*/
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
set_time_limit(-1);
|
||||
|
||||
use App\Paper\Paper;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class Settings extends Controller
|
||||
{
|
||||
|
||||
private $paper = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->paper = new Paper();
|
||||
}
|
||||
|
||||
/**
|
||||
* get:/
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
||||
*/
|
||||
public function mainView(Request $request)
|
||||
{
|
||||
|
||||
$keyboard = DB::select('SELECT * FROM keyboard');
|
||||
return view('settings', [
|
||||
'keyboard' => $keyboard,
|
||||
'actions' => $this->getActions()
|
||||
]);
|
||||
}
|
||||
|
||||
public function getMappedKeys()
|
||||
{
|
||||
$keys = DB::table('keyboard')->get();
|
||||
$text = '';
|
||||
$actions = $this->getActions('');
|
||||
foreach ($keys as $key) {
|
||||
$text .= '[' . $key->key . '] ' . $actions[$key->action] . "\n";
|
||||
}
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function printMappedKeys()
|
||||
{
|
||||
$this->paper->sendPrint('Zmapowane klawisze', $this->getMappedKeys());
|
||||
}
|
||||
|
||||
public function save(Request $request)
|
||||
{
|
||||
foreach ($request->input('key') as $keyid => $keyValue) {
|
||||
DB::table('keyboard')
|
||||
->where('id', $keyid)
|
||||
->update([
|
||||
'action' => $keyValue,
|
||||
]);
|
||||
}
|
||||
return redirect()->route('settingsList');
|
||||
}
|
||||
|
||||
private function getActions($noActionText = 'Bez akcji')
|
||||
{
|
||||
$actions = [];
|
||||
$actions[''] = $noActionText;
|
||||
|
||||
$actions['separator0'] = 'separator';
|
||||
|
||||
$actions['settings_list'] = 'Lista zmapowanych klawiszy';
|
||||
|
||||
$actions['separator1'] = 'separator';
|
||||
$actions['interactivemenu'] = 'Interaktywne menu';
|
||||
|
||||
$actions['separator2'] = 'separator';
|
||||
|
||||
$actions['repertoire_all_today'] = 'Repertuar wszystkie kina dzisiaj';
|
||||
$actions['repertoire_all_tomorrow'] = 'Repertuar wszystkie kina jutro';
|
||||
|
||||
$actions['repertoire_helios_today'] = 'Repertuar Helios dzisiaj';
|
||||
$actions['repertoire_helios_tomorrow'] = 'Repertuar Helios jutro';
|
||||
|
||||
$actions['repertoire_multikino_today'] = 'Repertuar Multikino dzisiaj';
|
||||
$actions['repertoire_multikino_tomorrow'] = 'Repertuar Multikino jutro';
|
||||
|
||||
$actions['repertoire_cinemacity_today'] = 'Repertuar Cinema-City dzisiaj';
|
||||
$actions['repertoire_cinemacity_tomorrow'] = 'Repertuar Cinema-City jutro';
|
||||
|
||||
$actions['repertoire_gdynskiecentrumfilmowe_today'] = 'Repertuar Gdyńskie Centrum filmowe dzisiaj';
|
||||
$actions['repertoire_gdynskiecentrumfilmowe_tomorrow'] = 'Repertuar Gdyńskie Centrum filmowe jutro';
|
||||
|
||||
$actions['separator3'] = 'separator';
|
||||
$actions['airly_all'] = 'Airly wszystkie stacje';
|
||||
$actions['airly_rzeczypospolitej'] = 'Airly (Rzeczypospolitej)';
|
||||
$actions['airly_grunwaldzka'] = 'Airly (Grunwaldzka)';
|
||||
$actions['airly_sowinskiego'] = 'Airly (Sowińskiego)';
|
||||
|
||||
// $actions['separator3'] = 'separator';
|
||||
// $actions['spacex_next_flight'] = 'Najbliższy lot SpaceX';
|
||||
// $actions['spacex_prev_flight'] = 'Poprzedni lot SpaceX';
|
||||
// $actions['spacex_all_next_summary'] = 'Wszystkie zaplanowane loty SpaceX (skrót)';
|
||||
|
||||
$actions['separator5'] = 'separator';
|
||||
$actions['note_last'] = 'Ostatnia zapisana notatka';
|
||||
|
||||
|
||||
$actions['separator6'] = 'separator';
|
||||
|
||||
$notes = DB::select('SELECT * FROM note WHERE type = "note" ORDER BY updated_at DESC');
|
||||
foreach ($notes as $note) {
|
||||
$actions['note_' . $note->id] = 'Notatka: ' . $note->topic;
|
||||
}
|
||||
return $actions;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'sms'
|
||||
];
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ class Airly
|
||||
return $this->stations;
|
||||
}
|
||||
|
||||
public function setStations($stations){
|
||||
public function setStations(array $stations){
|
||||
$this->stations = $stations;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,9 +26,6 @@ class CinemaCinemaCity implements Cinema
|
||||
if (is_null($this->cinemaId) || is_null($this->day))
|
||||
throw new \Exception('Day or cinemaid not set.');
|
||||
|
||||
// if (!is_array($this->cinemaId)) {
|
||||
// $this->cinemaId = (array)$this->cinemaId;
|
||||
// }
|
||||
$url = 'https://www.cinema-city.pl/pgm-list-byfeat?si=' . $this->cinemaId . '&sort=cin&bd=' . $this->day;
|
||||
|
||||
return file_get_contents($url);
|
||||
@@ -41,9 +38,6 @@ class CinemaCinemaCity implements Cinema
|
||||
$document = json_decode($document);
|
||||
|
||||
|
||||
// $cinemaData = [];
|
||||
// $text = "Repertuar Cinema-City\n";
|
||||
// $text .= str_replace('/', '-', $this->day) . "\n\n";
|
||||
$movies = [];
|
||||
|
||||
$date = date('d/m/Y', strtotime($this->day));
|
||||
@@ -55,9 +49,6 @@ class CinemaCinemaCity implements Cinema
|
||||
foreach ($movieData->BD as $projections) {
|
||||
if ($projections->date == $date) {
|
||||
foreach ($projections->P as $projection) {
|
||||
|
||||
// var_dump($projection);
|
||||
// die();
|
||||
$movie['hours'][] = $projection->time;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,14 +12,39 @@ class HtmlToPos
|
||||
return str_replace(['<br>', '<br/>', '<br />'], "\n", $text);
|
||||
}
|
||||
|
||||
public function convert($html = '')
|
||||
/**
|
||||
* usuwa linijki które na początku mają ! albo #
|
||||
* @param $posText
|
||||
* @return string
|
||||
*/
|
||||
private function hideLines($posText): string
|
||||
{
|
||||
$posText = $this->handleNewLine($html);
|
||||
return preg_replace('/^\s*[!#].*?$[\r\n]?/m', '', $posText);
|
||||
}
|
||||
|
||||
|
||||
private function pickRandomElement($posText)
|
||||
{
|
||||
/**
|
||||
* usuwa linijki które na początku mają ! albo #
|
||||
* poniższy kod wybieraz tekstu fragmenty w podwójnych nawiasach kwadratowych, rozdziela je po przecinkach
|
||||
* następnie losuje element i podmienia go w miejsce oryginalnego fragmentu
|
||||
*/
|
||||
$posText = preg_replace('/^\s*[!#].*?$[\r\n]/m', '', $posText);
|
||||
$re = "#\[\[(.*?)\]\]#s";
|
||||
preg_match_all($re, $posText, $found, PREG_SET_ORDER, 0);
|
||||
foreach ($found as $elements) {
|
||||
$data = explode(',', $elements[1]);
|
||||
$data = array_filter($data, function ($el) {
|
||||
return strlen(trim($el));
|
||||
});
|
||||
$data = array_values($data);
|
||||
$pos = strpos($posText, $elements[0]);
|
||||
$posText = substr_replace($posText, $data[mt_rand(0, count($data) - 1)], $pos, strlen($elements[0]));
|
||||
}
|
||||
return $posText;
|
||||
}
|
||||
|
||||
private function randomNumber($posText)
|
||||
{
|
||||
|
||||
/**
|
||||
* przeszukiwanie tekstu pod katem zawartości [ liczba, liczba2 ] i zamienianiu tego na randomową liczbę z przedziału
|
||||
@@ -27,12 +52,64 @@ class HtmlToPos
|
||||
* obojętnie czy ujemną czy nie
|
||||
*/
|
||||
$re = '/\[\s*(-?\d+)\s*\,\s*(-?\d+)\s*\]/';
|
||||
preg_match_all($re, $html, $matches, PREG_SET_ORDER, 0);
|
||||
preg_match_all($re, $posText, $matches, PREG_SET_ORDER, 0);
|
||||
foreach ($matches as $match) {
|
||||
$pos = strpos($posText, $match[0]);
|
||||
$posText = substr_replace($posText, mb_rand($match[1], $match[2]), $pos, strlen($match[0]));
|
||||
$posText = substr_replace($posText, mt_rand($match[1], $match[2]), $pos, strlen($match[0]));
|
||||
}
|
||||
return $posText;
|
||||
}
|
||||
|
||||
public function vocabularyWord($posText)
|
||||
{
|
||||
if (strstr($posText, '[vocabulary_word]')
|
||||
|| strpos($posText, '[vocabulary_short]')
|
||||
|| strpos($posText, '[vocabulary_long]')) {
|
||||
$voc = new Vocabulary();
|
||||
$randomWord = $voc->getRandomWord();
|
||||
$word = $voc->getWord($randomWord);
|
||||
|
||||
$posText = str_replace('[vocabulary_word]', $word->word, $posText);
|
||||
$posText = str_replace('[vocabulary_short]', $word->short, $posText);
|
||||
$posText = str_replace('[vocabulary_long]', $word->long, $posText);
|
||||
}
|
||||
|
||||
return $posText;
|
||||
}
|
||||
|
||||
public function traficar($posText)
|
||||
{
|
||||
if (strstr($posText, '[traficar]')) {
|
||||
$traficar = new Traficar();
|
||||
$nearest = $traficar->nearestCarText();
|
||||
$posText = str_replace('[traficar]', $nearest, $posText);
|
||||
}
|
||||
return $posText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* łamie tekst w miejscu spacji do długości 32 znaki na linię
|
||||
* @param $posText
|
||||
* @return string
|
||||
*/
|
||||
public function textBreak($posText)
|
||||
{
|
||||
$posText = wordwrap($posText, 32);
|
||||
return $posText;
|
||||
}
|
||||
|
||||
public function convert($html = '')
|
||||
{
|
||||
$posText = $this->handleNewLine($html);
|
||||
$posText = $this->hideLines($posText);
|
||||
$posText = $this->pickRandomElement($posText);
|
||||
$posText = $this->randomNumber($posText);
|
||||
$posText = $this->vocabularyWord($posText);
|
||||
$posText = $this->traficar($posText);
|
||||
|
||||
$posText = $this->textBreak($posText);
|
||||
|
||||
return $posText;
|
||||
}
|
||||
}
|
||||
42
app/Paper/InteractiveMenu.php
Normal file
42
app/Paper/InteractiveMenu.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Paper;
|
||||
|
||||
|
||||
class InteractiveMenu
|
||||
{
|
||||
|
||||
private $apiKey;
|
||||
|
||||
private $paper;
|
||||
|
||||
private $redis;
|
||||
|
||||
private $structure = [
|
||||
0 =>
|
||||
[
|
||||
'title' => 'tytuł pierwszego menu',
|
||||
1 => ['name' => 'to jest podtytuł pierwszego menu', 'action' => '', 'type' => 'output'],
|
||||
2 => ['name' => 'to jest podtytuł drugiego menu', 'action' => '', 'type' => 'input'],
|
||||
3 => ['name' => 'to jest podtytuł trzeciego menu', 'action' => '', 'type' => 'outputandinput'],
|
||||
4 => ['name' => 'to jest podtytuł czwartego menu', 'action' => '', 'type' => 'inputandoutput'],
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->paper = new Paper();
|
||||
$this->redis = new \Redis();
|
||||
$this->redis->connect('127.0.0.1', 6379);
|
||||
$this->redis->setex('interactivemenu', 10, 1);
|
||||
}
|
||||
|
||||
public function pressed($key)
|
||||
{
|
||||
$this->paper->sendPrint($key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,11 +23,21 @@ class Paper
|
||||
try {
|
||||
$this->connector = new FilePrintConnector("/dev/usb/lp0");
|
||||
$this->printer = new Printer($this->connector);
|
||||
}catch (Exception $e){
|
||||
} catch (Exception $e) {
|
||||
die($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function getConnector()
|
||||
{
|
||||
return $this->connector;
|
||||
}
|
||||
|
||||
public function getPrinter()
|
||||
{
|
||||
return $this->printer;
|
||||
}
|
||||
|
||||
|
||||
public function sendHeaderPrint($title)
|
||||
{
|
||||
@@ -42,11 +52,15 @@ class Paper
|
||||
}
|
||||
}
|
||||
|
||||
public function sendImagePrint($image, $imageLocal = true)
|
||||
public function sendImagePrint($image, $imageLocal = true, $icon = true)
|
||||
{
|
||||
if ($image) {
|
||||
if ($imageLocal) {
|
||||
$img = EscposImage::load($this->imageDirectory . basename($image).'.png');
|
||||
if ($icon) {
|
||||
$img = EscposImage::load($this->imageDirectory . basename($image) . '.png');
|
||||
} else {
|
||||
$img = EscposImage::load($image);
|
||||
}
|
||||
} else { //image not local so then remote image
|
||||
$extension = strtolower(pathinfo($image, PATHINFO_EXTENSION));
|
||||
|
||||
@@ -61,15 +75,35 @@ class Paper
|
||||
}
|
||||
}
|
||||
|
||||
public function saveToHistory($title, $text, $textSource, $image)
|
||||
{
|
||||
DB::table('history')
|
||||
->insertGetId([
|
||||
'topic' => $title,
|
||||
'topic_slug' => str_slug($title, '_'),
|
||||
'text' => $text,
|
||||
'text_source' => $textSource,
|
||||
'icon' => $image,
|
||||
'created_at' => time(),
|
||||
'updated_at' => time()
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
public function sendPrint($title, $text = '', $image = false, $imageLocal = true)
|
||||
{
|
||||
$this->sendImagePrint($image, $imageLocal);
|
||||
|
||||
$this->sendHeaderPrint($title);
|
||||
$htmlToPos = new HtmlToPos();
|
||||
$this->printer->text($htmlToPos->convert($text));
|
||||
$convertedData = $htmlToPos->convert($text);
|
||||
|
||||
//zapisuje do pamięci dane o drukowanej notatce, jesli obrazek nie jest ikoną to nie zapisuje go
|
||||
$this->saveToHistory($title, $convertedData, $text, $imageLocal ? $image : '');
|
||||
if (is_array($convertedData)) {
|
||||
$this->printer->text($convertedData['text']);
|
||||
} else {
|
||||
$this->printer->text($htmlToPos->convert($text));
|
||||
}
|
||||
$this->printer->feed(3);
|
||||
}
|
||||
|
||||
@@ -83,7 +117,7 @@ class Paper
|
||||
*/
|
||||
public function getIcons()
|
||||
{
|
||||
$icons = ["address-card-o","anchor","archive-3","at","balance-scale","ban","bar-chart-o","barcode","battery-empty","battery-full","battery-half","battery-quarter","battery-three-quarters","bed","beer","bell-o","bell-slash-o","bicycle","birthday-cake","bolt","bomb","book","bug","building-o","bullhorn","bus","camera","car","chain","chat-2","check","cloud","code","coffee","cog","cutlery","dashboard","database","diamond","dollar","dribbble","envelope-o","envira","exclamation-triangle","female","file-text-o","film","fingerprint","fire-extinguisher","fire","flag-o","flask","floppy-o","folder-o","folder-open-o","frown-o","gamepad","gift","git","glass","graduation-cap","grav","group","hand-o-left","heart-o","home","lemon-o","lightbulb-o","list-alt","location-arrow","lock","male","map-1","map-marker","microchip","money","moon-o","music","paper-plane","paperclip","paw","pencil","phone","pie-chart","piggy-bank","plane","question-circle-o","rocket","search","ship","shopping-cart","smile-o","snowflake-o","steam","subway","success","support","thermometer-2","thumbs-o-down","thumbs-o-up","ticket","times","trash-o","tree","trophy","truck","umbrella","usd","warning","wifi","wpexplorer","wrench","youtube-play"];
|
||||
$icons = ["address-card-o", "anchor", "archive-3", "at", "balance-scale", "ban", "bar-chart-o", "barcode", "battery-empty", "battery-full", "battery-half", "battery-quarter", "battery-three-quarters", "bed", "beer", "bell-o", "bell-slash-o", "bicycle", "birthday-cake", "bolt", "bomb", "book", "bug", "building-o", "bullhorn", "bus", "camera", "car", "chain", "chat-2", "check", "cloud", "code", "coffee", "cog", "cutlery", "dashboard", "database", "diamond", "dollar", "dribbble", "envelope-o", "envira", "exclamation-triangle", "female", "file-text-o", "film", "fingerprint", "fire-extinguisher", "fire", "flag-o", "flask", "floppy-o", "folder-o", "folder-open-o", "frown-o", "gamepad", "gift", "git", "glass", "graduation-cap", "grav", "group", "hand-o-left", "heart-o", "home", "lemon-o", "lightbulb-o", "list-alt", "location-arrow", "lock", "male", "map-1", "map-marker", "microchip", "money", "moon-o", "music", "paper-plane", "paperclip", "paw", "pencil", "phone", "pie-chart", "piggy-bank", "plane", "question-circle-o", "rocket", "search", "ship", "shopping-cart", "smile-o", "snowflake-o", "steam", "subway", "success", "support", "thermometer-2", "thumbs-o-down", "thumbs-o-up", "ticket", "times", "trash-o", "tree", "trophy", "truck", "umbrella", "usd", "warning", "wifi", "wpexplorer", "wrench", "youtube-play"];
|
||||
|
||||
|
||||
$iconsDatabase = [];
|
||||
|
||||
108
app/Paper/Traficar.php
Normal file
108
app/Paper/Traficar.php
Normal file
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: k
|
||||
* Date: 30.06.2018
|
||||
* Time: 18:29
|
||||
*/
|
||||
|
||||
namespace App\Paper;
|
||||
|
||||
|
||||
class Traficar
|
||||
{
|
||||
|
||||
private $homeCoords = ['lat' => 54.417475, 'lng' => 18.481913];
|
||||
|
||||
private $traficarJson;
|
||||
//dystans w kilometrach w którym auta brane są pod uwagę
|
||||
const CLOSEST_DISTANCE = 2.5;
|
||||
|
||||
/**
|
||||
* @param $lat1
|
||||
* @param $lon1
|
||||
* @param $lat2
|
||||
* @param $lon2
|
||||
* @return float zwracana jest odległość w kilometrach
|
||||
*/
|
||||
private function distance($lat1, $lon1, $lat2, $lon2)
|
||||
{
|
||||
|
||||
$theta = $lon1 - $lon2;
|
||||
$dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) + cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
|
||||
$dist = acos($dist);
|
||||
$dist = rad2deg($dist);
|
||||
$miles = $dist * 60 * 1.1515;
|
||||
return ($miles * 1.609344);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pobiera informacje o najbliższym trafficarze względem punktu podanego jako domowy i zwraca Sformatowane
|
||||
* informacje na jego temat lub jesli nie ma auta to podaje informację że nie ma dostępnego.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function nearestCarText()
|
||||
{
|
||||
$info = $this->nearestCarInfo();
|
||||
$formatedInfo = 'Brak aut w promieniu ' . self::CLOSEST_DISTANCE . 'km od domu.';
|
||||
if ($info['car'] != []) {
|
||||
$formatedInfo = "Najbliższy traficar:\n" .
|
||||
'Model: ' . $info['car']['model'] . "\n" .
|
||||
'Numer boczny: ' . $info['car']['orderNumber'] . "\n" .
|
||||
'Rejestracja: ' . $info['car']['regNumber'] . "\n" .
|
||||
'Lokalizacja: ' . $info['car']['location'] . "\n" .
|
||||
'Odległość: ' . $info['distance'] . "km\n\n" .
|
||||
'Traficarów w promieniu ' . self::CLOSEST_DISTANCE . 'km: ' . $this->getTotalCarsInArea() . "\n";
|
||||
}
|
||||
return $formatedInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* pobiera informacje na temat aut traficatowych i zapisuje do pamięci
|
||||
* @return mixed
|
||||
*/
|
||||
private function getTraficarJson()
|
||||
{
|
||||
if (is_null($this->traficarJson)) {
|
||||
$this->traficarJson = json_decode(file_get_contents('https://api.traficar.pl/eaw-rest-api/car?shapeId=5'), 1);
|
||||
}
|
||||
return $this->traficarJson;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* zwraca ilość aut w podanym promieniu
|
||||
* @return int
|
||||
*/
|
||||
private function getTotalCarsInArea()
|
||||
{
|
||||
$trafcarData = $this->getTraficarJson();
|
||||
$numberOfCarsInArea = 0;
|
||||
foreach ($trafcarData['cars'] as $car) {
|
||||
$distance = $this->distance($this->homeCoords['lat'], $this->homeCoords['lng'], $car['latitude'], $car['longitude']);
|
||||
if ($distance < self::CLOSEST_DISTANCE) {
|
||||
$numberOfCarsInArea++;
|
||||
}
|
||||
}
|
||||
return $numberOfCarsInArea;
|
||||
}
|
||||
|
||||
public function nearestCarInfo()
|
||||
{
|
||||
$trafcarData = $this->getTraficarJson();
|
||||
$closestCar = [];
|
||||
$closestDistance = 1000;
|
||||
foreach ($trafcarData['cars'] as $car) {
|
||||
|
||||
$distance = $this->distance($this->homeCoords['lat'], $this->homeCoords['lng'], $car['latitude'], $car['longitude']);
|
||||
if ($distance < self::CLOSEST_DISTANCE && $distance < $closestDistance) {
|
||||
$closestDistance = $distance;
|
||||
$closestCar = $car;
|
||||
}
|
||||
}
|
||||
return ['car' => $closestCar, 'distance' => round($closestDistance, 2),];
|
||||
}
|
||||
}
|
||||
88
app/Paper/Vocabulary.php
Normal file
88
app/Paper/Vocabulary.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App\Paper;
|
||||
|
||||
use DiDom\Document;
|
||||
use DiDom\Query;
|
||||
|
||||
|
||||
class Vocabulary
|
||||
{
|
||||
|
||||
const URL = 'https://www.vocabulary.com/';
|
||||
const EXAMPLES_URL = 'https://corpus.vocabulary.com/api/1.0/';
|
||||
|
||||
|
||||
public function getWordData($word)
|
||||
{
|
||||
return new Document($this->getWordUrl($word), true);
|
||||
}
|
||||
|
||||
private function getWordUrl($word)
|
||||
{
|
||||
$word = trim($word);
|
||||
return self::URL . 'dictionary/definition.ajax?search=' . $word . '&lang=en';
|
||||
}
|
||||
|
||||
private function getWordExamplesUrl($word, $maxResult = 10, $offset = 0)
|
||||
{
|
||||
$word = trim($word);
|
||||
return sprintf('%sexamples.json?query=%s&maxResults=%d&startOffset=%d', self::EXAMPLES_URL, $word, $maxResult, $offset);
|
||||
}
|
||||
|
||||
public function getWord($word)
|
||||
{
|
||||
$document = $this->getWordData($word);
|
||||
|
||||
|
||||
$wordData = new \stdClass();
|
||||
$wordPageSelector = $document->first('.wordPage');
|
||||
$wordData->lang = $wordPageSelector->attr('data-lang');
|
||||
$wordData->word = $wordPageSelector->attr('data-word');
|
||||
$wordData->next = $wordPageSelector->attr('data-next');
|
||||
$wordData->prev = $wordPageSelector->attr('data-prev');
|
||||
$wordData->short = trim($document->first('p.short')->text());
|
||||
$wordData->long = trim($document->first('p.long')->text());
|
||||
|
||||
$wordData->instances = [];
|
||||
foreach ($document->find('.ordinal ') as $ordinal) {
|
||||
$definition = [];
|
||||
$definition['type'] = $ordinal->first('h3')->first('a')->attr('title');
|
||||
$definition['definition'] = trim($ordinal->first('//h3[@class="definition"][1]/text()[2]', Query::TYPE_XPATH));
|
||||
$definition['example'] = ($example = $ordinal->first('//div[@class="example"]', Query::TYPE_XPATH)) ? $example->text() : '';
|
||||
|
||||
foreach ($ordinal->find('.instances') as $instance) {
|
||||
$in = [];
|
||||
$in['type'] = str_replace(' ', '_', trim(strtolower($instance->first('dt::text()')), ': '));
|
||||
$in['words'] = $instance->find('dd a::text()');
|
||||
$in['definition'] = $instance->first('div.definition::text()');
|
||||
$definition[$in['type']] = $in;
|
||||
}
|
||||
|
||||
$wordData->instances[] = $definition;
|
||||
}
|
||||
$wordData->examples = $this->getExamples($word, 3);
|
||||
|
||||
|
||||
return $wordData;
|
||||
}
|
||||
|
||||
private function getRandomWordUrl()
|
||||
{
|
||||
return self::URL . 'randomword.json';
|
||||
}
|
||||
|
||||
public function getRandomWord()
|
||||
{
|
||||
$data = json_decode(file_get_contents($this->getRandomWordUrl()));
|
||||
if ($data->status != 0) {
|
||||
throw new Exception('error');
|
||||
}
|
||||
return $data->result->word;
|
||||
}
|
||||
|
||||
public function getExamples($word, $maxResult = 10, $offset = 0)
|
||||
{
|
||||
return json_decode(file_get_contents($this->getWordExamplesUrl($word, $maxResult, $offset)), 1);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"php": ">=5.6.4",
|
||||
"php": ">=7.0.0",
|
||||
"imangazaliev/didom": "^1.9",
|
||||
"intervention/image": "^2.3",
|
||||
"laravel/framework": "5.4.*",
|
||||
|
||||
@@ -12,7 +12,7 @@ return [
|
||||
| any other location as required by the application or its packages.
|
||||
*/
|
||||
|
||||
'name' => 'Laravel',
|
||||
'name' => 'Paper.Pi',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
@@ -64,7 +64,7 @@ return [
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
'timezone' => 'Europe/Warsaw',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
||||
@@ -35,7 +35,7 @@ return [
|
||||
|
||||
'sqlite' => [
|
||||
'driver' => 'sqlite',
|
||||
'database' => env('DB_DATABASE', database_path('database.sqlite')),
|
||||
'database' => database_path(env('DB_DATABASE','database.sqlite')),
|
||||
'prefix' => '',
|
||||
],
|
||||
|
||||
|
||||
@@ -11,5 +11,8 @@ return ['airly' =>
|
||||
[
|
||||
'api_key' => '8b6d77b2950e4e018b0684912bf7b9ed',
|
||||
'stations' => ['2210', '2256', '2180'],
|
||||
'rzeczypospolitej' => 2210,
|
||||
'grunwaldzka' => 2256,
|
||||
'sowinskiego' => 2180,
|
||||
]
|
||||
];
|
||||
|
||||
BIN
database/printer_example.db
Normal file
BIN
database/printer_example.db
Normal file
Binary file not shown.
140
public/css/app.css
vendored
140
public/css/app.css
vendored
@@ -20,6 +20,14 @@ textarea.content {
|
||||
|
||||
}
|
||||
|
||||
.note-title {
|
||||
line-height: 32px;
|
||||
}
|
||||
|
||||
h1.header span.icon.display-inline-block {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
form {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -28,6 +36,23 @@ form {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.flex {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.flex.space-between {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.flex.header {
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
.flex .header {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.icon {
|
||||
cursor: pointer;
|
||||
height: 25px;
|
||||
@@ -37,7 +62,7 @@ form {
|
||||
margin: 2px;
|
||||
}
|
||||
|
||||
.icon:hover {
|
||||
.icons .icon:hover {
|
||||
background-color: #1e90ff4d;
|
||||
}
|
||||
|
||||
@@ -55,342 +80,455 @@ form {
|
||||
height: 29px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.icon.address-card-o {
|
||||
background-position-x: -0px;
|
||||
}
|
||||
|
||||
.icon.anchor {
|
||||
background-position-x: -25px;
|
||||
}
|
||||
|
||||
.icon.archive-3 {
|
||||
background-position-x: -50px;
|
||||
}
|
||||
|
||||
.icon.at {
|
||||
background-position-x: -75px;
|
||||
}
|
||||
|
||||
.icon.balance-scale {
|
||||
background-position-x: -100px;
|
||||
}
|
||||
|
||||
.icon.ban {
|
||||
background-position-x: -125px;
|
||||
}
|
||||
|
||||
.icon.bar-chart-o {
|
||||
background-position-x: -150px;
|
||||
}
|
||||
|
||||
.icon.barcode {
|
||||
background-position-x: -175px;
|
||||
}
|
||||
|
||||
.icon.battery-empty {
|
||||
background-position-x: -200px;
|
||||
}
|
||||
|
||||
.icon.battery-full {
|
||||
background-position-x: -225px;
|
||||
}
|
||||
|
||||
.icon.battery-half {
|
||||
background-position-x: -250px;
|
||||
}
|
||||
|
||||
.icon.battery-quarter {
|
||||
background-position-x: -275px;
|
||||
}
|
||||
|
||||
.icon.battery-three-quarters {
|
||||
background-position-x: -300px;
|
||||
}
|
||||
|
||||
.icon.bed {
|
||||
background-position-x: -325px;
|
||||
}
|
||||
|
||||
.icon.beer {
|
||||
background-position-x: -350px;
|
||||
}
|
||||
|
||||
.icon.bell-o {
|
||||
background-position-x: -375px;
|
||||
}
|
||||
|
||||
.icon.bell-slash-o {
|
||||
background-position-x: -400px;
|
||||
}
|
||||
|
||||
.icon.bicycle {
|
||||
background-position-x: -425px;
|
||||
}
|
||||
|
||||
.icon.birthday-cake {
|
||||
background-position-x: -450px;
|
||||
}
|
||||
|
||||
.icon.bolt {
|
||||
background-position-x: -475px;
|
||||
}
|
||||
|
||||
.icon.bomb {
|
||||
background-position-x: -500px;
|
||||
}
|
||||
|
||||
.icon.book {
|
||||
background-position-x: -525px;
|
||||
}
|
||||
|
||||
.icon.bug {
|
||||
background-position-x: -550px;
|
||||
}
|
||||
|
||||
.icon.building-o {
|
||||
background-position-x: -575px;
|
||||
}
|
||||
|
||||
.icon.bullhorn {
|
||||
background-position-x: -600px;
|
||||
}
|
||||
|
||||
.icon.bus {
|
||||
background-position-x: -625px;
|
||||
}
|
||||
|
||||
.icon.camera {
|
||||
background-position-x: -650px;
|
||||
}
|
||||
|
||||
.icon.car {
|
||||
background-position-x: -675px;
|
||||
}
|
||||
|
||||
.icon.chain {
|
||||
background-position-x: -700px;
|
||||
}
|
||||
|
||||
.icon.chat-2 {
|
||||
background-position-x: -725px;
|
||||
}
|
||||
|
||||
.icon.check {
|
||||
background-position-x: -750px;
|
||||
}
|
||||
|
||||
.icon.cloud {
|
||||
background-position-x: -775px;
|
||||
}
|
||||
|
||||
.icon.code {
|
||||
background-position-x: -800px;
|
||||
}
|
||||
|
||||
.icon.coffee {
|
||||
background-position-x: -825px;
|
||||
}
|
||||
|
||||
.icon.cog {
|
||||
background-position-x: -850px;
|
||||
}
|
||||
|
||||
.icon.cutlery {
|
||||
background-position-x: -875px;
|
||||
}
|
||||
|
||||
.icon.dashboard {
|
||||
background-position-x: -900px;
|
||||
}
|
||||
|
||||
.icon.database {
|
||||
background-position-x: -925px;
|
||||
}
|
||||
|
||||
.icon.diamond {
|
||||
background-position-x: -950px;
|
||||
}
|
||||
|
||||
.icon.dollar {
|
||||
background-position-x: -975px;
|
||||
}
|
||||
|
||||
.icon.dribbble {
|
||||
background-position-x: -1000px;
|
||||
}
|
||||
|
||||
.icon.envelope-o {
|
||||
background-position-x: -1025px;
|
||||
}
|
||||
|
||||
.icon.envira {
|
||||
background-position-x: -1050px;
|
||||
}
|
||||
|
||||
.icon.exclamation-triangle {
|
||||
background-position-x: -1075px;
|
||||
}
|
||||
|
||||
.icon.female {
|
||||
background-position-x: -1100px;
|
||||
}
|
||||
|
||||
.icon.file-text-o {
|
||||
background-position-x: -1125px;
|
||||
}
|
||||
|
||||
.icon.film {
|
||||
background-position-x: -1150px;
|
||||
}
|
||||
|
||||
.icon.fingerprint {
|
||||
background-position-x: -1175px;
|
||||
}
|
||||
|
||||
.icon.fire-extinguisher {
|
||||
background-position-x: -1200px;
|
||||
}
|
||||
|
||||
.icon.fire {
|
||||
background-position-x: -1225px;
|
||||
}
|
||||
|
||||
.icon.flag-o {
|
||||
background-position-x: -1250px;
|
||||
}
|
||||
|
||||
.icon.flask {
|
||||
background-position-x: -1275px;
|
||||
}
|
||||
|
||||
.icon.floppy-o {
|
||||
background-position-x: -1300px;
|
||||
}
|
||||
|
||||
.icon.folder-o {
|
||||
background-position-x: -1325px;
|
||||
}
|
||||
|
||||
.icon.folder-open-o {
|
||||
background-position-x: -1350px;
|
||||
}
|
||||
|
||||
.icon.frown-o {
|
||||
background-position-x: -1375px;
|
||||
}
|
||||
|
||||
.icon.gamepad {
|
||||
background-position-x: -1400px;
|
||||
}
|
||||
|
||||
.icon.gift {
|
||||
background-position-x: -1425px;
|
||||
}
|
||||
|
||||
.icon.git {
|
||||
background-position-x: -1450px;
|
||||
}
|
||||
|
||||
.icon.glass {
|
||||
background-position-x: -1475px;
|
||||
}
|
||||
|
||||
.icon.graduation-cap {
|
||||
background-position-x: -1500px;
|
||||
}
|
||||
|
||||
.icon.grav {
|
||||
background-position-x: -1525px;
|
||||
}
|
||||
|
||||
.icon.group {
|
||||
background-position-x: -1550px;
|
||||
}
|
||||
|
||||
.icon.hand-o-left {
|
||||
background-position-x: -1575px;
|
||||
}
|
||||
|
||||
.icon.heart-o {
|
||||
background-position-x: -1600px;
|
||||
}
|
||||
|
||||
.icon.home {
|
||||
background-position-x: -1625px;
|
||||
}
|
||||
|
||||
.icon.lemon-o {
|
||||
background-position-x: -1650px;
|
||||
}
|
||||
|
||||
.icon.lightbulb-o {
|
||||
background-position-x: -1675px;
|
||||
}
|
||||
|
||||
.icon.list-alt {
|
||||
background-position-x: -1700px;
|
||||
}
|
||||
|
||||
.icon.location-arrow {
|
||||
background-position-x: -1725px;
|
||||
}
|
||||
|
||||
.icon.lock {
|
||||
background-position-x: -1750px;
|
||||
}
|
||||
|
||||
.icon.male {
|
||||
background-position-x: -1775px;
|
||||
}
|
||||
|
||||
.icon.map-1 {
|
||||
background-position-x: -1800px;
|
||||
}
|
||||
|
||||
.icon.map-marker {
|
||||
background-position-x: -1825px;
|
||||
}
|
||||
|
||||
.icon.microchip {
|
||||
background-position-x: -1850px;
|
||||
}
|
||||
|
||||
.icon.money {
|
||||
background-position-x: -1875px;
|
||||
}
|
||||
|
||||
.icon.moon-o {
|
||||
background-position-x: -1900px;
|
||||
}
|
||||
|
||||
.icon.music {
|
||||
background-position-x: -1925px;
|
||||
}
|
||||
|
||||
.icon.paper-plane {
|
||||
background-position-x: -1950px;
|
||||
}
|
||||
|
||||
.icon.paperclip {
|
||||
background-position-x: -1975px;
|
||||
}
|
||||
|
||||
.icon.paw {
|
||||
background-position-x: -2000px;
|
||||
}
|
||||
|
||||
.icon.pencil {
|
||||
background-position-x: -2025px;
|
||||
}
|
||||
|
||||
.icon.phone {
|
||||
background-position-x: -2050px;
|
||||
}
|
||||
|
||||
.icon.pie-chart {
|
||||
background-position-x: -2075px;
|
||||
}
|
||||
|
||||
.icon.piggy-bank {
|
||||
background-position-x: -2100px;
|
||||
}
|
||||
|
||||
.icon.plane {
|
||||
background-position-x: -2125px;
|
||||
}
|
||||
|
||||
.icon.question-circle-o {
|
||||
background-position-x: -2150px;
|
||||
}
|
||||
|
||||
.icon.rocket {
|
||||
background-position-x: -2175px;
|
||||
}
|
||||
|
||||
.icon.search {
|
||||
background-position-x: -2200px;
|
||||
}
|
||||
|
||||
.icon.ship {
|
||||
background-position-x: -2225px;
|
||||
}
|
||||
|
||||
.icon.shopping-cart {
|
||||
background-position-x: -2250px;
|
||||
}
|
||||
|
||||
.icon.smile-o {
|
||||
background-position-x: -2275px;
|
||||
}
|
||||
|
||||
.icon.snowflake-o {
|
||||
background-position-x: -2300px;
|
||||
}
|
||||
|
||||
.icon.steam {
|
||||
background-position-x: -2325px;
|
||||
}
|
||||
|
||||
.icon.subway {
|
||||
background-position-x: -2350px;
|
||||
}
|
||||
|
||||
.icon.success {
|
||||
background-position-x: -2375px;
|
||||
}
|
||||
|
||||
.icon.support {
|
||||
background-position-x: -2400px;
|
||||
}
|
||||
|
||||
.icon.thermometer-2 {
|
||||
background-position-x: -2425px;
|
||||
}
|
||||
|
||||
.icon.thumbs-o-down {
|
||||
background-position-x: -2450px;
|
||||
}
|
||||
|
||||
.icon.thumbs-o-up {
|
||||
background-position-x: -2475px;
|
||||
}
|
||||
|
||||
.icon.ticket {
|
||||
background-position-x: -2500px;
|
||||
}
|
||||
|
||||
.icon.times {
|
||||
background-position-x: -2525px;
|
||||
}
|
||||
|
||||
.icon.trash-o {
|
||||
background-position-x: -2550px;
|
||||
}
|
||||
|
||||
.icon.tree {
|
||||
background-position-x: -2575px;
|
||||
}
|
||||
|
||||
.icon.trophy {
|
||||
background-position-x: -2600px;
|
||||
}
|
||||
|
||||
.icon.truck {
|
||||
background-position-x: -2625px;
|
||||
}
|
||||
|
||||
.icon.umbrella {
|
||||
background-position-x: -2650px;
|
||||
}
|
||||
|
||||
.icon.usd {
|
||||
background-position-x: -2675px;
|
||||
}
|
||||
|
||||
.icon.warning {
|
||||
background-position-x: -2700px;
|
||||
}
|
||||
|
||||
.icon.wifi {
|
||||
background-position-x: -2725px;
|
||||
}
|
||||
|
||||
.icon.wpexplorer {
|
||||
background-position-x: -2750px;
|
||||
}
|
||||
|
||||
.icon.wrench {
|
||||
background-position-x: -2775px;
|
||||
}
|
||||
|
||||
.icon.youtube-play {
|
||||
background-position-x: -2800px;
|
||||
}
|
||||
BIN
public/icons/icon-128.png
Normal file
BIN
public/icons/icon-128.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
BIN
public/icons/icon-16.png
Normal file
BIN
public/icons/icon-16.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 544 B |
BIN
public/icons/icon-256.png
Normal file
BIN
public/icons/icon-256.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
public/icons/icon-32.png
Normal file
BIN
public/icons/icon-32.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
public/icons/icon-512.png
Normal file
BIN
public/icons/icon-512.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
BIN
public/icons/icon-64.png
Normal file
BIN
public/icons/icon-64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.5 KiB |
@@ -1,4 +1,4 @@
|
||||
var content, preview, selfPrinter;
|
||||
var content, title, preview, selfPrinter;
|
||||
var Printer = function () {
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ var Printer = function () {
|
||||
this.delete = document.querySelector('.js-delete');
|
||||
|
||||
content = this.content = document.querySelector('.js-content');
|
||||
title = this.title = document.querySelector('input[name="title"]');
|
||||
|
||||
|
||||
selfPrinter = this;
|
||||
@@ -21,7 +22,7 @@ var Printer = function () {
|
||||
this.delete.addEventListener('click', this.confirmDelete);
|
||||
}
|
||||
|
||||
document.querySelectorAll('.icon').forEach(function (e) {
|
||||
document.querySelectorAll('.icons .icon').forEach(function (e) {
|
||||
e.addEventListener('click', function () {
|
||||
selfPrinter.selectIcon(this.title);
|
||||
});
|
||||
@@ -32,7 +33,7 @@ var Printer = function () {
|
||||
/**
|
||||
* resetuje wybór ikony
|
||||
*/
|
||||
this.selectIcon = function(iconTitle){
|
||||
this.selectIcon = function (iconTitle) {
|
||||
document.querySelectorAll('.icon').forEach(function (e, i) {
|
||||
e.classList.remove('selected');
|
||||
});
|
||||
@@ -42,7 +43,7 @@ var Printer = function () {
|
||||
};
|
||||
|
||||
this.restoreContentHeight = function () {
|
||||
if(!!localStorage.getItem('contentHeight')){
|
||||
if (!!localStorage.getItem('contentHeight')) {
|
||||
document.querySelector('.js-content').style.height = localStorage.getItem('contentHeight')
|
||||
}
|
||||
};
|
||||
@@ -56,6 +57,7 @@ var Printer = function () {
|
||||
};
|
||||
|
||||
this.clear = function () {
|
||||
selfPrinter.title.value = '';
|
||||
selfPrinter.content.innerHTML = '';
|
||||
selfPrinter.selectIcon('empty');
|
||||
};
|
||||
|
||||
34
public/manifest.json
Normal file
34
public/manifest.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name": "PaperPi",
|
||||
"short_name": "PaperPi",
|
||||
"start_url": ".",
|
||||
"display": "standalone",
|
||||
"background_color": "#277dd1",
|
||||
"description": "Raspberry Pi printer webapp",
|
||||
"orientation": "portrait",
|
||||
"icons": [{
|
||||
"src": "/icon-16.png",
|
||||
"sizes": "16x16",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/icon-32.png",
|
||||
"sizes": "32x32",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/icon-64.png",
|
||||
"sizes": "64x64",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/icon-128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/icon-256.png",
|
||||
"sizes": "256x256",
|
||||
"type": "image/png"
|
||||
}, {
|
||||
"src": "/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
}]
|
||||
}
|
||||
@@ -1,11 +1,22 @@
|
||||
@extends('layouts.base')
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
body .column .ui.form textarea:not([rows]) {max-height: inherit; height: 20em}
|
||||
|
||||
</style>
|
||||
<style>
|
||||
body .column .ui.form textarea:not([rows]) {
|
||||
max-height: inherit;
|
||||
height: 20em
|
||||
}
|
||||
|
||||
</style>
|
||||
<div class="ui container">
|
||||
@if(Session::has('print_status'))
|
||||
<div class="ui info message">
|
||||
<div class="header">
|
||||
{{ Session::get('print_status') }}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="ui one column middle aligned stackable grid">
|
||||
<div class="ui column">
|
||||
@if($type == 'template')
|
||||
@@ -13,8 +24,8 @@
|
||||
@else
|
||||
<h2><a href="/">Lista</a> » Edycja notatki</h2>
|
||||
@endif
|
||||
@include('form.create')
|
||||
<br><br>
|
||||
@include('form.create')
|
||||
<br><br>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -12,17 +12,11 @@
|
||||
name="text">{{ $text }}</textarea>
|
||||
<input type="hidden" name="icon" id="icon" value="{{ $icon_selected }}"/>
|
||||
<div class="icons">
|
||||
|
||||
|
||||
|
||||
<span class="icon @if(!isset($icon_selected) ) selected @endif empty" title="empty"></span>
|
||||
@foreach ($icons as $icon)<span
|
||||
class="icon {{ str_before($icon, '.') }} @if(isset($icon_selected) && $icon == basename($icon_selected)) selected @endif " title="{{ $icon }}">
|
||||
class="icon {{ str_before($icon, '.') }} @if(isset($icon_selected) && $icon == basename($icon_selected)) selected @endif "
|
||||
title="{{ $icon }}">
|
||||
</span>@endforeach
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -38,9 +32,12 @@
|
||||
<button class="ui reset button js-reset" type="reset">Wyczyść</button>
|
||||
@if(isset($id))
|
||||
<button class="ui delete button js-delete red" type="submit" name="delete">Usuń</button>
|
||||
|
||||
|
||||
@endif
|
||||
|
||||
<div class="ui @if(isset($private) && $private == 1) checked @endif checkbox">
|
||||
<input name="private" id="private" @if(isset($private) && $private == 1) checked="checked" @endif value="1" type="checkbox">
|
||||
<label for="private">Prywatna notatka</label>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,10 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.slim.min.js"></script>
|
||||
<script src="/js/semantic.min.js"></script>
|
||||
<script src="/js/printer.js"></script>
|
||||
|
||||
<link rel="shortcut" type="image/png" href="/icon-16.png"/>
|
||||
<link rel="icon" type="image/png" href="/icon-256.png" />
|
||||
<meta name="mobile-web-app-capable" content="yes">
|
||||
<link rel="manifest" href="/manifest.json">
|
||||
</head>
|
||||
<body>
|
||||
<div class="">
|
||||
|
||||
@@ -12,8 +12,10 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<h1 class="ui header">Szybka notatka</h1>
|
||||
|
||||
<div class="flex header space-between">
|
||||
<h1 class="ui header">Szybka notatka</h1>
|
||||
<a class="ui right floated" href="/settings">Ustawienia</a>
|
||||
</div>
|
||||
<div class="ui container">
|
||||
<div class="ui one column middle aligned stackable grid">
|
||||
<div class="ui column">
|
||||
@@ -45,23 +47,28 @@
|
||||
|
||||
</div>
|
||||
<div class="ui container">
|
||||
<h1 class="ui header">Lista notatek</h1>
|
||||
<h1 class="ui header"> @if(isset($filter)) <a href="/">Lista notatek</a> z ikonką <span
|
||||
class="icon {{ $filter }} display-inline-block"></span>@else Lista notatek @endif</h1>
|
||||
<div class="ui middle aligned divided list">
|
||||
|
||||
@foreach($notes as $note)
|
||||
<div class="item">
|
||||
<div class="right floated content">
|
||||
<form method="post" action="/print/{{ $note->id }}">
|
||||
{{ csrf_field() }}
|
||||
<button type="primary" class="ui tiny button primary">Drukuj</button>
|
||||
</form>
|
||||
@if($note->private != 1 || substr($_SERVER['REMOTE_ADDR'],0,9) == '192.168.0')
|
||||
<div class="item">
|
||||
<div class="left floated content">
|
||||
<a href="/filter/{{ $note->icon }}" class="left floated"><span
|
||||
class="icon @if($note->icon){{ $note->icon }} @else empty @endif "
|
||||
title="{{ $note->icon }}"></span></a><a class="note-title"
|
||||
href="/edit/{{ $note->id }}/{{ $note->topic_slug?$note->topic_slug:str_limit($note->text, 30, '...') }}">{{ $note->topic?$note->topic:str_limit($note->text, 30, '...') }}
|
||||
</a>
|
||||
</div>
|
||||
<div class="right floated content">
|
||||
<form method="post" action="/print/{{ $note->id }}">
|
||||
{{ csrf_field() }}
|
||||
<button type="primary" class="ui tiny button primary">Drukuj</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<a href="/edit/{{ $note->id }}/{{ $note->topic_slug?$note->topic_slug:str_limit($note->text, 30, '...') }}"><span
|
||||
class="icon {{ $note->icon }} "
|
||||
title="{{ $note->icon }}"></span>{{ $note->topic?$note->topic:str_limit($note->text, 30, '...') }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
@endforeach
|
||||
</div>
|
||||
<h1 class="ui header">Szablony notatek</h1>
|
||||
|
||||
54
resources/views/settings.blade.php
Normal file
54
resources/views/settings.blade.php
Normal file
@@ -0,0 +1,54 @@
|
||||
@extends('layouts.base')
|
||||
|
||||
|
||||
|
||||
@section('content')
|
||||
<div class="ui container">
|
||||
@if(Session::has('print_status'))
|
||||
<div class="ui info message">
|
||||
<div class="header">
|
||||
{{ Session::get('print_status') }}
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="flex header space-between">
|
||||
<h1 class="ui header">Ustawienia</h1>
|
||||
<a class="ui right floated" href="/">Notatki</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="ui container">
|
||||
|
||||
<h3 class="ui header">Przypisanie klawiszy</h3>
|
||||
|
||||
<form class="ui form" method="POST">
|
||||
{{ csrf_field() }}
|
||||
@foreach($keyboard as $element)
|
||||
<div class="inline fields">
|
||||
<div class="three wide field">
|
||||
Klawisz: {{ $element->key }}
|
||||
</div>
|
||||
<div class="left floated content">
|
||||
<div class="field">
|
||||
Akcja:
|
||||
<select class="ui" name="key[{{ $element->id }}]">
|
||||
@foreach($actions as $actionKey => $action)
|
||||
@if($action == 'separator')
|
||||
<optgroup label=""></optgroup>
|
||||
@else
|
||||
<option @if($element->action == $actionKey)selected="selected"
|
||||
@endif
|
||||
value="{{ $actionKey }}">{{ $action }}</optionvalue>
|
||||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
<button class="ui blue button" type="submit">Zapisz</button>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@@ -12,18 +12,22 @@
|
||||
*/
|
||||
|
||||
Route::get('/', 'Main@listView')->name('list');
|
||||
Route::get('/filter/{icon?}', 'Main@filterView');
|
||||
Route::get('/settings', 'Settings@mainView')->name('settingsList');
|
||||
Route::post('/settings', 'Settings@save');
|
||||
//Route::post('/', 'Main@listView');
|
||||
Route::get('/edit/{id}/{slug}', 'Main@edit')->name('edit');
|
||||
Route::get('/edit/{id}/{slug?}', 'Main@edit')->name('edit');
|
||||
Route::post('/print/{id}/', 'Main@printText')->name('print');
|
||||
Route::post('/edit/{id}/{slug}', 'Main@edit');
|
||||
Route::post('/edit/{id}/{slug?}', 'Main@edit');
|
||||
|
||||
Route::post('/sms', 'Plivo@recieveSms');
|
||||
|
||||
Route::post('/printImage', 'Main@imagePrint');
|
||||
|
||||
Route::post('/', 'Main@main');
|
||||
|
||||
|
||||
Route::get('/airly', 'Main@airly');
|
||||
Route::get('/airly', 'AirlyController@airly_all');
|
||||
|
||||
|
||||
|
||||
|
||||
71
tests/Unit/VocabularyTest.php
Normal file
71
tests/Unit/VocabularyTest.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use App\Paper\Vocabulary;
|
||||
use Tests\TestCase;
|
||||
|
||||
class VocabularyTest extends TestCase
|
||||
{
|
||||
|
||||
public function testGetExistingWordData()
|
||||
{
|
||||
$voc = new Vocabulary();
|
||||
$data = $voc->getWordData('random');
|
||||
$this->assertNotEmpty($data);
|
||||
$element = $data->find('.wordPage[data-word="random"]');
|
||||
$this->assertCount(1, $element);
|
||||
}
|
||||
|
||||
public function testGetNonExistingWordData()
|
||||
{
|
||||
$nonExistingWord = time();
|
||||
$voc = new Vocabulary();
|
||||
$data = $voc->getWordData($nonExistingWord);
|
||||
$this->assertNotEmpty($data);
|
||||
$element = $data->find('.wordPage[data-word="random"]');
|
||||
$this->assertCount(0, $element);
|
||||
|
||||
$elementNotFound = $data->find('.noresults[data-search="' . $nonExistingWord . '"]');
|
||||
$this->assertCount(1, $elementNotFound);
|
||||
}
|
||||
|
||||
public function testGetExistingWord()
|
||||
{
|
||||
$dummyWord = 'dummy';
|
||||
$vot = new Vocabulary();
|
||||
$word = $vot->getWord($dummyWord);
|
||||
|
||||
$this->assertEquals('en', $word->lang);
|
||||
$this->assertEquals('dummy', $word->word);
|
||||
$this->assertEquals('dump', $word->next);
|
||||
$this->assertEquals('dumbstruck', $word->prev);
|
||||
$this->assertEquals('Have you ever seen an entertainer make a doll look like it’s talking? The entertainer is using a dummy — a doll made to look like a person.', $word->short);
|
||||
$this->assertEquals("A dummy is a type of doll that looks like a person. Entertainers called ventriloquists can make dummies appear to talk. The automobile industry uses dummies in cars to study how safe cars are during a crash. A dummy can also be anything that looks real but doesn’t work: a fake. Actors in a play might use certain props that are dummies, such as a dummy laptop. Dummy is also an insult used to mean “an ignorant person.”", $word->long);
|
||||
|
||||
}
|
||||
|
||||
public function testGetRandomWord()
|
||||
{
|
||||
$vot = new Vocabulary();
|
||||
$word = $vot->getRandomWord();
|
||||
$this->assertNotNull($word);
|
||||
}
|
||||
|
||||
public function testGetRandomWordData()
|
||||
{
|
||||
$vot = new Vocabulary();
|
||||
$word = $vot->getRandomWord();
|
||||
$this->assertNotNull($word);
|
||||
|
||||
$wordData = $vot->getWord($word);
|
||||
|
||||
$this->assertEquals('en', $wordData->lang);
|
||||
$this->assertNotEmpty($wordData->word);
|
||||
$this->assertNotEmpty($wordData->next);
|
||||
$this->assertNotEmpty($wordData->prev);
|
||||
$this->assertNotEmpty($wordData->short);
|
||||
$this->assertNotEmpty($wordData->long);
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user