Work so far in refactoring front-end

- Mainly getting rid of existing css/js
- No longer linking to stuff like a11y.css
- Creating a FrontPageController to better deal with the home page
This commit is contained in:
Jonny Barnes 2019-07-26 10:40:56 +01:00
parent 30f9b0f557
commit 5ef23376be
135 changed files with 7461 additions and 100 deletions

View file

@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use Exception;
use App\Models\Like;
use App\Models\Note;
use App\Models\Article;
use App\Models\Bookmark;
class FrontPageController extends Controller
{
/**
* Show all the recent activity.
*/
public function index()
{
$pageNumber = request()->query('page') ?? 1;
$notes = Note::latest()->get();
$articles = Article::latest()->get();
$bookmarks = Bookmark::latest()->get();
$likes = Like::latest()->get();
$allItems = collect($notes)
->merge($articles)
->merge($bookmarks)
->merge($likes)
->sortByDesc('updated_at')
->chunk(10);
$totalNumPages = $allItems->count();
$page = $allItems->get($pageNumber - 1);
if (is_null($page)) {
abort(404);
}
return view('front-page', [
'items' => $page,
]);
}
}

View file

@ -2,9 +2,13 @@
use App\Models\Note;
use Faker\Generator as Faker;
use Illuminate\Support\Carbon;
$factory->define(Note::class, function (Faker $faker) {
$now = Carbon::now()->subDays(rand(5, 15));
return [
'note' => $faker->paragraph,
'created_at' => $now,
'updated_at' => $now,
];
});

View file

