mirror of
https://github.com/cydrobolt/polr.git
synced 2024-11-13 21:52:29 +01:00
Merge branch 'master' into 346-show-uniques
This commit is contained in:
commit
50622909d5
1
.github/ISSUE_TEMPLATE.md
vendored
1
.github/ISSUE_TEMPLATE.md
vendored
@ -1,4 +1,5 @@
|
||||
<!--- Provide a general summary of the issue in the Title above -->
|
||||
<!--- IMPORTANT: Please follow the format displayed in this template, or your ticket may be ignored. -->
|
||||
|
||||
## Expected Behavior
|
||||
<!--- If you're describing a bug, tell us what should happen -->
|
||||
|
13
README.md
13
README.md
@ -1,4 +1,5 @@
|
||||
# [![Logo](http://i.imgur.com/aOtrJNz.png)](https://polrproject.org)
|
||||
<img src="https://i.imgur.com/ckI6GTu.png" width="350px" alt="Polr Logo" />
|
||||
|
||||
|
||||
:aerial_tramway: A modern, minimalist, and lightweight URL shortener.
|
||||
|
||||
@ -44,11 +45,17 @@ There are breaking changes between 2.x and 1.x; it is not yet possible to automa
|
||||
|
||||
* Safari - [Polr.safariextension](https://github.com/cleverdevil/Polr.safariextension)
|
||||
|
||||
#### Sponsors
|
||||
#### Libraries
|
||||
|
||||
* Python - [mypolr](https://github.com/fauskanger/mypolr)
|
||||
|
||||
#### Acknowledgements
|
||||
We would like to thank Oregon State University's Open Source Lab for providing resources for our infrastructure. The Polr website and demo are hosted on their infrastructure.
|
||||
|
||||
<a href="//osuosl.org"><img height="100em" src="http://i.imgur.com/1VtLxyX.png" /></a>
|
||||
|
||||
Thank you to [lastspark](https://thenounproject.com/lastspark/) for providing our logo's icon.
|
||||
|
||||
#### Versioning
|
||||
|
||||
Polr uses [Semantic Versioning](http://semver.org/)
|
||||
@ -57,7 +64,7 @@ Polr uses [Semantic Versioning](http://semver.org/)
|
||||
#### License
|
||||
|
||||
|
||||
Copyright (C) 2013-2017 Chaoyi Zha
|
||||
Copyright (C) 2013-2018 Chaoyi Zha
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
|
@ -51,7 +51,7 @@ class Handler extends ExceptionHandler {
|
||||
return redirect()->to(env('SETTING_INDEX_REDIRECT'));
|
||||
}
|
||||
// Otherwise, show a nice error page
|
||||
return view('errors.404');
|
||||
return response(view('errors.404'), 404);
|
||||
}
|
||||
if ($e instanceof HttpException) {
|
||||
// Handle HTTP exceptions thrown by public-facing controllers
|
||||
@ -60,11 +60,15 @@ class Handler extends ExceptionHandler {
|
||||
|
||||
if ($status_code == 500) {
|
||||
// Render a nice error page for 500s
|
||||
return view('errors.500');
|
||||
return response(view('errors.500'), 500);
|
||||
}
|
||||
else {
|
||||
// If not 500, render generic page
|
||||
return response(view('errors.generic', ['status_code' => $status_code, 'status_message' => $status_message]), $status_code);
|
||||
return response(
|
||||
view('errors.generic', [
|
||||
'status_code' => $status_code,
|
||||
'status_message' => $status_message
|
||||
]), $status_code);
|
||||
}
|
||||
}
|
||||
if ($e instanceof ApiException) {
|
||||
|
@ -23,11 +23,15 @@ class ApiHelper {
|
||||
$api_quota = env('SETTING_ANON_API_QUOTA') ?: 5;
|
||||
}
|
||||
|
||||
if ($api_quota < 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$links_last_minute = Link::where('is_api', 1)
|
||||
->where('creator', $username)
|
||||
->where('created_at', '>=', $last_minute)
|
||||
->count();
|
||||
|
||||
return ($api_quota > -1 && $links_last_minute >= $api_quota);
|
||||
return $links_last_minute >= $api_quota;
|
||||
}
|
||||
}
|
||||
|
@ -17,8 +17,8 @@ class AdminPaginationController extends Controller {
|
||||
/* Cell rendering functions */
|
||||
|
||||
public function renderLongUrlCell($link) {
|
||||
return '<a target="_blank" title="' . e($link->long_url) . '" href="'. $link->long_url .'">' . str_limit($link->long_url, 50) . '</a>
|
||||
<a class="btn btn-primary btn-xs edit-long-link-btn" ng-click="editLongLink(\'' . $link->short_url . '\', \'' . $link->long_url . '\')"><i class="fa fa-edit edit-link-icon"></i></a>';
|
||||
return '<a target="_blank" title="' . e($link->long_url) . '" href="'. e($link->long_url) .'">' . e(str_limit($link->long_url, 50)) . '</a>
|
||||
<a class="btn btn-primary btn-xs edit-long-link-btn" ng-click="editLongLink(\'' . e($link->short_url) . '\', \'' . e($link->long_url) . '\')"><i class="fa fa-edit edit-link-icon"></i></a>';
|
||||
}
|
||||
|
||||
public function renderClicksCell($link) {
|
||||
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateApiQuotaIndex extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('links', function (Blueprint $table)
|
||||
{
|
||||
$table->index(
|
||||
['created_at', 'creator', 'is_api'],
|
||||
'api_quota_index'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('links', function (Blueprint $table)
|
||||
{
|
||||
$table->dropIndex('api_quota_index');
|
||||
});
|
||||
}
|
||||
}
|
@ -5,9 +5,6 @@ To interact with Polr's API, you may opt to use a library or write your own inte
|
||||
As not all languages and frameworks are currently supported by a library, it is encouraged
|
||||
that you take a look at the [API documentation](api/) to integrate Polr into your application.
|
||||
|
||||
### Official Libraries
|
||||
- there are no official libraries for Polr 2.0 yet.
|
||||
|
||||
### Unofficial libraries
|
||||
- there are no unofficial libraries for Polr 2.0 yet.
|
||||
- perhaps you'd like to write one? Send a PR to add your library to this page.
|
||||
## Unofficial libraries
|
||||
### Python
|
||||
- [mypolr](https://github.com/fauskanger/mypolr) is a Python 3 package for interacting with the Polr 2.0 API. ([Documentation](https://mypolr.readthedocs.io))
|
||||
|
BIN
docs/logo.png
BIN
docs/logo.png
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 9.2 KiB |
@ -17,11 +17,11 @@
|
||||
}
|
||||
|
||||
.logo-img {
|
||||
width: 18em;
|
||||
width: 17em;
|
||||
}
|
||||
|
||||
.logo-well {
|
||||
width: 19em;
|
||||
width: 20.5em;
|
||||
|
||||
-webkit-animation: colorpulse 20s infinite;
|
||||
animation: colorpulse 20s infinite;
|
||||
|
@ -37,7 +37,7 @@ input.api-quota {
|
||||
display: inline;
|
||||
width: 9em;
|
||||
font-size: .85em;
|
||||
height: .85em;
|
||||
height: auto;
|
||||
padding-left: 0.8em;
|
||||
}
|
||||
|
||||
|
@ -5,10 +5,19 @@
|
||||
|
||||
}
|
||||
|
||||
.back-btn {
|
||||
.btn {
|
||||
margin-top: 30px;
|
||||
}
|
||||
|
||||
.content-div {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.qr-code-container {
|
||||
display: none;
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.qr-code-container img {
|
||||
display: inline !important;
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 9.8 KiB |
1
public/js/qrcode.min.js
vendored
Normal file
1
public/js/qrcode.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -9,6 +9,19 @@ $('.result-box').change(function () {
|
||||
$(this).val(original_link);
|
||||
});
|
||||
|
||||
|
||||
$('#generate-qr-code').click(function () {
|
||||
var container = $('.qr-code-container');
|
||||
container.empty();
|
||||
new QRCode(container.get(0), {
|
||||
text: original_link,
|
||||
width: 280,
|
||||
height: 280
|
||||
});
|
||||
container.find('img').attr('alt', original_link);
|
||||
container.show();
|
||||
});
|
||||
|
||||
$(function () {
|
||||
original_link = $('.result-box').val();
|
||||
select_text();
|
||||
|
@ -7,9 +7,15 @@
|
||||
@section('content')
|
||||
<h3>Shortened URL</h3>
|
||||
<input type='text' class='result-box form-control' value='{{$short_url}}' />
|
||||
<a href='{{route('index')}}' class='btn btn-info back-btn'>Shorten another</a>
|
||||
<a id="generate-qr-code" class='btn btn-primary'>Generate QR Code</a>
|
||||
<a href='{{route('index')}}' 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/shorten_result.js'></script>
|
||||
@endsection
|
||||
|
Loading…
Reference in New Issue
Block a user