Compare commits

58 Commits

Author SHA1 Message Date
ba3f2e954a Merge branch 'issue-65' of krzysiej/paper-pi into master 2018-10-26 08:58:18 +02:00
kplaczek
fbffeec3a3 Added way to recieve text messages and printing them. 2018-10-26 08:13:01 +02:00
817b573258 Merge branch 'issue-57' of krzysiej/paper-pi into master 2018-10-04 22:41:06 +02:00
kplaczek
d08bdc0893 Fixed save note without a title. 2018-10-04 22:40:22 +02:00
b052fa50db Merge branch 'issue-pi-8' of krzysiej/paper-pi into master 2018-10-04 22:35:10 +02:00
kplaczek
efad44ea57 Added database example. Modified place for a database to be database folder. 2018-10-04 18:58:11 +02:00
23f3d647e0 Merge branch 'issue-59' of krzysiej/paper-pi into master 2018-09-28 10:29:11 +02:00
kplaczek
954cadd874 Fix previous commit. Now it works as intended and not always hiding private notes. 2018-09-28 10:27:00 +02:00
2b33c35049 Merge branch 'issue-59' of krzysiej/paper-pi into master 2018-09-19 20:05:47 +02:00
kplaczek
fcfc0bd58a Add checkbox to set note as private. When note is private then no one can see them from non local network. 2018-09-19 20:04:35 +02:00
31e65c4730 Merge branch 'issue-28' of krzysiej/paper-pi into master 2018-08-19 10:08:27 +02:00
kplaczek
6fb933a86c Saveing data after each print, saved or quick note. Increased trafficar radius to 2,5km from 2km. 2018-08-19 10:06:34 +02:00
e76edbb531 Merge branch 'issue-45' of krzysiej/paper-pi into master 2018-08-16 22:08:43 +02:00
kplaczek
081aa0f7a4 Print status after printing single note. 2018-08-16 22:07:59 +02:00
0afea8ead6 Merge branch 'issue-53' of krzysiej/paper-pi into master 2018-08-15 19:14:23 +02:00
kplaczek
41b7d5778d Added information about available traficars in a given area to printed info. 2018-08-15 19:12:53 +02:00
kplaczek
cee945f561 Merge branch 'master' of https://git.pi.techtube.pl/krzysiej/paper-pi 2018-08-12 12:36:06 +02:00
f806edb7b3 Merge branch 'issue-37' of krzysiej/paper-pi into master 2018-08-12 12:35:38 +02:00
kplaczek
76ae18e82a Merge remote-tracking branch 'origin/master' 2018-08-12 12:24:55 +02:00
kplaczek
23220819d5 Fixed printing informations about nearest traficar car. Increased size of printed image from 300 to 370px. 2018-08-12 12:21:16 +02:00
a839befc41 Merge branch 'issue-49' of krzysiej/paper-pi into master 2018-07-29 17:13:20 +02:00
kplaczek
7a5e7a5d9d Breaking up text to 32 character length on space. 2018-07-29 17:05:26 +02:00
611628c753 Merge branch 'issue-46' of krzysiej/paper-pi into master 2018-07-16 18:12:57 +02:00
kplaczek
4fdd43dc4e Bug where everytime before printing paper would gram word from vocabulary, not just when there is a shortcode in a content. 2018-07-16 18:11:46 +02:00
5512990704 Merge branch 'issue-32' of krzysiej/paper-pi into master 2018-07-08 12:53:43 +02:00
kplaczek
9187702634 Removed duplicate favicon line. 2018-07-08 12:52:44 +02:00
kplaczek
4b2dedc8f2 Added favicons, manifest,json and bunch of various size icons. 2018-07-08 12:10:16 +02:00
a3e8c19795 Merge branch 'issue-26' of krzysiej/paper-pi into master 2018-07-05 08:40:36 +02:00
kplaczek
178853874f Added route phpdoc 2018-07-05 08:39:19 +02:00
kplaczek
0b3d25d013 Clicking on icon next to note title will filter list to notes that has been assigned with clicked icon. 2018-07-05 08:37:52 +02:00
42c61feff8 Merge branch 'issue-37' of krzysiej/paper-pi into master 2018-07-04 20:59:27 +02:00
kplaczek
b4aa26ee17 Nearest traficar inforations. 2018-07-04 20:57:28 +02:00
bfe04f94ca Merge branch 'issue-35' of krzysiej/paper-pi into master 2018-06-21 22:29:43 +02:00
kplaczek
5d75992372 Proper form reseting after printing. 2018-06-21 22:23:49 +02:00
dcbb7e21f3 Merge branch 'issue-30' of krzysiej/paper-pi into master 2018-06-11 08:58:05 +02:00
kplaczek
db3f7772a6 Added tests to vocabulary and ability to print by key press 2018-05-18 21:47:43 +02:00
625193e99e Merge branch 'issue-23' of krzysiej/paper-pi into master 2018-05-13 12:09:26 +02:00
0df6753bd2 Merge branch 'issue-25' of krzysiej/paper-pi into master 2018-05-06 21:04:22 +02:00
kplaczek
e5f44b92e4 Printing data on numpad key press, first version. Settings page for mapping key to actions. 2018-05-06 21:03:42 +02:00
kplaczek
283c5b905e Fixed issue with selecting iocns by clicking icon next to saved note title. 2018-04-28 00:03:54 +02:00
de000d0403 Merge branch 'issue-21' of krzysiej/paper-pi into master 2018-04-22 18:46:11 +02:00
kplaczek
2f55d8491a Fixed bug with displaying icon for the notes without one set. 2018-04-22 18:45:19 +02:00
6f29248e8b Merge branch 'issue-19' of krzysiej/paper-pi into master 2018-04-22 00:04:23 +02:00
kplaczek
817479415f fixed issue with wrong array indexes 2018-04-21 13:27:58 +02:00
b0ba390cb5 Merge branch 'issue-14' of krzysiej/paper-pi into master 2018-04-19 23:31:05 +02:00
kplaczek
9f3c5a1487 Fixed regex 2018-04-19 23:30:27 +02:00
b66e08bc5b Merge branch 'issue-10' of krzysiej/paper-pi into master 2018-04-19 23:10:16 +02:00
kplaczek
f82fbd0e5a replaced random function with mt_random 2018-04-19 23:09:34 +02:00
556e7adfab Merge branch 'issue-14' of krzysiej/paper-pi into master 2018-04-19 23:07:03 +02:00
kplaczek
ec776f837e Merge remote-tracking branch 'origin/master'
# Conflicts:
#	app/Paper/HtmlToPos.php
2018-04-19 23:04:55 +02:00
kplaczek
2a242ff7ed Removes before printing lines with ! or # as a leading characer even after some space characters in front. 2018-04-19 23:01:12 +02:00
fbac17281a Merge branch 'issue-14' of krzysiej/paper-pi into master 2018-04-19 23:00:44 +02:00
kplaczek
501a64e0c7 Removes before printing lines with ! or # as a leading characer even after some space characters in front. 2018-04-19 22:59:47 +02:00
b68bf4b2e1 Merge branch 'issue-10' of krzysiej/paper-pi into master 2018-04-17 18:01:34 +02:00
kplaczek
680e52e2b4 Added a way to check if there is a [ number, number2 ] in a text and then replace that with a random number from that range. 2018-04-17 18:00:06 +02:00
kplaczek
7be360c01d Fixed typo. 2018-04-16 17:22:21 +02:00
kplaczek
8e181ec4c6 Added a paper config file with airly settings, fixed some minor issues with airly data not being printed. 2018-04-15 20:09:08 +02:00
1f1743adc2 Merge branch 'issue-7' of krzysiej/paper-pi into master 2018-04-15 15:44:19 +02:00
35 changed files with 1137 additions and 113 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@
Homestead.json Homestead.json
Homestead.yaml Homestead.yaml
.env .env
database/printer.db