@ -1,7 +1,9 @@
<?php
use App\Models\Article;
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ArticlesTableSeeder extends Seeder
{
@ -12,12 +14,18 @@ class ArticlesTableSeeder extends Seeder
*/
public function run()
{
Article::create([
$now = Carbon::now()->subMonth();
$articleFirst = Article::create([
'title' => 'My New Blog',
'main' => 'This is *my* new blog. It uses `Markdown`.',
'published' => 1,
'created_at' => $now,
]);
DB::table('articles')
->where('id', $articleFirst->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(2)->subMinutes(25);
$articleWithCode = <<<EOF
I wrote some code.
@ -37,10 +45,14 @@ class Foo
}
```
EOF;
Article::create([
$articleSecond = Article::create([
'title' => 'Some code I did',
'main' => $articleWithCode,
'published' => 1,
'created_at' => $now,
]);
DB::table('articles')
->where('id', $articleSecond->id)
->update(['updated_at' => $now->toDateTimeString()]);
}
}

View file

@ -1,7 +1,9 @@
<?php
use Illuminate\Support\Carbon;
use App\Models\{Bookmark, Tag};
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class BookmarksTableSeeder extends Seeder
{
@ -14,6 +16,14 @@ class BookmarksTableSeeder extends Seeder
{
factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
$bookmark->tags()->save(factory(Tag::class)->make());
$now = Carbon::now()->subDays(rand(2, 12));
DB::table('bookmarks')
->where('id', $bookmark->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
});
}
}

View file

@ -2,7 +2,9 @@
use App\Models\Like;
use Faker\Generator;
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class LikesTableSeeder extends Seeder
{
@ -13,20 +15,40 @@ class LikesTableSeeder extends Seeder
*/
public function run()
{
factory(Like::class, 10)->create();
sleep(1);
factory(Like::class, 10)->create()->each(function ($like) {
$now = Carbon::now()->subDays(rand(5, 15));
DB::table('likes')
->where('id', $like->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
});
$now = Carbon::now()->subDays(rand(3, 6));
$faker = new Generator();
$faker->addProvider(new \Faker\Provider\en_US\Person($faker));
$faker->addProvider(new \Faker\Provider\Lorem($faker));
$faker->addProvider(new \Faker\Provider\Internet($faker));
Like::create([
$likeFromAuthor = Like::create([
'url' => $faker->url,
'author_url' => $faker->url,
'author_name' => $faker->name,
]);
sleep(1);
DB::table('likes')
->where('id', $likeFromAuthor->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
Like::create(['url' => 'https://example.com']);
$now = Carbon::now()->subHours(rand(3, 6));
$likeJustUrl = Like::create(['url' => 'https://example.com']);
DB::table('likes')
->where('id', $likeJustUrl->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
}
}

View file

@ -1,6 +1,8 @@
<?php
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\{Media, Note, Place};
class NotesTableSeeder extends Seeder
@ -12,103 +14,175 @@ class NotesTableSeeder extends Seeder
*/
public function run()
{
factory(Note::class, 10)->create();
sleep(1);
//factory(Note::class, 10)->create();
$now = Carbon::now()->subDays(rand(2, 5));
$noteTwitterReply = Note::create([
'note' => 'What does this even mean?',
'in_reply_to' => 'https://twitter.com/realDonaldTrump/status/933662564587855877',
'created_at' => $now,
]);
sleep(1);
DB::table('notes')
->where('id', $noteTwitterReply->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(2, 5));
$noteWithPlace = Note::create([
'note' => 'Having a #beer at the local. 🍺',
'created_at' => $now,
]);
$noteWithPlace->tweet_id = '123456789';
$place = Place::find(1);
$noteWithPlace->place()->associate($place);
$noteWithPlace->save();
sleep(1);
DB::table('notes')
->where('id', $noteWithPlace->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(3, 6));
$noteWithPlaceTwo = Note::create([
'note' => 'Its really good',
'created_at' => $now,
]);
$place = Place::find(1);
$noteWithPlaceTwo->place()->associate($place);
$noteWithPlaceTwo->save();
sleep(1);
DB::table('notes')
->where('id', $noteWithPlaceTwo->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(4, 8));
$noteWithContact = Note::create([
'note' => 'Hi @tantek'
'note' => 'Hi @tantek',
'created_at' => $now,
]);
sleep(1);
DB::table('notes')
->where('id', $noteWithContact->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(1, 10));
$noteWithContactPlusPic = Note::create([
'note' => 'Hi @aaron',
'client_id' => 'https://jbl5.dev/notes/new'
'client_id' => 'https://jbl5.dev/notes/new',
'created_at' => $now,
]);
sleep(1);
DB::table('notes')
->where('id', $noteWithContactPlusPic->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(2, 5));
$noteWithoutContact = Note::create([
'note' => 'Hi @bob',
'client_id' => 'https://quill.p3k.io'
'client_id' => 'https://quill.p3k.io',
'created_at' => $now,
]);
sleep(1);
DB::table('notes')
->where('id', $noteWithoutContact->id)
->update(['updated_at' => $now->toDateTimeString()]);
//copy aarons profile pic in place
$spl = new SplFileInfo(public_path() . '/assets/profile-images/aaronparecki.com');
if ($spl->isDir() === false) {
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image');
}
$now = Carbon::now()->subDays(rand(3, 7));
$noteWithCoords = Note::create([
'note' => 'Note from a town',
'created_at' => $now,
]);
DB::table('notes')
->where('id', $noteWithCoords->id)
->update(['updated_at' => $now->toDateTimeString()]);
$noteWithCoords->location = '53.499,-2.379';
$noteWithCoords->save();
sleep(1);
$noteWithCoords2 = Note::create([
'note' => 'Note from a city',
'created_at' => $now,
]);
$noteWithCoords2->location = '53.9026894,-2.42250444118781';
$noteWithCoords2->save();
sleep(1);
DB::table('notes')
->where('id', $noteWithCoords2->id)
->update(['updated_at' => $now->toDateTimeString()]);
$noteWithCoords3 = Note::create([
'note' => 'Note from a county',
'created_at' => $now,
]);
$noteWithCoords3->location = '57.5066357,-5.0038367';
$noteWithCoords3->save();
sleep(1);
DB::table('notes')
->where('id', $noteWithCoords3->id)
->update(['updated_at' => $now->toDateTimeString()]);
$noteWithCoords4 = Note::create([
'note' => 'Note from a country',
'created_at' => $now,
]);
$noteWithCoords4->location = '63.000147,-136.002502';
$noteWithCoords4->save();
sleep(1);
DB::table('notes')
->where('id', $noteWithCoords4->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(7);
$noteSyndicated = Note::create([
'note' => 'This note has all the syndication targets',
'created_at' => $now,
]);
$noteSyndicated->tweet_id = '123456';
$noteSyndicated->facebook_url = 'https://www.facebook.com/post/12345789';
$noteSyndicated->swarm_url = 'https://www.swarmapp.com/checking/123456789';
$noteSyndicated->instagram_url = 'https://www.instagram.com/p/aWsEd123Jh';
$noteSyndicated->save();
sleep(1);
DB::table('notes')
->where('id', $noteSyndicated->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(6);
$noteWithTextLinkandEmoji = Note::create([
'note' => 'I love https://duckduckgo.com 💕' // theres a two-heart emoji at the end of this
'note' => 'I love https://duckduckgo.com 💕', // theres a two-heart emoji at the end of this
'created_at' => $now,
]);
sleep(1);
DB::table('notes')
->where('id', $noteWithTextLinkandEmoji->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(5);
$noteJustCheckin = new Note();
$noteJustCheckin->setCreatedAt($now);
$place = Place::find(1);
$noteJustCheckin->place()->associate($place);
$noteJustCheckin->save();
sleep(1);
DB::table('notes')
->where('id', $noteJustCheckin->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(4);
$media = new Media();
$media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg';
$media->type = 'image';
$media->image_widths = '3648';
$media->save();
$noteWithOnlyImage = new Note();
$noteWithOnlyImage->setCreatedAt($now);
$noteWithOnlyImage->setUpdatedAt($now);
$noteWithOnlyImage->save();
$noteWithOnlyImage->media()->save($media);
sleep(1);
DB::table('notes')
->where('id', $noteWithOnlyImage->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(3);
$noteCapitalHashtag = Note::create([
'note' => 'A #TwoWord hashtag',
'created_at' => $now,
]);
sleep(1);
DB::table('notes')
->where('id', $noteCapitalHashtag->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(2);
$noteWithCodeContent = <<<EOF
A note with some code:
```php
@ -118,6 +192,10 @@ echo 'Hello World';
EOF;
$noteWithCode = Note::create([
'note' => $noteWithCodeContent,
'created_at' => $now,
]);
DB::table('notes')
->where('id', $noteWithCode->id)
->update(['updated_at' => $now->toDateTimeString()]);
}
}

7035
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -9,18 +9,27 @@
"puppeteer": "^1.18.1"
},
"devDependencies": {
"css-loader": "^3.1.0",
"husky": "^3.0.0",
"lint-staged": "^9.2.0",
"pre-commit": "^1.1.3"
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.12.0",
"pre-commit": "^1.1.3",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"stylelint": "^10.1.0",
"webpack": "^4.36.1",
"webpack-cli": "^3.3.6"
},
"scripts": {
"compress": "scripts/compress",
"copy-dist": "cp ./node_modules/normalize.css/normalize.css ./public/assets/frontend/",
"lint:es6": "eslint resources/es6-orig/*.js",
"lint:sass": "stylelint --syntax=scss resources/sass-orig/**/*.scss",
"lint:es6": "eslint resources/es/*.js",
"lint:sass": "stylelint --syntax=scss resources/sass/**/*.scss",
"make": "npm run make:css && npm run make:js",
"make:css": "npm run lint:sass && npm run sass && npm run postcss",
"make:js": "npm run lint:es6 && npm run webpack && npm run uglifyjs"
"make:js": "npm run lint:es6 && npm run webpack && npm run uglifyjs",
"webpack": "webpack"
},
"husky": {
"hooks": {

5
public/assets/app.css vendored Normal file
View file

@ -0,0 +1,5 @@
body {
font-family: "Comic Sans MS", cursive; }
/*# sourceMappingURL=app.css.map*/

View file

@ -0,0 +1 @@
{"version":3,"sources":["webpack:///./resources/sass/app.scss"],"names":[],"mappings":"AAAA;EACI,qCAAqC","file":"app.css","sourcesContent":["body {\n font-family: \"Comic Sans MS\", cursive;\n}\n"],"sourceRoot":""}

Some files were not shown because too many files have changed in this diff Show more