Merge branch 'release/0.0.3'
This commit is contained in:
commit
68e11f4331
12 changed files with 571 additions and 275 deletions
|
@ -11,7 +11,6 @@ DB_PORT=3306
|
||||||
DB_DATABASE=homestead
|
DB_DATABASE=homestead
|
||||||
DB_USERNAME=homestead
|
DB_USERNAME=homestead
|
||||||
DB_PASSWORD=secret
|
DB_PASSWORD=secret
|
||||||
DB_CONNECTION=pgsql
|
|
||||||
|
|
||||||
CACHE_DRIVER=file
|
CACHE_DRIVER=file
|
||||||
SESSION_DRIVER=file
|
SESSION_DRIVER=file
|
||||||
|
|
|
@ -13,10 +13,12 @@ env:
|
||||||
- setup=basic
|
- setup=basic
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.0
|
- 7.0.6
|
||||||
|
- 7.0.7
|
||||||
- nightly
|
- nightly
|
||||||
matrix:
|
matrix:
|
||||||
allow_failures:
|
allow_failures:
|
||||||
|
- php: 7.0.7 # A known bug in PHP 7.0.7 stops phpdbg producing code coverage reports
|
||||||
- php: nightly
|
- php: nightly
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
namespace App;
|
namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Jonnybarnes\UnicodeTools\UnicodeTools;
|
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
use MartinBean\Database\Eloquent\Sluggable;
|
use MartinBean\Database\Eloquent\Sluggable;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
|
@ -57,9 +56,8 @@ class Article extends Model
|
||||||
*/
|
*/
|
||||||
public function getMainAttribute($value)
|
public function getMainAttribute($value)
|
||||||
{
|
{
|
||||||
$unicode = new UnicodeTools();
|
|
||||||
$markdown = new CommonMarkConverter();
|
$markdown = new CommonMarkConverter();
|
||||||
$html = $markdown->convertToHtml($unicode->convertUnicodeCodepoints($value));
|
$html = $markdown->convertToHtml($value);
|
||||||
//change <pre><code>[lang] ~> <pre><code data-language="lang">
|
//change <pre><code>[lang] ~> <pre><code data-language="lang">
|
||||||
$match = '/<pre><code>\[(.*)\]\n/';
|
$match = '/<pre><code>\[(.*)\]\n/';
|
||||||
$replace = '<pre><code class="language-$1">';
|
$replace = '<pre><code class="language-$1">';
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Client;
|
use App\MicropubClient;
|
||||||
|
|
||||||
class ClientsAdminController extends Controller
|
class ClientsAdminController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -13,7 +13,7 @@ class ClientsAdminController extends Controller
|
||||||
*/
|
*/
|
||||||
public function listClients()
|
public function listClients()
|
||||||
{
|
{
|
||||||
$clients = Client::all();
|
$clients = MicropubClient::all();
|
||||||
|
|
||||||
return view('admin.listclients', ['clients' => $clients]);
|
return view('admin.listclients', ['clients' => $clients]);
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ class ClientsAdminController extends Controller
|
||||||
*/
|
*/
|
||||||
public function postNewClient(Request $request)
|
public function postNewClient(Request $request)
|
||||||
{
|
{
|
||||||
Client::create([
|
MicropubClient::create([
|
||||||
'client_url' => $request->input('client_url'),
|
'client_url' => $request->input('client_url'),
|
||||||
'client_name' => $request->input('client_name'),
|
'client_name' => $request->input('client_name'),
|
||||||
]);
|
]);
|
||||||
|
@ -52,7 +52,7 @@ class ClientsAdminController extends Controller
|
||||||
*/
|
*/
|
||||||
public function editClient($clientId)
|
public function editClient($clientId)
|
||||||
{
|
{
|
||||||
$client = Client::findOrFail($clientId);
|
$client = MicropubClient::findOrFail($clientId);
|
||||||
|
|
||||||
return view('admin.editclient', [
|
return view('admin.editclient', [
|
||||||
'id' => $clientId,
|
'id' => $clientId,
|
||||||
|
@ -70,7 +70,7 @@ class ClientsAdminController extends Controller
|
||||||
*/
|
*/
|
||||||
public function postEditClient($clientId, Request $request)
|
public function postEditClient($clientId, Request $request)
|
||||||
{
|
{
|
||||||
$client = Client::findOrFail($clientId);
|
$client = MicropubClient::findOrFail($clientId);
|
||||||
if ($request->input('edit')) {
|
if ($request->input('edit')) {
|
||||||
$client->client_url = $request->input('client_url');
|
$client->client_url = $request->input('client_url');
|
||||||
$client->client_name = $request->input('client_name');
|
$client->client_name = $request->input('client_name');
|
||||||
|
|
|
@ -155,17 +155,9 @@ class NotesController extends Controller
|
||||||
*/
|
*/
|
||||||
public function taggedNotes($tag)
|
public function taggedNotes($tag)
|
||||||
{
|
{
|
||||||
$tag = mb_strtolower(
|
$notes = Note::whereHas('tags', function ($query) use ($tag) {
|
||||||
preg_replace(
|
$query->where('tag', $tag);
|
||||||
'/&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/i',
|
})->get();
|
||||||
'$1',
|
|
||||||
htmlentities($tag)
|
|
||||||
),
|
|
||||||
'UTF-8'
|
|
||||||
);
|
|
||||||
|
|
||||||
$tagId = Tag::where('tag', $tag)->pluck('id');
|
|
||||||
$notes = Tag::find($tagId)->notes()->orderBy('updated_at', 'desc')->get();
|
|
||||||
foreach ($notes as $note) {
|
foreach ($notes as $note) {
|
||||||
$note->iso8601_time = $note->updated_at->toISO8601String();
|
$note->iso8601_time = $note->updated_at->toISO8601String();
|
||||||
$note->human_time = $note->updated_at->diffForHumans();
|
$note->human_time = $note->updated_at->diffForHumans();
|
||||||
|
|
|
@ -4,7 +4,7 @@ namespace App;
|
||||||
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
class Client extends Model
|
class MicropubClient extends Model
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The table associated with the model.
|
* The table associated with the model.
|
|
@ -5,7 +5,6 @@ namespace App;
|
||||||
use Normalizer;
|
use Normalizer;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Jonnybarnes\UnicodeTools\UnicodeTools;
|
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
use Illuminate\Database\Eloquent\SoftDeletes;
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
||||||
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
use Spatie\MediaLibrary\HasMedia\HasMediaTrait;
|
||||||
|
@ -98,10 +97,8 @@ class Note extends Model implements HasMedia
|
||||||
*/
|
*/
|
||||||
public function getNoteAttribute($value)
|
public function getNoteAttribute($value)
|
||||||
{
|
{
|
||||||
$unicode = new UnicodeTools();
|
|
||||||
$codepoints = $unicode->convertUnicodeCodepoints($value);
|
|
||||||
$markdown = new CommonMarkConverter();
|
$markdown = new CommonMarkConverter();
|
||||||
$html = $markdown->convertToHtml($codepoints);
|
$html = $markdown->convertToHtml($value);
|
||||||
$hcards = $this->makeHCards($html);
|
$hcards = $this->makeHCards($html);
|
||||||
$hashtags = $this->autoLinkHashtag($hcards);
|
$hashtags = $this->autoLinkHashtag($hcards);
|
||||||
|
|
||||||
|
@ -150,7 +147,7 @@ class Note extends Model implements HasMedia
|
||||||
if ($this->client_id == null) {
|
if ($this->client_id == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$name = Client::where('client_url', $this->client_id)->value('client_name');
|
$name = MicropubClient::where('client_url', $this->client_id)->value('client_name');
|
||||||
if ($name == null) {
|
if ($name == null) {
|
||||||
$url = parse_url($this->client_id);
|
$url = parse_url($this->client_id);
|
||||||
if (isset($url['path'])) {
|
if (isset($url['path'])) {
|
||||||
|
@ -216,7 +213,7 @@ class Note extends Model implements HasMedia
|
||||||
foreach ($matches[0] as $name) {
|
foreach ($matches[0] as $name) {
|
||||||
$name = str_replace('#', '', $name);
|
$name = str_replace('#', '', $name);
|
||||||
$replacements[$name] =
|
$replacements[$name] =
|
||||||
'<a rel="tag" class="p-category" href="/notes/tagged/' . $name . '">#' . $name . '</a>';
|
'<a rel="tag" class="p-category" href="/notes/tagged/' . Tag::normalizeTag($name) . '">#' . $name . '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace #tags with valid microformat-enabled link
|
// Replace #tags with valid microformat-enabled link
|
||||||
|
|
|
@ -5,7 +5,6 @@ namespace App\Providers;
|
||||||
use App\Tag;
|
use App\Tag;
|
||||||
use App\Note;
|
use App\Note;
|
||||||
use Validator;
|
use Validator;
|
||||||
use Jonnybarnes\IndieWeb\NotePrep;
|
|
||||||
use Illuminate\Support\ServiceProvider;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AppServiceProvider extends ServiceProvider
|
class AppServiceProvider extends ServiceProvider
|
||||||
|
@ -32,11 +31,14 @@ class AppServiceProvider extends ServiceProvider
|
||||||
|
|
||||||
//Add tags for notes
|
//Add tags for notes
|
||||||
Note::created(function ($note) {
|
Note::created(function ($note) {
|
||||||
$noteprep = new NotePrep();
|
|
||||||
$tagsToAdd = [];
|
$tagsToAdd = [];
|
||||||
$tags = $noteprep->getTags($note->note);
|
preg_match_all('/#([^\s<>]+)\b/', $note, $tags);
|
||||||
foreach ($tags as $text) {
|
foreach ($tags[1] as $tag) {
|
||||||
$tag = Tag::firstOrCreate(['tag' => $text]);
|
$tag = Tag::normalizeTag($tag);
|
||||||
|
}
|
||||||
|
$tags = array_unique($tags[1]);
|
||||||
|
foreach ($tags as $tag) {
|
||||||
|
$tag = Tag::firstOrCreate(['tag' => $tag]);
|
||||||
$tagsToAdd[] = $tag->id;
|
$tagsToAdd[] = $tag->id;
|
||||||
}
|
}
|
||||||
if (count($tagsToAdd > 0)) {
|
if (count($tagsToAdd > 0)) {
|
||||||
|
|
28
app/Tag.php
28
app/Tag.php
|
@ -36,4 +36,32 @@ class Tag extends Model
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $guarded = ['id'];
|
protected $guarded = ['id'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize tags so they’re lowercase and fancy diatrics are removed.
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
public function setTagAttribute($value)
|
||||||
|
{
|
||||||
|
$this->attributes['tag'] = $this->normalizeTag($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method actually normalizes a tag. That means lowercase-ing and
|
||||||
|
* removing fancy diatric characters.
|
||||||
|
*
|
||||||
|
* @param string
|
||||||
|
*/
|
||||||
|
public static function normalizeTag($tag)
|
||||||
|
{
|
||||||
|
return mb_strtolower(
|
||||||
|
preg_replace(
|
||||||
|
'/&([a-z]{1,2})(acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/i',
|
||||||
|
'$1',
|
||||||
|
htmlentities($tag)
|
||||||
|
),
|
||||||
|
'UTF-8'
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version 0.0.3 (2013-06-09)
|
||||||
|
- Better tag normalization code organisation
|
||||||
|
- Remove `jonnybarnes/unicode-tools` dependency and clean up relevant code
|
||||||
|
|
||||||
## Version 0.0.2 (2016-05-25)
|
## Version 0.0.2 (2016-05-25)
|
||||||
- Fix issue#1: tagged notes page needs the tag from the URL normalizing.
|
- Fix issue#1: tagged notes page needs the tag from the URL normalizing.
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
"ext-intl": "*",
|
"ext-intl": "*",
|
||||||
"php": ">=7.0.0",
|
"php": ">=7.0.0",
|
||||||
"laravel/framework": "5.2.*",
|
"laravel/framework": "5.2.*",
|
||||||
"jonnybarnes/unicode-tools": "dev-master",
|
|
||||||
"jonnybarnes/indieweb": "dev-master",
|
"jonnybarnes/indieweb": "dev-master",
|
||||||
"jonnybarnes/webmentions-parser": "dev-master",
|
"jonnybarnes/webmentions-parser": "dev-master",
|
||||||
"guzzlehttp/guzzle": "~6.0",
|
"guzzlehttp/guzzle": "~6.0",
|
||||||
|
@ -21,24 +20,18 @@
|
||||||
"league/commonmark": "^0.13.0",
|
"league/commonmark": "^0.13.0",
|
||||||
"spatie/laravel-medialibrary": "^3.5",
|
"spatie/laravel-medialibrary": "^3.5",
|
||||||
"league/flysystem-aws-s3-v3": "^1.0",
|
"league/flysystem-aws-s3-v3": "^1.0",
|
||||||
"phaza/laravel-postgis": "dev-master",
|
"phaza/laravel-postgis": "~3.1",
|
||||||
"lcobucci/jwt": "^3.1"
|
"lcobucci/jwt": "^3.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"fzaninotto/faker": "~1.4",
|
"fzaninotto/faker": "~1.4",
|
||||||
"mockery/mockery": "0.9.*",
|
"mockery/mockery": "0.9.*",
|
||||||
"phpunit/phpunit": "~4.0",
|
"phpunit/phpunit": "~5.0",
|
||||||
"symfony/css-selector": "2.8.*|3.0.*",
|
"symfony/css-selector": "2.8.*|3.0.*",
|
||||||
"symfony/dom-crawler": "2.8.*|3.0.*",
|
"symfony/dom-crawler": "2.8.*|3.0.*",
|
||||||
"barryvdh/laravel-debugbar": "~2.0",
|
"barryvdh/laravel-debugbar": "~2.0",
|
||||||
"filp/whoops": "~2.0"
|
"filp/whoops": "~2.0"
|
||||||
},
|
},
|
||||||
"repositories": [
|
|
||||||
{
|
|
||||||
"type": "vcs",
|
|
||||||
"url": "https://github.com/njbarrett/laravel-postgis"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
"database"
|
"database"
|
||||||
|
|
747
composer.lock
generated
747
composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue