Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Jan 9, 2021
0 parents commit 8100160
Show file tree
Hide file tree
Showing 37 changed files with 6,667 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
js/src export-ignore
.git* export-ignore

js/dist/*.js -diff
16 changes: 16 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Build JavaScript assets

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- uses: flarum/action-build@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
vendor
composer.lock
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MIT License Copyright (c) 2021 Ian Morland

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 (including the next paragraph) 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.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# HTML Head

![License](https://img.shields.io/badge/license-MIT-blue.svg) [![Latest Stable Version](https://img.shields.io/packagist/v/ianm/htmlhead.svg)](https://packagist.org/packages/ianm/htmlhead)

A [Flarum](http://flarum.org) extension. Add custom items to the <head> array

### Installation

Install manually with composer:

```sh
composer require ianm/htmlhead
```

### Updating

```sh
composer update ianm/htmlhead
```

### Links

- [Packagist](https://packagist.org/packages/ianm/htmlhead)
42 changes: 42 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "ianm/html-head",
"description": "Add custom items to the HTML <head> attributes",
"keywords": [
"flarum", "headers", "html", "head", "custom"
],
"type": "flarum-extension",
"license": "MIT",
"support": {
"issues": "https://github.com/imorland/html-head/issues",
"source": "https://github.com/imorland/html-head",
"forum": "https://discuss.flarum.org"
},
"require": {
"flarum/core": "^0.1.0-beta.15"
},
"authors": [
{
"name": "IanM",
"homepage": "https://discuss.flarum.org/u/ianm"
}
],
"autoload": {
"psr-4": {
"IanM\\HtmlHead\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "HTML Head Items",
"category": "other",
"icon": {
"name": "fas fa-heading",
"backgroundColor": "#008000",
"color": "#fff"
}
},
"flagrow": {
"discuss": ""
}
}
}
43 changes: 43 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

/*
* This file is part of ianm/htmlhead.
*
* Copyright (c) 2021 IanM.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace IanM\HtmlHead;

use Flarum\Extend;
use Flarum\Frontend\Document;
use IanM\HtmlHead\Api\Controllers;
use Illuminate\Database\Eloquent\Collection;

return [

(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/resources/less/admin.less'),

new Extend\Locales(__DIR__ . '/resources/locale'),

(new Extend\Frontend('forum'))
->content(function (Document $document) {
/** @var Collection */
$headCollection = Header::where('active', 1)->get();

/** @var Header $headItem */
foreach ($headCollection as $headItem) {
$document->head[] = $headItem->header;
}
}),

(new Extend\Routes('api'))
->get('/html-headers', 'ianm.html-headers.index', Controllers\ListHeadersController::class)
->post('/html-headers', 'ianm.html-headers.create', Controllers\CreateHeaderItemController::class)
->patch('/html-headers/{id}', 'ianm.html-headers.update', Controllers\UpdateHeaderItemController::class)
->delete('/html-headers/{id}', 'ianm.html-headers.delete', Controllers\DeleteHeaderItemController::class),
];
1 change: 1 addition & 0 deletions js/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/admin';
Loading

0 comments on commit 8100160

Please sign in to comment.