Skip to content

Commit

Permalink
Merge pull request #17 from Kovah/dev
Browse files Browse the repository at this point in the history
v0.0.2 (Beta 1)
  • Loading branch information
Kovah authored Jan 17, 2019
2 parents 357269f + dfccf93 commit 35e41f5
Show file tree
Hide file tree
Showing 25 changed files with 458 additions and 77 deletions.
14 changes: 14 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright 2019 Kovah.de

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of
the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,19 @@
<p>&nbsp;</p>

<p align="center"><b>A small, selfhosted bookmark manager.</b></p>
<p align="center"><b>:warning: This application is still in development and not save to use! :warning:</b></p>
<p align="center"><b>:warning: This application is still in development! :warning:</b></p>

<p align="center">
<a href="https://hub.docker.com/r/linkace/linkace">
<img src="https://img.shields.io/badge/Docker-linkace%2Flinkace-2596EC.svg" alt="Docker Repository">
</a>
<a href="https://github.com/Kovah/LinkAce/releases">
<img src="https://img.shields.io/github/release/kovah/linkace.svg" alt="Latest Release">
</a>
<a href="https://opensource.org/licenses/MIT">
<img src="https://img.shields.io/github/license/kovah/linkace.svg" alt="License">
</a>
</p>

<p>&nbsp;</p>

Expand All @@ -27,9 +39,9 @@ Now, install all dependencies from inside the PHP container:
$ docker exec linkace-php bash -c "composer install"
```

Last step, compile all assets. You need [Node](https://nodejs.org/en/) with either NPM or [Yarn](https://yarnpkg.com)
Last step: compile all assets. You need [Node](https://nodejs.org/en/) with either NPM or [Yarn](https://yarnpkg.com)
installed.
Node 8 LTS is the minimum version required and recommended to use.
Node 10 LTS is the minimum version required and recommended to use.

```
$ npm install
Expand Down
18 changes: 17 additions & 1 deletion app/Http/Controllers/App/TrashController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Http\Controllers\Controller;
use App\Models\Category;
use App\Models\Link;
use App\Models\Note;
use App\Models\Tag;
use Illuminate\Http\Request;

Expand All @@ -29,10 +30,15 @@ public function index()
->byUser(auth()->id())
->get();

$notes = Note::onlyTrashed()
->byUser(auth()->id())
->get();

return view('actions.trash.index', [
'links' => $links,
'categories' => $categories,
'tags' => $tags,
'notes' => $notes,
]);
}

Expand Down Expand Up @@ -63,6 +69,11 @@ public function clearTrash(Request $reques, $model)
->byUser(auth()->id())
->get();
break;
case 'notes':
$entries = Note::onlyTrashed()
->byUser(auth()->id())
->get();
break;
}

if (empty($entries)) {
Expand All @@ -72,6 +83,7 @@ public function clearTrash(Request $reques, $model)

foreach ($entries as $entry) {
$entry->forceDelete();
$entry->flushCache();
}

alert(trans('trash.delete_success.' . $model), 'success');
Expand Down Expand Up @@ -101,6 +113,9 @@ public function restoreEntry(Request $request, $model, $id)
case 'tag':
$entry = Tag::withTrashed()->find($id);
break;
case 'note':
$entry = Note::withTrashed()->find($id);
break;
}

if (empty($entry)) {
Expand All @@ -112,8 +127,9 @@ public function restoreEntry(Request $request, $model, $id)
}

$entry->restore();
$entry->flushCache();

alert(trans('trash.delete_success.' . $model), 'success');
alert(trans('trash.delete_restore.' . $model), 'success');

return redirect()->route('get-trash');
}
Expand Down
108 changes: 70 additions & 38 deletions app/Http/Controllers/Models/NoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,83 +6,115 @@
use App\Http\Requests\NoteDeleteRequest;
use App\Http\Requests\NoteStoreRequest;
use App\Http\Requests\NoteUpdateRequest;
use App\Models\Link;
use App\Models\Note;