View 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();
}
}

View File

@@ -2,25 +2,125 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Paper\CinemaMultikino;
use DiDom\Query;
use Illuminate\Http\Request;
use DiDom\Document;
use App\Paper\Paper; use App\Paper\Paper;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Keyboard extends Controller class Keyboard extends Controller
{ {
public function press(Request $request, $key)
private $paper;
public function __construct()
{ {
$this->paper = new Paper();
}
public function press($key) $keyboardData = DB::table('keyboard')->where('key', $key)->first();
{
$this->paper->sendPrint($key); if (isset($keyboardData) && isset($keyboardData->action)) {
$keyboardAction = explode('_', $keyboardData->action);
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;
}
}
} }
} }

View File

@@ -9,11 +9,8 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
set_time_limit(-1); set_time_limit(-1);
use App\Paper\Airly;
use App\Paper\Paper; use App\Paper\Paper;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Mike42\Escpos\PrintConnectors\FilePrintConnector;
use Mike42\Escpos\Printer;
use Intervention\Image\ImageManagerStatic as Image; use Intervention\Image\ImageManagerStatic as Image;
use Mike42\Escpos\EscposImage; use Mike42\Escpos\EscposImage;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -34,6 +31,7 @@ class Main extends Controller
* post::/printImage * post::/printImage
* @param Request $request * @param Request $request
* @return \Illuminate\Http\RedirectResponse * @return \Illuminate\Http\RedirectResponse
* @throws \Exception
*/ */
public function imagePrint(Request $request) public function imagePrint(Request $request)
{ {
@@ -51,7 +49,7 @@ class Main extends Controller
$image = $image->greyscale() $image = $image->greyscale()
->resize(300, null, function ($constraint) { ->resize(370, null, function ($constraint) {
$constraint->aspectRatio(); $constraint->aspectRatio();
$constraint->upsize(); $constraint->upsize();
}); });
@@ -108,13 +106,10 @@ class Main extends Controller
// Header("Content-type: image/png"); // Header("Content-type: image/png");
imagepng($output, $fileName, 9); //to print to screen imagepng($output, $fileName, 9); //to print to screen
$connector = new FilePrintConnector("/dev/usb/lp0");
$printer = new Printer($connector);
$img = EscposImage::load($fileName, false); $img = EscposImage::load($fileName, false);
$printer->bitImage($img); $this->paper->getPrinter()->bitImage($img);
$printer->feed(4); $this->paper->getPrinter()->feed(4);
return back(); return back();
} }
@@ -139,23 +134,30 @@ class Main extends Controller
} }
/** /**
* get:/airly * get:/filte/{$filter?}
* @param Request $request * @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(); $notes = DB::select('SELECT *, CASE WHEN icon IS NULL
$this->paper->sendImagePrint('cloud.png'); THEN \'empty\'
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y')); ELSE icon
foreach ($airly->getStations() as $stationId) { END AS new_icon FROM note WHERE type = "note" AND new_icon = :icon ORDER BY updated_at DESC', ['icon' => $filter]);
$stationInfo = $airly->getStationInfo($stationId); $templates = DB::select('SELECT *, CASE WHEN icon IS NULL
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']); THEN \'empty\'
$dataText = $airly->getInformationText($stationId); ELSE icon
$this->paper->sendPrint('', $dataText); END AS new_icon FROM note WHERE type = "template" AND new_icon = :icon ORDER BY updated_at DESC', ['icon' => $filter]);
} return view('list', [
return back(); 'filter' => $filter,
'notes' => $notes,
'templates' => $templates,
'title' => $request->old('title'),
'text' => $request->old('text'),
'icon_selected' => $request->old('icon'),
'icons' => $this->paper->getIcons()
]);
} }
/** /**
@@ -166,15 +168,26 @@ class Main extends Controller
*/ */
public function printText(Request $request, $id) public function printText(Request $request, $id)
{ {
$note = DB::table('note')->where('id', $id)->first(); $note = $this->printNote($id);
$this->paper->sendPrint($note->topic, $note->text, $note->icon);
$request->session()->flash('print_status', 'Wydrukowano notatkę: ' . $note->topic . '!'); $request->session()->flash('print_status', 'Wydrukowano notatkę: ' . $note->topic . '!');
return back(); 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) private function templateReplace($input)
{ {
return str_replace(['[d]', '[m]', '[y]', '[h]', '[i]', '[s]'], return str_replace(['[d]', '[m]', '[y]', '[h]', '[i]', '[s]'],
[date('d'), date('m'), date('Y'), date('H'), date('i'), date('s')], [date('d'), date('m'), date('Y'), date('H'), date('i'), date('s')],
$input); $input);
@@ -189,7 +202,7 @@ class Main extends Controller
* @param $slug * @param $slug
* @return \Illuminate\Contracts\View\Factory|\Illuminate\Http\RedirectResponse|\Illuminate\View\View * @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(); $note = DB::table('note')->where('id', $id)->first();
if ($request->isMethod('post')) { if ($request->isMethod('post')) {
@@ -203,11 +216,13 @@ class Main extends Controller
'text' => $this->templateReplace($request->input('text')), 'text' => $this->templateReplace($request->input('text')),
'icon' => $request->input('icon'), 'icon' => $request->input('icon'),
'type' => self::NOTE, 'type' => self::NOTE,
'private' => $request->input('private', 0),
'created_at' => time(), 'created_at' => time(),
'updated_at' => time() 'updated_at' => time()
]); ]);
$note = DB::table('note')->where('id', $id)->first(); $note = DB::table('note')->where('id', $id)->first();
} else { } else {
DB::table('note') DB::table('note')
->where('id', $note->id) ->where('id', $note->id)
->update([ ->update([
@@ -215,6 +230,7 @@ class Main extends Controller
'topic_slug' => str_slug($request->input('title'), '_'), 'topic_slug' => str_slug($request->input('title'), '_'),
'text' => $request->input('text'), 'text' => $request->input('text'),
'icon' => $request->input('icon'), 'icon' => $request->input('icon'),
'private' => $request->input('private',0),
'updated_at' => time(), 'updated_at' => time(),
]); ]);
} }
@@ -225,6 +241,7 @@ class Main extends Controller
return redirect()->route('list'); return redirect()->route('list');
} elseif ($request->exists('print')) { } elseif ($request->exists('print')) {
$this->paper->sendPrint($request->input('title'), $request->input('text'), $request->input('icon')); $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]); return redirect()->route('edit', ['id' => $note->id, 'slug' => $note->topic_slug]);
} else { } else {
@@ -233,6 +250,7 @@ class Main extends Controller
'text' => $note->text, 'text' => $note->text,
'icon_selected' => $note->icon, 'icon_selected' => $note->icon,
'type' => $note->type, 'type' => $note->type,
'private' => $note->private,
'id' => $note->id, 'id' => $note->id,
'icons' => $this->paper->getIcons(), 'icons' => $this->paper->getIcons(),
'topic_slug' => $note->topic_slug, 'topic_slug' => $note->topic_slug,
@@ -256,6 +274,7 @@ class Main extends Controller
'text' => $request->input('text'), 'text' => $request->input('text'),
'icon' => $request->input('icon'), 'icon' => $request->input('icon'),
'type' => self::NOTE, 'type' => self::NOTE,
'private' => $request->input('private',0),
'created_at' => time(), 'created_at' => time(),
'updated_at' => time() 'updated_at' => time()
]); ]);
@@ -269,6 +288,7 @@ class Main extends Controller
'text' => $request->input('text'), 'text' => $request->input('text'),
'icon' => $request->input('icon'), 'icon' => $request->input('icon'),
'type' => self::TEMPLATE, 'type' => self::TEMPLATE,
'private' => $request->input('private',0),
'created_at' => time(), 'created_at' => time(),
'updated_at' => time() 'updated_at' => time()
]); ]);

