Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkwinkelmann committed Apr 4, 2018
0 parents commit ac761f1
Show file tree
Hide file tree
Showing 16 changed files with 2,959 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
[*.md]
indent_size = 2
trim_trailing_whitespace = false
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.gitattributes export-ignore
.github export-ignore
.gitignore export-ignore
.gitmodules export-ignore
js/*/src export-ignore
js/*/Gulfile.js
js/*/package.json
js/*/yarn.lock

js/*/dist/*.js -diff
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
js/*/node_modules
vendor/
composer.lock
21 changes: 21 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) Flagrow

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Custom HTML Error Pages by ![Flagrow logo](https://avatars0.githubusercontent.com/u/16413865?v=3&s=20) [Flagrow](https://discuss.flarum.org/d/1832-flagrow-extension-developer-group), a project of [Gravure](https://gravure.io/)

[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/flagrow/html-errors/blob/master/LICENSE.md) [![Latest Stable Version](https://img.shields.io/packagist/v/flagrow/html-errors.svg)](https://packagist.org/packages/flagrow/html-errors) [![Total Downloads](https://img.shields.io/packagist/dt/flagrow/html-errors.svg)](https://packagist.org/packages/flagrow/html-errors) [![Donate](https://img.shields.io/badge/patreon-support-yellow.svg)](https://www.patreon.com/flagrow) [![Join our Discord server](https://discordapp.com/api/guilds/240489109041315840/embed.png)](https://flagrow.io/join-discord)

This extension allows you to customize the Flarum error pages.
By default these pages have very boring HTML content with no styling and no link in beta7.
Now you can change them to something that better reflects your website!

## Installation

Use [Bazaar](https://discuss.flarum.org/d/5151-flagrow-bazaar-the-extension-marketplace) or install manually:

```bash
composer require flagrow/html-errors
```

## Updating

```bash
composer update flagrow/html-errors
php flarum migrate
php flarum cache:clear
```

## Configuration

Open the extension options to configure the custom HTML.
Leaving a field empty will show the default Flarum error page.

The custom error pages are only applied when browsing the forum front-end.
Any error response under /api or /admin is unaffected.

You can handle additional error codes by entering the values manually in the `settings` table of the database.

## Support our work

We prefer to keep our work available to everyone.
In order to do so we rely on voluntary contributions on [Patreon](https://www.patreon.com/flagrow).

## Security

If you discover a security vulnerability within Custom HTML Error Pages, please send an email to the Gravure team at [email protected]. All security vulnerabilities will be promptly addressed.

Please include as many details as possible. You can use `php flarum info` to get the PHP, Flarum and extension versions installed.

## Links

- [Flarum Discuss post](https://discuss.flarum.org/d/10784-custom-html-error-pages)
- [Source code on GitHub](https://github.com/flagrow/html-errors)
- [Report an issue](https://github.com/flagrow/html-errors/issues)
- [Download via Packagist](https://packagist.org/packages/flagrow/html-errors)

An extension by [Flagrow](https://flagrow.io/), a project of [Gravure](https://gravure.io/).
10 changes: 10 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Flagrow\HtmlErrors;

use Illuminate\Contracts\Events\Dispatcher;

return function (Dispatcher $events) {
$events->subscribe(Listeners\Assets::class);
$events->subscribe(Listeners\Middlewares::class);
};
45 changes: 45 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "flagrow/html-errors",
"description": "Add custom HTML error pages",
"keywords": [
"extension",
"flarum",
"error",
"page",
"html"
],
"type": "flarum-extension",
"license": "MIT",
"authors": [
{
"name": "Clark Winkelmann",
"email": "[email protected]",
"homepage": "https://clarkwinkelmann.com/"
}
],
"support": {
"issues": "https://github.com/flagrow/html-errors/issues",
"source": "https://github.com/flagrow/html-errors"
},
"require": {
"flarum/core": "^0.1.0-beta.7"
},
"extra": {
"flarum-extension": {
"title": "Flagrow HTML Errors",
"icon": {
"name": "exclamation-circle",
"backgroundColor": "#f4f4f4",
"color": "#5f4bb6"
}
},
"flagrow": {
"discuss": "https://discuss.flarum.org/d/10784-custom-html-error-pages"
}
},
"autoload": {
"psr-4": {
"Flagrow\\HtmlErrors\\": "src/"
}
}
}
7 changes: 7 additions & 0 deletions js/admin/Gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const gulp = require('flarum-gulp');

gulp({
modules: {
'flagrow/html-errors': 'src/**/*.js'
}
});
78 changes: 78 additions & 0 deletions js/admin/dist/extension.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
'use strict';

System.register('flagrow/html-errors/components/ErrorSettingsModal', ['flarum/app', 'flarum/components/SettingsModal'], function (_export, _context) {
"use strict";

var app, SettingsModal, settingsPrefix, translationPrefix, ErrorSettingsModal;
return {
setters: [function (_flarumApp) {
app = _flarumApp.default;
}, function (_flarumComponentsSettingsModal) {
SettingsModal = _flarumComponentsSettingsModal.default;
}],
execute: function () {
settingsPrefix = 'flagrow-html-errors.';
translationPrefix = 'flagrow-html-errors.admin.settings.';

ErrorSettingsModal = function (_SettingsModal) {
babelHelpers.inherits(ErrorSettingsModal, _SettingsModal);

function ErrorSettingsModal() {
babelHelpers.classCallCheck(this, ErrorSettingsModal);
return babelHelpers.possibleConstructorReturn(this, (ErrorSettingsModal.__proto__ || Object.getPrototypeOf(ErrorSettingsModal)).apply(this, arguments));
}

babelHelpers.createClass(ErrorSettingsModal, [{
key: 'title',
value: function title() {
return app.translator.trans(translationPrefix + 'title');
}
}, {
key: 'className',
value: function className() {
return 'Modal--large';
}
}, {
key: 'form',
value: function form() {
var _this2 = this;

return [403, 404, 500, 503].map(function (error) {
return m('.Form-group', [m('label', app.translator.trans(translationPrefix + 'error.' + error)), m('textarea.FormControl', {
bidi: _this2.setting(settingsPrefix + 'custom' + error + 'ErrorHtml'),
placeholder: app.translator.trans(translationPrefix + 'placeholder.empty_for_default')
})]);
});
}
}]);
return ErrorSettingsModal;
}(SettingsModal);

_export('default', ErrorSettingsModal);
}
};
});;
'use strict';

System.register('flagrow/html-errors/main', ['flarum/extend', 'flarum/app', 'flagrow/html-errors/components/ErrorSettingsModal'], function (_export, _context) {
"use strict";

var extend, app, ErrorSettingsModal;
return {
setters: [function (_flarumExtend) {
extend = _flarumExtend.extend;
}, function (_flarumApp) {
app = _flarumApp.default;
}, function (_flagrowHtmlErrorsComponentsErrorSettingsModal) {
ErrorSettingsModal = _flagrowHtmlErrorsComponentsErrorSettingsModal.default;
}],
execute: function () {

app.initializers.add('flagrow-html-errors', function (app) {
app.extensionSettings['flagrow-html-errors'] = function () {
return app.modal.show(new ErrorSettingsModal());
};
});
}
};
});
7 changes: 7 additions & 0 deletions js/admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"private": true,
"devDependencies": {
"gulp": "^3.8.11",
"flarum-gulp": "^0.2.0"
}
}
27 changes: 27 additions & 0 deletions js/admin/src/components/ErrorSettingsModal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import app from 'flarum/app';
import SettingsModal from 'flarum/components/SettingsModal';

const settingsPrefix = 'flagrow-html-errors.';
const translationPrefix = 'flagrow-html-errors.admin.settings.';

export default class ErrorSettingsModal extends SettingsModal {
title() {
return app.translator.trans(translationPrefix + 'title');
}

className() {
return 'Modal--large';
}

form() {
return [403, 404, 500, 503].map(
error => m('.Form-group', [
m('label', app.translator.trans(translationPrefix + 'error.' + error)),
m('textarea.FormControl', {
bidi: this.setting(settingsPrefix + 'custom' + error + 'ErrorHtml'),
placeholder: app.translator.trans(translationPrefix + 'placeholder.empty_for_default'),
}),
])
);
}
}
7 changes: 7 additions & 0 deletions js/admin/src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import {extend} from 'flarum/extend';
import app from 'flarum/app';
import ErrorSettingsModal from 'flagrow/html-errors/components/ErrorSettingsModal';

app.initializers.add('flagrow-html-errors', app => {
app.extensionSettings['flagrow-html-errors'] = () => app.modal.show(new ErrorSettingsModal());
});
Loading

0 comments on commit ac761f1

Please sign in to comment.