class NoteController extends Controller
{
/**
* Display a listing of the resource.
*
* @return void
*/
public function index()
{
//
}

/**
* Show the form for creating a new resource.
*
* @return void
*/
public function create()
{
//
}

/**
* Store a newly created resource in storage.
*
* @param NoteStoreRequest $request
* @return void
* @return \Illuminate\Http\RedirectResponse
*/
public function store(NoteStoreRequest $request)
{
//
}
$link = Link::find($request->get('link_id'));

/**
* Display the specified resource.
*
* @param int $id
* @return void
*/
public function show($id)
{
//
if ($link->user_id !== auth()->id()) {
abort(403);
}

$data = $request->except(['_token']);
$data['user_id'] = auth()->id();

$note = Note::create($data);

Note::flushCache();
Link::flushCache();

alert(trans('note.added_successfully'), 'success');

return redirect()->route('links.show', [$link->id]);
}

/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return void
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function edit($id)
{
//
$note = Note::find($id);

if (empty($note)) {
abort(404);
}

if ($note->user_id !== auth()->id()) {
abort(404);
}

return view('models.notes.edit')->with('note', $note);
}

/**
* Update the specified resource in storage.
*
* @param NoteUpdateRequest $request
* @param int $id
* @return void
* @return \Illuminate\Http\RedirectResponse
*/
public function update(NoteUpdateRequest $request, $id)
{
//
$note = Note::find($request->get('note_id'));

if (empty($note)) {
abort(404);
}

$data = $request->except(['_token', 'note_id']);
$data['is_private'] = $data['is_private'] ?? false;

$note->update($data);

Note::flushCache();
Link::flushCache();

alert(trans('note.updated_successfully'), 'success');

return redirect()->route('links.show', [$note->link->id]);
}

/**
* Remove the specified resource from storage.
*
* @param NoteDeleteRequest $request
* @param int $id
* @return void
* @return \Illuminate\Http\RedirectResponse
* @throws \Exception
*/
public function destroy(NoteDeleteRequest $request, $id)
{
//
$note = Note::find($id);

if (empty($note)) {
abort(404);
}

if ($note->link->user_id !== auth()->id()) {
abort(404);
}

$link = $note->link->id;
$note->delete();

Note::flushCache();
Link::flushCache();

alert(trans('note.deleted_successfully'), 'success');

return redirect()->route('links.show', [$link]);
}
}
3 changes: 2 additions & 1 deletion app/Http/Requests/NoteStoreRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ public function authorize()
public function rules()
{
return [
'link_id' => 'required',
'note' => 'required',
'is_private' => 'required|integer',
'is_private' => 'boolean',
];
}
}
2 changes: 1 addition & 1 deletion app/Http/Requests/NoteUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function rules()
return [
'note_id' => 'required',
'note' => 'required',
'is_private' => 'required|integer',
'is_private' => 'boolean',
];
}
}
21 changes: 21 additions & 0 deletions app/Models/Note.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,25 @@ public function link()
{
return $this->belongsTo('App\Models\Link', 'link_id');
}

/*
| ========================================================================
| METHODS
*/

/**
* Output a relative time inside a span with real time information
*
* @return string
*/
public function addedAt()
{
$output = '<time-ago class="cursor-help"';
$output .= ' datetime="' . $this->created_at->toIso8601String() . '"';
$output .= ' title="' . formatDateTime($this->created_at) . '">';
$output .= formatDateTime($this->created_at, true);
$output .= '</time-ago>';

return $output;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function up()
$table->integer('user_id')->unsigned();
$table->integer('link_id')->unsigned();
$table->text('note');
$table->boolean('is_private')->default(true);
$table->boolean('is_private')->default(false);
$table->timestamps();
$table->softDeletes();
});
Expand Down
58 changes: 58 additions & 0 deletions docker-compose.production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
version: "2"

services:

# --- MariaDB
db:
container_name: "linkace-db"
image: bitnami/mariadb:10.1
restart: always
environment:
- MARIADB_ROOT_PASSWORD=${DB_PASSWORD}
- MARIADB_USER=${DB_USERNAME}
- MARIADB_PASSWORD=${DB_PASSWORD}
- MARIADB_DATABASE=${DB_DATABASE}
env_file:
- ./.env
volumes:
- db:/bitnami

# --- LinkAce Image with PHP 7.2
php:
container_name: "linkace-php"
image: linkace/linkace:latest
restart: always
volumes:
- linkace_app:/app
- ./.env:/app/.env:ro

# --- nginx
nginx:
container_name: "linkace-nginx"
image: bitnami/nginx:latest
restart: always
ports:
- "127.0.0.1:80:8085"
depends_on:
- php
env_file:
- ./.env
volumes:
- linkace_app:/app
- site.conf:/opt/bitnami/nginx/conf/vhosts/site.conf:ro

# --- Redis
redis:
container_name: "linkace-redis"
image: bitnami/redis:latest
restart: always
env_file:
- ./.env
environment:
- REDIS_PASSWORD=${REDIS_PASSWORD}

volumes:
linkace_app:
db:
driver: local
Loading

0 comments on commit 35e41f5

Please sign in to comment.