View 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');
}
}
}

View File

@@ -28,7 +28,7 @@ class Repertoire extends Controller
$cinemacity->setDay(date('Y-m-d')); $cinemacity->setDay(date('Y-m-d'));
$repertuarText = $cinemacity->convertToPrint(); $repertuarText = $cinemacity->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar CinemaCity na dzisiaj!'); $request->session()->flash('print_status', 'Wydrukowano repertuar CinemaCity na dzisiaj!');
return back(); return back();
@@ -42,7 +42,7 @@ class Repertoire extends Controller
$cinemacity->setDay(date_create()->modify('+1 day')->format('Y-m-d')); $cinemacity->setDay(date_create()->modify('+1 day')->format('Y-m-d'));
$repertuarText = $cinemacity->convertToPrint(); $repertuarText = $cinemacity->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar CinemaCity na jutro!'); $request->session()->flash('print_status', 'Wydrukowano repertuar CinemaCity na jutro!');
return back(); return back();
@@ -57,7 +57,7 @@ class Repertoire extends Controller
$multikino->setDay(date('Y-m-d')); $multikino->setDay(date('Y-m-d'));
$repertuarText = $multikino->convertToPrint(); $repertuarText = $multikino->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar Multikina na dzisiaj!'); $request->session()->flash('print_status', 'Wydrukowano repertuar Multikina na dzisiaj!');
return back(); return back();
@@ -70,7 +70,7 @@ class Repertoire extends Controller
$multikino->setCinemaId(4); $multikino->setCinemaId(4);
$repertuarText = $multikino->convertToPrint(); $repertuarText = $multikino->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar Multikina na jutro!'); $request->session()->flash('print_status', 'Wydrukowano repertuar Multikina na jutro!');
return back(); return back();
@@ -83,7 +83,7 @@ class Repertoire extends Controller
$gdynskieCentrumFilmowe->setDay(date_create()->modify('+1 day')->format('d_m_Y')); $gdynskieCentrumFilmowe->setDay(date_create()->modify('+1 day')->format('d_m_Y'));
$repertuarText = $gdynskieCentrumFilmowe->convertToPrint(); $repertuarText = $gdynskieCentrumFilmowe->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar Gdyńskiego Centrum Filmowego na jutro!'); $request->session()->flash('print_status', 'Wydrukowano repertuar Gdyńskiego Centrum Filmowego na jutro!');
return back(); return back();
@@ -95,7 +95,7 @@ class Repertoire extends Controller
$gdynskieCentrumFilmowe->setDay(date('d_m_y')); $gdynskieCentrumFilmowe->setDay(date('d_m_y'));
$repertuarText = $gdynskieCentrumFilmowe->convertToPrint(); $repertuarText = $gdynskieCentrumFilmowe->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar Gdyńskiego Centrum Filmowego na jutro!'); $request->session()->flash('print_status', 'Wydrukowano repertuar Gdyńskiego Centrum Filmowego na jutro!');
return back(); return back();
@@ -109,7 +109,7 @@ class Repertoire extends Controller
$helios->convertToPrint(); $helios->convertToPrint();
$repertuarText = $helios->convertToPrint(); $repertuarText = $helios->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar Helios na dzisiaj!'); $request->session()->flash('print_status', 'Wydrukowano repertuar Helios na dzisiaj!');
return back(); return back();
} }
@@ -122,7 +122,7 @@ class Repertoire extends Controller
$helios->convertToPrint(); $helios->convertToPrint();
$repertuarText = $helios->convertToPrint(); $repertuarText = $helios->convertToPrint();
$this->main->sendPrintnt('', $repertuarText, $this->icon); $this->main->sendPrint('', $repertuarText, $this->icon);
$request->session()->flash('print_status', 'Wydrukowano repertuar Helios na jutro!'); $request->session()->flash('print_status', 'Wydrukowano repertuar Helios na jutro!');
return back(); return back();
} }

