Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkwinkelmann committed Nov 6, 2022
0 parents commit 8caf968
Show file tree
Hide file tree
Showing 18 changed files with 2,530 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
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
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
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2022 Clark Winkelmann

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.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Meilisearch dashboard

[![MIT license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/clarkwinkelmann/flarum-ext-meilisearch-dashboard/blob/master/LICENSE.md) [![Latest Stable Version](https://img.shields.io/packagist/v/clarkwinkelmann/flarum-ext-meilisearch-dashboard.svg)](https://packagist.org/packages/clarkwinkelmann/flarum-ext-meilisearch-dashboard) [![Total Downloads](https://img.shields.io/packagist/dt/clarkwinkelmann/flarum-ext-meilisearch-dashboard.svg)](https://packagist.org/packages/clarkwinkelmann/flarum-ext-meilisearch-dashboard) [![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.me/clarkwinkelmann)

This is a companion extension for Scout. It provides a proxied access to the Meilisearch HTTP dashboard through Flarum at `/meilisearch/`.

Access control is done through Flarum permissions.

Meilisearch only offers the dashboard when running in development mode.
In production mode, this extension will just proxy the error page.

## Installation

composer require clarkwinkelmann/flarum-ext-meilisearch-dashboard

## Support

This extension is under **minimal maintenance**.

It was developed for a client and released as open-source for the benefit of the community.
I might publish simple bugfixes or compatibility updates for free.

You can [contact me](https://clarkwinkelmann.com/flarum) to sponsor additional features or updates.

Support is offered on a "best effort" basis through the Flarum community thread.

## Links

- [GitHub](https://github.com/clarkwinkelmann/flarum-ext-meilisearch-dashboard)
- [Packagist](https://packagist.org/packages/clarkwinkelmann/flarum-ext-meilisearch-dashboard)
42 changes: 42 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "clarkwinkelmann/flarum-ext-meilisearch-dashboard",
"description": "Proxy for Meilisearch HTTP dashboard",
"keywords": [
"flarum",
"meilisearch"
],
"type": "flarum-extension",
"license": "MIT",
"require": {
"flarum/core": "^1.2",
"clarkwinkelmann/flarum-ext-scout": "*",
"guzzlehttp/guzzle": "^7.0",
"ext-json": "*"
},
"authors": [
{
"name": "Clark Winkelmann",
"email": "[email protected]",
"role": "Developer"
}
],
"support": {
"source": "https://github.com/clarkwinkelmann/flarum-ext-meilisearch-dashboard"
},
"autoload": {
"psr-4": {
"ClarkWinkelmann\\MeilisearchDashboard\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "Meilisearch Dashboard",
"category": "feature",
"icon": {
"name": "fas fa-search",
"backgroundColor": "#f47f68",
"color": "#fff"
}
}
}
}
19 changes: 19 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

namespace ClarkWinkelmann\MeilisearchDashboard;

use Flarum\Api\Serializer\ForumSerializer;
use Flarum\Extend;

return [
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),

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

(new Extend\ApiSerializer(ForumSerializer::class))
->attributes(ForumAttributes::class),

(new Extend\Middleware('forum'))
->insertBefore('flarum.forum.route_resolver', MeilisearchDashboardMiddleware::class),
];
1 change: 1 addition & 0 deletions js/admin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './src/admin';
2 changes: 2 additions & 0 deletions js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions js/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@clarkwinkelmann/meilisearch-dashboard",
"private": true,
"dependencies": {
"flarum-tsconfig": "^1.0",
"flarum-webpack-config": "^2.0",
"webpack": "^5.65",
"webpack-cli": "^4.9"
},
"scripts": {
"dev": "webpack --mode development --watch",
"build": "webpack --mode production"
}
}
29 changes: 29 additions & 0 deletions js/src/admin/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import app from 'flarum/admin/app';
import {extend} from 'flarum/common/extend';
import SessionDropdown from 'flarum/admin/components/SessionDropdown';
import LinkButton from 'flarum/common/components/LinkButton';
import Separator from 'flarum/common/components/Separator';

app.initializers.add('clarkwinkelmann-meilisearch-dashboard', () => {
app.extensionData.for('clarkwinkelmann-meilisearch-dashboard')
.registerPermission({
permission: 'meilisearch-dashboard.access',
label: app.translator.trans('clarkwinkelmann-meilisearch-dashboard.admin.permission.access'),
icon: 'fas fa-search',
}, 'moderate');


extend(SessionDropdown.prototype, 'items', function (items) {
items.add('meilisearch-dashboard', LinkButton.component({
icon: 'fas fa-search',
href: app.forum.attribute('baseUrl') + '/meilisearch/',
external: true,
}, app.translator.trans('clarkwinkelmann-meilisearch-dashboard.admin.header.link')));

// Add a separator between links and logout button, just like in the forum frontend
// Flamarkt Backoffice does the same thing
if (!items.has('separator')) {
items.add('separator', Separator.component(), -90);
}
});
});
16 changes: 16 additions & 0 deletions js/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "flarum-tsconfig",
"include": [
"src/**/*",
"../vendor/flarum/core/js/dist-typings/@types/**/*"
],
"files": [],
"compilerOptions": {
"baseUrl": ".",
"paths": {
"flarum/*": [
"../vendor/flarum/core/js/dist-typings/*"
]
}
}
}
1 change: 1 addition & 0 deletions js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('flarum-webpack-config')();
Loading

0 comments on commit 8caf968

Please sign in to comment.