Skip to content

URL Shortener on admin dashboard #468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Http/Controllers/LinkController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function performShorten(Request $request) {
return self::renderError($e->getMessage());
}

return view('shorten_result', ['short_url' => $short_url]);
return view($request->path() === 'admin/shorten' ? 'shorten_result_admin' : 'shorten_result', ['short_url' => $short_url]);
}

public function performRedirect(Request $request, $short_url, $secret_key=false) {
Expand Down
1 change: 1 addition & 0 deletions app/Http/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@

$app->post('/login', ['as' => 'plogin', 'uses' => 'UserController@performLogin']);
$app->post('/shorten', ['as' => 'pshorten', 'uses' => 'LinkController@performShorten']);
$app->post('/admin/shorten', ['as' => 'pshorten', 'uses' => 'LinkController@performShorten']);
$app->post('/lost_password', ['as' => 'plost_password', 'uses' => 'UserController@performSendPasswordResetCode']);
$app->post('/reset_password/{username}/{recovery_key}', ['as' => 'preset_password', 'uses' => 'UserController@performPasswordReset']);

Expand Down
44 changes: 42 additions & 2 deletions resources/views/admin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
@section('css')
<link rel='stylesheet' href='/css/admin.css'>
<link rel='stylesheet' href='/css/datatables.min.css'>
<link rel='stylesheet' href='css/index.css' />
@endsection

@section('content')
Expand All @@ -26,8 +27,46 @@
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<h2>Welcome to your {{env('APP_NAME')}} dashboard!</h2>
<p>Use the links on the left hand side to navigate your {{env('APP_NAME')}} dashboard.</p>
</div>
<p>Choose to shorten an URL below and use the links on the left hand side to navigate your {{env('APP_NAME')}} dashboard.</p>

<form method='POST' action='/admin/shorten' role='form'>
<input type='url' autocomplete='off'
class='form-control long-link-input' placeholder='http://' name='link-url' />

<div class='row' id='options' ng-cloak>
<p>Customize link</p>

@if (!env('SETTING_PSEUDORANDOM_ENDING'))
{{-- Show secret toggle only if using counter-based ending --}}
<div class='btn-group btn-toggle visibility-toggler' data-toggle='buttons'>
<label class='btn btn-primary btn-sm active'>
<input type='radio' name='options' value='p' checked /> Public
</label>
<label class='btn btn-sm btn-default'>
<input type='radio' name='options' value='s' /> Secret
</label>
</div>
@endif

<div>
<div class='custom-link-text'>
<h2 class='site-url-field'>{{env('APP_ADDRESS')}}/</h2>
<input type='text' autocomplete="off" class='form-control custom-url-field' name='custom-ending' />
</div>
<div>
<a href='#' class='btn btn-success btn-xs check-btn' id='check-link-availability'>Check Availability</a>
<div id='link-availability-status'></div>
</div>
</div>
</div>
<input type='submit' class='btn btn-info' id='shorten' value='Shorten' />
<a href='#' class='btn btn-warning' id='show-link-options'>Link Options</a>
<input type="hidden" name='_token' value='{{csrf_token()}}' />
</form>

</div>



<div role="tabpanel" class="tab-pane" id="links">
@include('snippets.link_table', [
Expand Down Expand Up @@ -144,4 +183,5 @@
<script src='/js/datatables.min.js'></script>
<script src='/js/api.js'></script>
<script src='/js/AdminCtrl.js'></script>
<script src='js/index.js'></script>
@endsection
52 changes: 52 additions & 0 deletions resources/views/partials/shorten_url.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
@extends('layouts.base')

@section('css')
<link rel='stylesheet' href='css/index.css' />
@endsection

@section('content')
<h1 class='title'>{{env('APP_NAME')}}</h1>

<form method='POST' action='/shorten' role='form'>
<input type='url' autocomplete='off'
class='form-control long-link-input' placeholder='http://' name='link-url' />

<div class='row' id='options' ng-cloak>
<p>Customize link</p>

@if (!env('SETTING_PSEUDORANDOM_ENDING'))
{{-- Show secret toggle only if using counter-based ending --}}
<div class='btn-group btn-toggle visibility-toggler' data-toggle='buttons'>
<label class='btn btn-primary btn-sm active'>
<input type='radio' name='options' value='p' checked /> Public
</label>
<label class='btn btn-sm btn-default'>
<input type='radio' name='options' value='s' /> Secret
</label>
</div>
@endif

<div>
<div class='custom-link-text'>
<h2 class='site-url-field'>{{env('APP_ADDRESS')}}/</h2>
<input type='text' autocomplete="off" class='form-control custom-url-field' name='custom-ending' />
</div>
<div>
<a href='#' class='btn btn-success btn-xs check-btn' id='check-link-availability'>Check Availability</a>
<div id='link-availability-status'></div>
</div>
</div>
</div>
<input type='submit' class='btn btn-info' id='shorten' value='Shorten' />
<a href='#' class='btn btn-warning' id='show-link-options'>Link Options</a>
<input type="hidden" name='_token' value='{{csrf_token()}}' />
</form>

<div id='tips' class='text-muted tips'>
<i class='fa fa-spinner'></i> Loading Tips...
</div>
@endsection

@section('js')
<script src='js/index.js'></script>
@endsection
26 changes: 26 additions & 0 deletions resources/views/shorten_result_admin.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
@extends('layouts.base')

@section('css')
<link rel='stylesheet' href='/css/shorten_result.css' />
@endsection

@section('content')
<h3>Shortened URL</h3>
<div class="input-group">
<input type='text' class='result-box form-control' value='{{$short_url}}' id='short_url' />
<div class='input-group-addon' id='clipboard-copy' data-clipboard-target='#short_url' data-toggle='tooltip' data-placement='bottom' data-title='Copied!'>
<i class='fa fa-clipboard' aria-hidden='true' title='Copy to clipboard'></i>
</div>
</div>
<a id="generate-qr-code" class='btn btn-primary'>Generate QR Code</a>
<a href='/admin' class='btn btn-info'>Shorten another</a>
<div class="qr-code-container"></div>

@endsection


@section('js')
<script src='/js/qrcode.min.js'></script>
<script src='/js/clipboard.min.js'></script>
<script src='/js/shorten_result.js'></script>
@endsection