View File

@@ -0,0 +1,119 @@
<?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['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['separator2'] = '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['separator4'] = 'separator';
$actions['note_last'] = 'Ostatnia zapisana notatka';
$actions['separator5'] = '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;
}
}

View File

@@ -12,6 +12,6 @@ class VerifyCsrfToken extends BaseVerifier
* @var array * @var array
*/ */
protected $except = [ protected $except = [
// 'sms'
]; ];
} }

View File

@@ -6,18 +6,28 @@ namespace App\Paper;
class Airly class Airly
{ {
private $apiKey = '8b6d77b2950e4e018b0684912bf7b9ed'; private $apiKey;
public $icon = 'cloud';
private $stations = ['2210', '2256', '2180']; private $stations = [];
private $airlyApi = 'https://airapi.airly.eu/v1'; private $airlyApi = 'https://airapi.airly.eu/v1';
public function __construct()
{
$this->apiKey = config('paper.airly.api_key');
}
public function getStations() public function getStations()
{ {
return $this->stations; return $this->stations;
} }
public function setStations(array $stations){
$this->stations = $stations;
}
function getStationInfo($stationId) function getStationInfo($stationId)
{ {
return json_decode(file_get_contents(sprintf('%s/sensors/%d?apikey=%s', $this->airlyApi, $stationId, $this->apiKey)), 1); return json_decode(file_get_contents(sprintf('%s/sensors/%d?apikey=%s', $this->airlyApi, $stationId, $this->apiKey)), 1);

View File

@@ -26,9 +26,6 @@ class CinemaCinemaCity implements Cinema
if (is_null($this->cinemaId) || is_null($this->day)) if (is_null($this->cinemaId) || is_null($this->day))
throw new \Exception('Day or cinemaid not set.'); 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; $url = 'https://www.cinema-city.pl/pgm-list-byfeat?si=' . $this->cinemaId . '&sort=cin&bd=' . $this->day;
return file_get_contents($url); return file_get_contents($url);
@@ -41,9 +38,6 @@ class CinemaCinemaCity implements Cinema
$document = json_decode($document); $document = json_decode($document);
// $cinemaData = [];
// $text = "Repertuar Cinema-City\n";
// $text .= str_replace('/', '-', $this->day) . "\n\n";
$movies = []; $movies = [];
$date = date('d/m/Y', strtotime($this->day)); $date = date('d/m/Y', strtotime($this->day));
@@ -55,9 +49,6 @@ class CinemaCinemaCity implements Cinema
foreach ($movieData->BD as $projections) { foreach ($movieData->BD as $projections) {
if ($projections->date == $date) { if ($projections->date == $date) {
foreach ($projections->P as $projection) { foreach ($projections->P as $projection) {
// var_dump($projection);
// die();
$movie['hours'][] = $projection->time; $movie['hours'][] = $projection->time;
} }
} }

View File

@@ -12,10 +12,104 @@ class HtmlToPos
return str_replace(['<br>', '<br/>', '<br />'], "\n", $text); 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)
{
/**
* 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
*/
$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; return $posText;
} }
private function randomNumber($posText)
{
/**
* przeszukiwanie tekstu pod katem zawartości [ liczba, liczba2 ] i zamienianiu tego na randomową liczbę z przedziału
* liczba - liczba2
* obojętnie czy ujemną czy nie
*/
$re = '/\[\s*(-?\d+)\s*\,\s*(-?\d+)\s*\]/';
preg_match_all($re, $posText, $matches, PREG_SET_ORDER, 0);
foreach ($matches as $match) {
$pos = strpos($posText, $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;
}
} }

View File

@@ -23,11 +23,21 @@ class Paper
try { try {
$this->connector = new FilePrintConnector("/dev/usb/lp0"); $this->connector = new FilePrintConnector("/dev/usb/lp0");
$this->printer = new Printer($this->connector); $this->printer = new Printer($this->connector);
}catch (Exception $e){ } catch (Exception $e) {
die($e->getMessage()); die($e->getMessage());
} }
} }
public function getConnector()
{
return $this->connector;
}
public function getPrinter()
{
return $this->printer;
}
public function sendHeaderPrint($title) 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 ($image) {
if ($imageLocal) { 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 } else { //image not local so then remote image
$extension = strtolower(pathinfo($image, PATHINFO_EXTENSION)); $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) public function sendPrint($title, $text = '', $image = false, $imageLocal = true)
{ {
$this->sendImagePrint($image, $imageLocal); $this->sendImagePrint($image, $imageLocal);
$this->sendHeaderPrint($title); $this->sendHeaderPrint($title);
$htmlToPos = new HtmlToPos(); $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); $this->printer->feed(3);
} }
@@ -83,7 +117,7 @@ class Paper
*/ */
public function getIcons() 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 = []; $iconsDatabase = [];

108
app/Paper/Traficar.php Normal file
View 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
View 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);
}
}

