Merge pull request #758 from jonnybarnes/develop

MTM 2023 Redesign v1
This commit is contained in:
Jonny Barnes 2023-04-08 17:07:18 +01:00 • committed by GitHub
commit 22447b6027
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
74 changed files with 2527 additions and 3455 deletions

View file

@ -1,59 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\Bookmark;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyndicateBookmarkToTwitter implements ShouldQueue
{
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Create a new job instance.
*/
public function __construct(
protected Bookmark $bookmark
) {
}
/**
* Execute the job.
*
* @throws GuzzleException
*/
public function handle(Client $guzzle): void
{
//send webmention
$response = $guzzle->request(
'POST',
'https://brid.gy/publish/webmention',
[
'form_params' => [
'source' => $this->bookmark->longurl,
'target' => 'https://brid.gy/publish/twitter',
'bridgy_omit_link' => 'maybe',
],
]
);
//parse for syndication URL
if ($response->getStatusCode() === 201) {
$json = json_decode((string) $response->getBody());
$syndicates = $this->bookmark->syndicates;
$syndicates['twitter'] = $json->url;
$this->bookmark->syndicates = $syndicates;
$this->bookmark->save();
}
}
}

View file

@ -1,57 +0,0 @@
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\Note;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyndicateNoteToTwitter implements ShouldQueue
{
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Create a new job instance.
*/
public function __construct(
protected Note $note
) {
}
/**
* Execute the job.
*
*
* @throws GuzzleException
*/
public function handle(Client $guzzle)
{
//send webmention
$response = $guzzle->request(
'POST',
'https://brid.gy/publish/webmention',
[
'form_params' => [
'source' => $this->note->longurl,
'target' => 'https://brid.gy/publish/twitter',
'bridgy_omit_link' => 'maybe',
],
]
);
//parse for syndication URL
if ($response->getStatusCode() == 201) {
$json = json_decode((string) $response->getBody());
$tweet_id = basename(parse_url($json->url, PHP_URL_PATH));
$this->note->tweet_id = $tweet_id;
$this->note->save();
}
}
}

View file

@ -279,50 +279,6 @@ class Note extends Model
return $oEmbed;
}
/**
* Show a specific form of the note for twitter.
*
* That is we swap the contacts names for their known Twitter handles.
*/
public function getTwitterContentAttribute(): string
{
$this->getContacts();
// check for contacts
if ($this->contacts === null || count($this->contacts) === 0) {
return '';
}
// here we check the matched contact from the note corresponds to a contact
// in the database
if (
count(array_unique(array_values($this->contacts))) === 1
&& array_unique(array_values($this->contacts))[0] === null
) {
return '';
}
// swap in Twitter usernames
$swapped = preg_replace_callback(
self::USERNAMES_REGEX,
function ($matches) {
if (is_null($this->contacts[$matches[1]])) {
return $matches[0];
}
$contact = $this->contacts[$matches[1]];
if ($contact->twitter) {
return '@' . $contact->twitter;
}
return $contact->name;
},
$this->getRawOriginal('note')
);
return $this->convertMarkdown($swapped);
}
/**
* Scope a query to select a note via a NewBase60 id.
*/

View file

@ -6,9 +6,7 @@ namespace App\Services;
use App\Exceptions\InternetArchiveException;
use App\Jobs\ProcessBookmark;
use App\Jobs\SyndicateBookmarkToTwitter;
use App\Models\Bookmark;
use App\Models\SyndicationTarget;
use App\Models\Tag;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
@ -47,23 +45,6 @@ class BookmarkService extends Service
$bookmark->tags()->save($tag);
}
$mpSyndicateTo = null;
if (Arr::get($request, 'mp-syndicate-to')) {
$mpSyndicateTo = Arr::get($request, 'mp-syndicate-to');
}
if (Arr::get($request, 'properties.mp-syndicate-to')) {
$mpSyndicateTo = Arr::get($request, 'properties.mp-syndicate-to');
}
$mpSyndicateTo = Arr::wrap($mpSyndicateTo);
foreach ($mpSyndicateTo as $uid) {
$target = SyndicationTarget::where('uid', $uid)->first();
if ($target && $target->service_name === 'Twitter') {
SyndicateBookmarkToTwitter::dispatch($bookmark);
break;
}
}
ProcessBookmark::dispatch($bookmark);
return $bookmark;

View file

@ -6,7 +6,6 @@ namespace App\Services;
use App\Jobs\SendWebMentions;
use App\Jobs\SyndicateNoteToMastodon;
use App\Jobs\SyndicateNoteToTwitter;
use App\Models\Media;
use App\Models\Note;
use App\Models\Place;
@ -50,11 +49,6 @@ class NoteService extends Service
dispatch(new SendWebMentions($note));
// Syndication targets
if (in_array('twitter', $this->getSyndicationTargets($request), true)) {
dispatch(new SyndicateNoteToTwitter($note));
}
if (in_array('mastodon', $this->getSyndicationTargets($request), true)) {
dispatch(new SyndicateNoteToMastodon($note));
}

View file

@ -24,7 +24,7 @@
"laravel/horizon": "^5.0",
"laravel/sanctum": "^3.0",
"laravel/tinker": "^2.0",
"lcobucci/jwt": "^4.0",
"lcobucci/jwt": "^5.0",
"league/commonmark": "^2.0",
"league/flysystem-aws-s3-v3": "^3.0",
"mf2/mf2": "~0.3",

959
composer.lock generated

File diff suppressed because it is too large Load diff

3195
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -4,42 +4,34 @@
"version": "0.0.1",
"repository": "https://github.com/jonnybarnes/jonnybarnes.uk",
"license": "CC0-1.0",
"dependencies": {
"normalize.css": "^8.0.1"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@babel/preset-env": "^7.20.2",
"autoprefixer": "^10.4.13",
"@babel/core": "^7.21.4",
"@babel/preset-env": "^7.21.4",
"@csstools/postcss-oklab-function": "^2.2.0",
"autoprefixer": "^10.4.14",
"babel-loader": "^9.1.2",
"browserlist": "^1.0.1",
"compression-webpack-plugin": "^10.0.0",
"css-loader": "^6.7.3",
"cssnano": "^5.1.15",
"eslint": "^8.34.0",
"cssnano": "^6.0.0",
"eslint": "^8.37.0",
"eslint-webpack-plugin": "^4.0.0",
"mini-css-extract-plugin": "^2.7.2",
"mini-css-extract-plugin": "^2.7.5",
"postcss": "^8.4.21",
"postcss-combine-duplicated-selectors": "^10.0.2",
"postcss-combine-media-query": "^1.0.1",
"postcss-import": "^15.1.0",
"postcss-loader": "^7.0.2",
"stylelint": "^14.16.1",
"stylelint-config-standard": "^29.0.0",
"stylelint-webpack-plugin": "^4.0.0",
"webpack": "^5.75.0",
"postcss-loader": "^7.2.4",
"postcss-nesting": "^11.2.2",
"stylelint": "^15.4.0",
"stylelint-config-standard": "^32.0.0",
"stylelint-webpack-plugin": "^4.1.0",
"webpack": "^5.78.0",
"webpack-cli": "^5.0.1"
},
"scripts": {
"compress": "scripts/compress",
"copy-dist": "cp ./node_modules/normalize.css/normalize.css ./public/assets/frontend/",
"lint:es6": "eslint resources/es/*.js",
"lint:sass": "stylelint --syntax=scss resources/sass/**/*.scss",
"make-orig": "npm run make:css && npm run make:js",
"make": "npm run lint:sass && npm run webpack",
"make:css": "npm run lint:sass && npm run sass && npm run postcss",
"make:js": "npm run lint:es6 && npm run webpack && npm run uglifyjs",
"webpack": "webpack"
"dev": "webpack",
"prod": "NODE_ENV=production webpack"
},
"browserslist": [
"last 2 versions",

4
postcss.config.js vendored
View file

@ -2,6 +2,10 @@ module.exports = {
plugins: {
'postcss-import': {},
'autoprefixer': {},
'@csstools/postcss-oklab-function': {
preserve: true
},
'postcss-nesting': {},
'postcss-combine-media-query': {},
'postcss-combine-duplicated-selectors': {
removeDuplicatedProperties: true,

View file

@ -1,6 +1 @@
/*!***************************************************************************************************************************************************************************!*\
!*** css ./node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[0].use[1]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[0].use[2]!./resources/css/app.css ***!
\***************************************************************************************************************************************************************************/
:root{--font-stack-body:"Whitney SSm A","Whitney SSm B",sans-serif;--font-stack-headings:"Quarto A","Quarto B",serif;--font-stack-monospace:"Operator Mono SSm A","Operator Mono SSm B",monospace;--color-background:#004643;--color-headline:#fffffe;--color-paragraph:#abd1c6;--color-button:#f9bc60;--color-button-text:#001e1d;--color-stroke:#001e1d;--color-main:#e8e4e6;--color-highlight:#f9bc60;--color-secondary:#abd1c6;--color-tertiary:#e16162}body{-webkit-box-orient:vertical;-webkit-box-direction:normal;background-color:var(--color-background);color:var(--color-paragraph);display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;font-family:var(--font-stack-body);font-size:2rem;font-style:normal;font-weight:400}h1,h2,h3,h4,h5,h6{font-family:var(--font-stack-headings);font-style:normal;font-weight:800}code,pre{font-family:var(--font-stack-monospace);font-style:normal;font-weight:400}a{color:var(--color-highlight);text-decoration:none}.h-feed>.h-entry,.h-feed>.note{margin-top:4rem}main{-webkit-box-orient:vertical;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin:auto}main img{max-width:100%}main .h-entry:first-child>.bookmark-link{padding-top:2rem}.note{-webkit-box-orient:vertical;-ms-flex-direction:column;flex-direction:column}.note,.note-metadata{-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex}.note-metadata{-webkit-box-orient:horizontal;-webkit-box-pack:justify;-ms-flex-pack:justify;-ms-flex-direction:row;flex-direction:row;justify-content:space-between}.note .client{word-break:break-all}.note .syndication-links svg{height:1em;width:1em}.note>.e-content>.naked-link .u-photo{margin:2rem 0}article header>h1{margin-bottom:0}.post-info{font-size:1.4rem}.pagination{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-webkit-box-pack:space-evenly;-ms-flex-pack:space-evenly;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-flow:row wrap;flex-flow:row wrap;justify-content:space-evenly;list-style-type:none;max-width:90vw}.personal-bio{padding:0 2rem}footer{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-align:center;-ms-flex-align:center;align-items:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;margin-top:1.5rem}.iwc-logo{max-width:100%}#top-header{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-box-pack:center;-ms-flex-pack:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:column;flex-direction:column;justify-content:center}#top-header h1{text-align:center;width:100%}nav{-webkit-box-pack:center;-ms-flex-pack:center;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:wrap;flex-wrap:wrap;justify-content:center}nav a{margin:0 .5rem}.post-info a,.syndication-links .u-syndication{text-decoration:none}.hovercard,.p-bridgy-facebook-content,.p-bridgy-twitter-content{display:none}@media screen and (max-width:699px){main{margin-left:5px;margin-right:5px}input{max-width:95vw}footer{margin-left:5px;margin-right:5px}}@media screen and (min-width:700px){main{max-width:700px}main>.h-entry,main>.note{padding:0 1rem}}
/*# sourceMappingURL=app.css.map*/
:root{--font-family-headings:"Archer SSm A","Archer SSm B",serif;--font-family-body:"Verlag A","Verlag B",sans-serif;--font-family-monospace:"Operator Mono SSm A","Operator Mono SSm B",monospace;--font-size-sm:0.75rem;--font-size-base:1rem;--font-size-md:1.25rem;--font-size-lg:1.5rem;--font-size-xl:1.75rem;--font-size-xxl:2rem;--font-size-xxxl:2.25rem;--color-primary:#334800;--color-secondary:#e3ffb5;--color-link:#0064a5;--color-link-visited:#be76ff;--color-primary-shadow:rgba(15,25,0,.4)}@supports (color:color(display-p3 0 0 0)){:root{--color-primary:color(display-p3 0.21567 0.27838 0.03615);--color-secondary:color(display-p3 0.91016 0.99842 0.74082);--color-link:color(display-p3 0.01045 0.38351 0.63618);--color-link-visited:color(display-p3 0.70467 0.47549 0.99958);--color-primary-shadow:color(display-p3 0.06762 0.09646 0.00441/0.4)}}@supports (color:oklch(0% 0 0)){:root{--color-primary:oklch(36.8% 0.1 125.505);--color-secondary:oklch(96.3% 0.1 125.505);--color-link:oklch(48.09% 0.146 241.41);--color-link-visited:oklch(70.44% 0.21 304.41);--color-primary-shadow:oklch(19.56% 0.054 125.505/40%)}}body{background-color:var(--color-secondary);color:var(--color-primary);font-family:var(--font-family-body);font-size:var(--font-size-md)}code{font-family:var(--font-family-monospace)}h1,h2,h3,h4,h5,h6{font-family:var(--font-family-headings)}.grid{display:grid;grid-template-columns:5vw 1fr 5vw;grid-template-rows:-webkit-min-content 1fr -webkit-min-content;grid-template-rows:min-content 1fr min-content;row-gap:1rem}#site-header{grid-column:2/3;grid-row:1/2}main{grid-row:2/3}footer,main{grid-column:2/3}footer{grid-row:3/4}footer .iwc-logo{max-width:85vw}a{color:var(--color-link)}a:visited{color:var(--color-link-visited)}#site-header a:visited{color:var(--color-link)}.hljs{border-radius:.5rem}.p-bridgy-twitter-content{display:none}.h-card .hovercard{-webkit-box-orient:vertical;-webkit-box-direction:normal;background-color:var(--color-secondary);border-radius:1rem;-webkit-box-shadow:0 .5rem .5rem .5rem var(--color-primary-shadow);box-shadow:0 .5rem .5rem .5rem var(--color-primary-shadow);display:none;-ms-flex-direction:column;flex-direction:column;gap:.5rem;opacity:0;padding:1rem;position:absolute;-webkit-transition:opacity .5s ease-in-out;transition:opacity .5s ease-in-out;width:-webkit-fit-content;width:-moz-fit-content;width:fit-content;z-index:100}.h-card .hovercard .u-photo{max-width:6rem}.h-card .hovercard .social-icon{height:1rem;width:1rem}.h-card:hover .hovercard{display:-webkit-box;display:-ms-flexbox;display:flex;opacity:1}.h-entry{-webkit-border-start:1px solid var(--color-primary);-webkit-padding-start:.5rem;border-inline-start:1px solid var(--color-primary);padding-inline-start:.5rem}.h-entry .reply-to{font-style:italic}.h-entry .post-info a{text-decoration:none}.h-entry .note-metadata{-webkit-box-orient:horizontal;-webkit-box-direction:normal;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-direction:row;flex-direction:row;gap:1rem}.h-entry .note-metadata .syndication-links{-webkit-box-orient:horizontal;-webkit-box-direction:normal;-ms-flex-flow:row wrap;flex-flow:row wrap}.h-entry .note-metadata .syndication-links a{text-decoration:none}.h-entry .note-metadata .syndication-links a svg{height:1rem;width:1rem}

Binary file not shown.

68
public/assets/app.js vendored
View file

@ -1,68 +0,0 @@
/******/ (function() { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ "./resources/css/app.css":
/*!*******************************!*\
!*** ./resources/css/app.css ***!
\*******************************/
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
__webpack_require__.r(__webpack_exports__);
// extracted by mini-css-extract-plugin
/***/ })
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
!function() {
/*!*****************************!*\
!*** ./resources/js/app.js ***!
\*****************************/
__webpack_require__.r(__webpack_exports__);
/* harmony import */ var _css_app_css__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../css/app.css */ "./resources/css/app.css");
}();
/******/ })()
;
//# sourceMappingURL=app.js.map

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

View file

@ -2,14 +2,12 @@
This is the code that runs my website, [jonnybarnes.uk](https://jonnybarnes.uk).
In theory this is usable by other now :D
In theory this is usable by others now 🚀
Set up the database, this software needs [PostgreSQL](https://wwwpostgresql.org)
with the [PostGIS](http://postgis.net) plugin. After installing these:
Set up the database, this software needs [PostgreSQL](https://wwwpostgresql.org), after installing:
```shell
$ createdb -E utf8 db_name
$ psql -d db_name -c 'CREATE EXTENSION postgis'
```
First get the code, and make sure you’re on the `master` branch. This branch will
@ -36,12 +34,11 @@ $ php artisan key:generate
$ php artisan migrate
```
Now we need to edit some config values. In `config/app.php` edit `name`, and in
`config/syndication.php` edit it to the appropriate values or set targets to `[]`.
Now we need to edit some config values. In `config/app.php` edit `name`.
Some other things that should be changed. Go to `resources/views/master.blade.php`,
you may not want to link to a projects page. Also in the `<head>` the two last links
are to my profile pic and pgp key, ammend/remove as desired.
Now point your server to `public/index.php` and viola. Essentially this is a
Now point your server to `public/index.php` et viola. Essentially this is a
Laravel app so debugging things shouldn’t be too hard.

10
resources/css/app.css vendored
View file

@ -1,6 +1,6 @@
@import "variables.css";
@import "base.css";
@import "layout/main.css";
@import "link-style.css";
@import "posse.css";
@import "user-profiles.css";
@import "fonts.css";
@import "layout.css";
@import "colours.css";
@import "code.css";
@import "content.css";

View file

@ -1,36 +0,0 @@
body {
font-family: var(--font-stack-body);
font-style: normal;
font-weight: 400;
font-size: 2rem;
background-color: var(--color-background);
color: var(--color-paragraph);
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: var(--font-stack-headings);
font-style: normal;
font-weight: 800;
}
pre,
code {
font-family: var(--font-stack-monospace);
font-style: normal;
font-weight: 400;
}
a {
color: var(--color-highlight);
text-decoration: none;
}
.h-feed > .note,
.h-feed > .h-entry {
margin-top: 4rem;
}

3
resources/css/code.css vendored Normal file
View file

@ -0,0 +1,3 @@
.hljs {
border-radius: .5rem;
}

18
resources/css/colours.css vendored Normal file
View file

@ -0,0 +1,18 @@
body {
background-color: var(--color-secondary);
color: var(--color-primary);
}
a {
color: var(--color-link);
&:visited {
color: var(--color-link-visited);
}
}
#site-header {
& a:visited {
color: var(--color-link);
}
}

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