View File

@@ -5,7 +5,7 @@
"license": "MIT", "license": "MIT",
"type": "project", "type": "project",
"require": { "require": {
"php": ">=5.6.4", "php": ">=7.0.0",
"imangazaliev/didom": "^1.9", "imangazaliev/didom": "^1.9",
"intervention/image": "^2.3", "intervention/image": "^2.3",
"laravel/framework": "5.4.*", "laravel/framework": "5.4.*",

View File

@@ -12,7 +12,7 @@ return [
| any other location as required by the application or its packages. | 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',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@@ -35,7 +35,7 @@ return [
'sqlite' => [ 'sqlite' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')), 'database' => database_path(env('DB_DATABASE','database.sqlite')),
'prefix' => '', 'prefix' => '',
], ],

18
config/paper.php Normal file
View File

@@ -0,0 +1,18 @@
<?php
/**
* Created by PhpStorm.
* User: k
* Date: 15.04.2018
* Time: 19:53
*/
return ['airly' =>
[
'api_key' => '8b6d77b2950e4e018b0684912bf7b9ed',
'stations' => ['2210', '2256', '2180'],
'rzeczypospolitej' => 2210,
'grunwaldzka' => 2256,
'sowinskiego' => 2180,
]
];

BIN
database/printer_example.db Normal file

Binary file not shown.

140
public/css/app.css vendored
View File

@@ -20,6 +20,14 @@ textarea.content {
} }
.note-title {
line-height: 32px;
}
h1.header span.icon.display-inline-block {
display: inline-block;
}
form { form {
margin-bottom: 0; margin-bottom: 0;
} }
@@ -28,6 +36,23 @@ form {
display: none; 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 { .icon {
cursor: pointer; cursor: pointer;
height: 25px; height: 25px;
@@ -37,7 +62,7 @@ form {
margin: 2px; margin: 2px;
} }
.icon:hover { .icons .icon:hover {
background-color: #1e90ff4d; background-color: #1e90ff4d;
} }
@@ -55,342 +80,455 @@ form {
height: 29px; height: 29px;
margin: 0; margin: 0;
} }
.icon.address-card-o { .icon.address-card-o {
background-position-x: -0px; background-position-x: -0px;
} }
.icon.anchor { .icon.anchor {
background-position-x: -25px; background-position-x: -25px;
} }
.icon.archive-3 { .icon.archive-3 {
background-position-x: -50px; background-position-x: -50px;
} }
.icon.at { .icon.at {
background-position-x: -75px; background-position-x: -75px;
} }
.icon.balance-scale { .icon.balance-scale {
background-position-x: -100px; background-position-x: -100px;
} }
.icon.ban { .icon.ban {
background-position-x: -125px; background-position-x: -125px;
} }
.icon.bar-chart-o { .icon.bar-chart-o {
background-position-x: -150px; background-position-x: -150px;
} }
.icon.barcode { .icon.barcode {
background-position-x: -175px; background-position-x: -175px;
} }
.icon.battery-empty { .icon.battery-empty {
background-position-x: -200px; background-position-x: -200px;
} }
.icon.battery-full { .icon.battery-full {
background-position-x: -225px; background-position-x: -225px;
} }
.icon.battery-half { .icon.battery-half {
background-position-x: -250px; background-position-x: -250px;
} }
.icon.battery-quarter { .icon.battery-quarter {
background-position-x: -275px; background-position-x: -275px;
} }
.icon.battery-three-quarters { .icon.battery-three-quarters {
background-position-x: -300px; background-position-x: -300px;
} }
.icon.bed { .icon.bed {
background-position-x: -325px; background-position-x: -325px;
} }
.icon.beer { .icon.beer {
background-position-x: -350px; background-position-x: -350px;
} }
.icon.bell-o { .icon.bell-o {
background-position-x: -375px; background-position-x: -375px;
} }
.icon.bell-slash-o { .icon.bell-slash-o {
background-position-x: -400px; background-position-x: -400px;
} }
.icon.bicycle { .icon.bicycle {
background-position-x: -425px; background-position-x: -425px;
} }
.icon.birthday-cake { .icon.birthday-cake {
background-position-x: -450px; background-position-x: -450px;
} }
.icon.bolt { .icon.bolt {
background-position-x: -475px; background-position-x: -475px;
} }
.icon.bomb { .icon.bomb {
background-position-x: -500px; background-position-x: -500px;
} }
.icon.book { .icon.book {
background-position-x: -525px; background-position-x: -525px;
} }
.icon.bug { .icon.bug {
background-position-x: -550px; background-position-x: -550px;
} }
.icon.building-o { .icon.building-o {
background-position-x: -575px; background-position-x: -575px;
} }
.icon.bullhorn { .icon.bullhorn {
background-position-x: -600px; background-position-x: -600px;
} }
.icon.bus { .icon.bus {
background-position-x: -625px; background-position-x: -625px;
} }
.icon.camera { .icon.camera {
background-position-x: -650px; background-position-x: -650px;
} }
.icon.car { .icon.car {
background-position-x: -675px; background-position-x: -675px;
} }
.icon.chain { .icon.chain {
background-position-x: -700px; background-position-x: -700px;
} }
.icon.chat-2 { .icon.chat-2 {
background-position-x: -725px; background-position-x: -725px;
} }
.icon.check { .icon.check {
background-position-x: -750px; background-position-x: -750px;
} }
.icon.cloud { .icon.cloud {
background-position-x: -775px; background-position-x: -775px;
} }
.icon.code { .icon.code {
background-position-x: -800px; background-position-x: -800px;
} }
.icon.coffee { .icon.coffee {
background-position-x: -825px; background-position-x: -825px;
} }
.icon.cog { .icon.cog {
background-position-x: -850px; background-position-x: -850px;
} }
.icon.cutlery { .icon.cutlery {
background-position-x: -875px; background-position-x: -875px;
} }
.icon.dashboard { .icon.dashboard {
background-position-x: -900px; background-position-x: -900px;
} }
.icon.database { .icon.database {
background-position-x: -925px; background-position-x: -925px;
} }
.icon.diamond { .icon.diamond {
background-position-x: -950px; background-position-x: -950px;
} }
.icon.dollar { .icon.dollar {
background-position-x: -975px; background-position-x: -975px;
} }
.icon.dribbble { .icon.dribbble {
background-position-x: -1000px; background-position-x: -1000px;
} }
.icon.envelope-o { .icon.envelope-o {
background-position-x: -1025px; background-position-x: -1025px;
} }
.icon.envira { .icon.envira {
background-position-x: -1050px; background-position-x: -1050px;
} }
.icon.exclamation-triangle { .icon.exclamation-triangle {
background-position-x: -1075px; background-position-x: -1075px;
} }
.icon.female { .icon.female {
background-position-x: -1100px; background-position-x: -1100px;
} }
.icon.file-text-o { .icon.file-text-o {
background-position-x: -1125px; background-position-x: -1125px;
} }
.icon.film { .icon.film {
background-position-x: -1150px; background-position-x: -1150px;
} }
.icon.fingerprint { .icon.fingerprint {
background-position-x: -1175px; background-position-x: -1175px;
} }
.icon.fire-extinguisher { .icon.fire-extinguisher {
background-position-x: -1200px; background-position-x: -1200px;
} }
.icon.fire { .icon.fire {
background-position-x: -1225px; background-position-x: -1225px;
} }
.icon.flag-o { .icon.flag-o {
background-position-x: -1250px; background-position-x: -1250px;
} }
.icon.flask { .icon.flask {
background-position-x: -1275px; background-position-x: -1275px;
} }
.icon.floppy-o { .icon.floppy-o {
background-position-x: -1300px; background-position-x: -1300px;
} }
.icon.folder-o { .icon.folder-o {
background-position-x: -1325px; background-position-x: -1325px;
} }
.icon.folder-open-o { .icon.folder-open-o {
background-position-x: -1350px; background-position-x: -1350px;
} }
.icon.frown-o { .icon.frown-o {
background-position-x: -1375px; background-position-x: -1375px;
} }
.icon.gamepad { .icon.gamepad {
background-position-x: -1400px; background-position-x: -1400px;
} }
.icon.gift { .icon.gift {
background-position-x: -1425px; background-position-x: -1425px;
} }
.icon.git { .icon.git {
background-position-x: -1450px; background-position-x: -1450px;
} }
.icon.glass { .icon.glass {
background-position-x: -1475px; background-position-x: -1475px;
} }
.icon.graduation-cap { .icon.graduation-cap {
background-position-x: -1500px; background-position-x: -1500px;
} }
.icon.grav { .icon.grav {
background-position-x: -1525px; background-position-x: -1525px;
} }
.icon.group { .icon.group {
background-position-x: -1550px; background-position-x: -1550px;
} }
.icon.hand-o-left { .icon.hand-o-left {
background-position-x: -1575px; background-position-x: -1575px;
} }
.icon.heart-o { .icon.heart-o {
background-position-x: -1600px; background-position-x: -1600px;
} }
.icon.home { .icon.home {
background-position-x: -1625px; background-position-x: -1625px;
} }
.icon.lemon-o { .icon.lemon-o {
background-position-x: -1650px; background-position-x: -1650px;
} }
.icon.lightbulb-o { .icon.lightbulb-o {
background-position-x: -1675px; background-position-x: -1675px;
} }
.icon.list-alt { .icon.list-alt {
background-position-x: -1700px; background-position-x: -1700px;
} }
.icon.location-arrow { .icon.location-arrow {
background-position-x: -1725px; background-position-x: -1725px;
} }
.icon.lock { .icon.lock {
background-position-x: -1750px; background-position-x: -1750px;
} }
.icon.male { .icon.male {
background-position-x: -1775px; background-position-x: -1775px;
} }
.icon.map-1 { .icon.map-1 {
background-position-x: -1800px; background-position-x: -1800px;
} }
.icon.map-marker { .icon.map-marker {
background-position-x: -1825px; background-position-x: -1825px;
} }
.icon.microchip { .icon.microchip {
background-position-x: -1850px; background-position-x: -1850px;
} }
.icon.money { .icon.money {
background-position-x: -1875px; background-position-x: -1875px;
} }
.icon.moon-o { .icon.moon-o {
background-position-x: -1900px; background-position-x: -1900px;
} }
.icon.music { .icon.music {
background-position-x: -1925px; background-position-x: -1925px;
} }
.icon.paper-plane { .icon.paper-plane {
background-position-x: -1950px; background-position-x: -1950px;
} }
.icon.paperclip { .icon.paperclip {
background-position-x: -1975px; background-position-x: -1975px;
} }
.icon.paw { .icon.paw {
background-position-x: -2000px; background-position-x: -2000px;
} }
.icon.pencil { .icon.pencil {
background-position-x: -2025px; background-position-x: -2025px;
} }
.icon.phone { .icon.phone {
background-position-x: -2050px; background-position-x: -2050px;
} }
.icon.pie-chart { .icon.pie-chart {
background-position-x: -2075px; background-position-x: -2075px;
} }
.icon.piggy-bank { .icon.piggy-bank {
background-position-x: -2100px; background-position-x: -2100px;
} }
.icon.plane { .icon.plane {
background-position-x: -2125px; background-position-x: -2125px;
} }
.icon.question-circle-o { .icon.question-circle-o {
background-position-x: -2150px; background-position-x: -2150px;
} }
.icon.rocket { .icon.rocket {
background-position-x: -2175px; background-position-x: -2175px;
} }
.icon.search { .icon.search {
background-position-x: -2200px; background-position-x: -2200px;
} }
.icon.ship { .icon.ship {
background-position-x: -2225px; background-position-x: -2225px;
} }
.icon.shopping-cart { .icon.shopping-cart {
background-position-x: -2250px; background-position-x: -2250px;
} }
.icon.smile-o { .icon.smile-o {
background-position-x: -2275px; background-position-x: -2275px;
} }
.icon.snowflake-o { .icon.snowflake-o {
background-position-x: -2300px; background-position-x: -2300px;
} }
.icon.steam { .icon.steam {
background-position-x: -2325px; background-position-x: -2325px;
} }
.icon.subway { .icon.subway {
background-position-x: -2350px; background-position-x: -2350px;
} }
.icon.success { .icon.success {
background-position-x: -2375px; background-position-x: -2375px;
} }
.icon.support { .icon.support {
background-position-x: -2400px; background-position-x: -2400px;
} }
.icon.thermometer-2 { .icon.thermometer-2 {
background-position-x: -2425px; background-position-x: -2425px;
} }
.icon.thumbs-o-down { .icon.thumbs-o-down {
background-position-x: -2450px; background-position-x: -2450px;
} }
.icon.thumbs-o-up { .icon.thumbs-o-up {
background-position-x: -2475px; background-position-x: -2475px;
} }
.icon.ticket { .icon.ticket {
background-position-x: -2500px; background-position-x: -2500px;
} }
.icon.times { .icon.times {
background-position-x: -2525px; background-position-x: -2525px;
} }
.icon.trash-o { .icon.trash-o {
background-position-x: -2550px; background-position-x: -2550px;
} }
.icon.tree { .icon.tree {
background-position-x: -2575px; background-position-x: -2575px;
} }
.icon.trophy { .icon.trophy {
background-position-x: -2600px; background-position-x: -2600px;
} }
.icon.truck { .icon.truck {
background-position-x: -2625px; background-position-x: -2625px;
} }
.icon.umbrella { .icon.umbrella {
background-position-x: -2650px; background-position-x: -2650px;
} }
.icon.usd { .icon.usd {
background-position-x: -2675px; background-position-x: -2675px;
} }
.icon.warning { .icon.warning {
background-position-x: -2700px; background-position-x: -2700px;
} }
.icon.wifi { .icon.wifi {
background-position-x: -2725px; background-position-x: -2725px;
} }
.icon.wpexplorer { .icon.wpexplorer {
background-position-x: -2750px; background-position-x: -2750px;
} }
.icon.wrench { .icon.wrench {
background-position-x: -2775px; background-position-x: -2775px;
} }
.icon.youtube-play { .icon.youtube-play {
background-position-x: -2800px; background-position-x: -2800px;
} }

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -1,4 +1,4 @@
var content, preview, selfPrinter; var content, title, preview, selfPrinter;
var Printer = function () { var Printer = function () {
@@ -8,6 +8,7 @@ var Printer = function () {
this.delete = document.querySelector('.js-delete'); this.delete = document.querySelector('.js-delete');
content = this.content = document.querySelector('.js-content'); content = this.content = document.querySelector('.js-content');
title = this.title = document.querySelector('input[name="title"]');
selfPrinter = this; selfPrinter = this;
@@ -21,7 +22,7 @@ var Printer = function () {
this.delete.addEventListener('click', this.confirmDelete); this.delete.addEventListener('click', this.confirmDelete);
} }
document.querySelectorAll('.icon').forEach(function (e) { document.querySelectorAll('.icons .icon').forEach(function (e) {
e.addEventListener('click', function () { e.addEventListener('click', function () {
selfPrinter.selectIcon(this.title); selfPrinter.selectIcon(this.title);
}); });
@@ -32,7 +33,7 @@ var Printer = function () {
/** /**
* resetuje wybór ikony * resetuje wybór ikony
*/ */
this.selectIcon = function(iconTitle){ this.selectIcon = function (iconTitle) {
document.querySelectorAll('.icon').forEach(function (e, i) { document.querySelectorAll('.icon').forEach(function (e, i) {
e.classList.remove('selected'); e.classList.remove('selected');
}); });
@@ -42,7 +43,7 @@ var Printer = function () {
}; };
this.restoreContentHeight = function () { this.restoreContentHeight = function () {
if(!!localStorage.getItem('contentHeight')){ if (!!localStorage.getItem('contentHeight')) {
document.querySelector('.js-content').style.height = localStorage.getItem('contentHeight') document.querySelector('.js-content').style.height = localStorage.getItem('contentHeight')
} }
}; };
@@ -56,6 +57,7 @@ var Printer = function () {
}; };
this.clear = function () { this.clear = function () {
selfPrinter.title.value = '';
selfPrinter.content.innerHTML = ''; selfPrinter.content.innerHTML = '';
selfPrinter.selectIcon('empty'); selfPrinter.selectIcon('empty');
}; };

34
public/manifest.json Normal file
View 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"
}]
}

View File

@@ -1,11 +1,22 @@
@extends('layouts.base') @extends('layouts.base')
@section('content') @section('content')
<style> <style>
body .column .ui.form textarea:not([rows]) {max-height: inherit; height: 20em} body .column .ui.form textarea:not([rows]) {
max-height: inherit;
height: 20em
}
</style> </style>
<div class="ui container"> <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 one column middle aligned stackable grid">
<div class="ui column"> <div class="ui column">
@if($type == 'template') @if($type == 'template')
@@ -13,8 +24,8 @@
@else @else
<h2><a href="/">Lista</a> &raquo; Edycja notatki</h2> <h2><a href="/">Lista</a> &raquo; Edycja notatki</h2>
@endif @endif
@include('form.create') @include('form.create')
<br><br> <br><br>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -12,17 +12,11 @@
name="text">{{ $text }}</textarea> name="text">{{ $text }}</textarea>
<input type="hidden" name="icon" id="icon" value="{{ $icon_selected }}"/> <input type="hidden" name="icon" id="icon" value="{{ $icon_selected }}"/>
<div class="icons"> <div class="icons">
<span class="icon @if(!isset($icon_selected) ) selected @endif empty" title="empty"></span> <span class="icon @if(!isset($icon_selected) ) selected @endif empty" title="empty"></span>
@foreach ($icons as $icon)<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 </span>@endforeach
</div> </div>
</div> </div>
@@ -38,9 +32,12 @@
<button class="ui reset button js-reset" type="reset">Wyczyść</button> <button class="ui reset button js-reset" type="reset">Wyczyść</button>
@if(isset($id)) @if(isset($id))
<button class="ui delete button js-delete red" type="submit" name="delete">Usuń</button> <button class="ui delete button js-delete red" type="submit" name="delete">Usuń</button>
@endif @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> </form>

View File

@@ -10,7 +10,10 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.slim.min.js"></script> <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/semantic.min.js"></script>
<script src="/js/printer.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> </head>
<body> <body>
<div class=""> <div class="">

View File

@@ -12,8 +12,10 @@
</div> </div>
@endif @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 container">
<div class="ui one column middle aligned stackable grid"> <div class="ui one column middle aligned stackable grid">
<div class="ui column"> <div class="ui column">
@@ -45,23 +47,28 @@
</div> </div>
<div class="ui container"> <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"> <div class="ui middle aligned divided list">
@foreach($notes as $note) @foreach($notes as $note)
<div class="item"> @if($note->private != 1 || substr($_SERVER['REMOTE_ADDR'],0,9) == '192.168.0')
<div class="right floated content"> <div class="item">
<form method="post" action="/print/{{ $note->id }}"> <div class="left floated content">
{{ csrf_field() }} <a href="/filter/{{ $note->icon }}" class="left floated"><span
<button type="primary" class="ui tiny button primary">Drukuj</button> class="icon @if($note->icon){{ $note->icon }} @else empty @endif "
</form> 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>
<div class="content"> @endif
<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>
@endforeach @endforeach
</div> </div>
<h1 class="ui header">Szablony notatek</h1> <h1 class="ui header">Szablony notatek</h1>

View 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

View File

@@ -12,18 +12,22 @@
*/ */
Route::get('/', 'Main@listView')->name('list'); 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::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('/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('/printImage', 'Main@imagePrint');
Route::post('/', 'Main@main'); Route::post('/', 'Main@main');
Route::get('/airly', 'Main@airly'); Route::get('/airly', 'AirlyController@airly_all');

View 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 its 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 doesnt 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);
}
}