Skip to content

Commit

Permalink
feat: Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
joeirimpan committed Jan 7, 2023
0 parents commit a699df7
Show file tree
Hide file tree
Showing 15 changed files with 4,717 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/asset/vendor
/build
/language/debug.po
/language/debug.mo
/language/chef.po
/language/chef.mo
/node_modules
/vendor
.sass-cache/
.bundle
.DS_Store
.php_cs.cache
composer.phar
debug.log
Untitled-1.md
674 changes: 674 additions & 0 deletions LICENCE

Large diffs are not rendered by default.

64 changes: 64 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

declare(strict_types=1);

namespace TypesenseSearch;

if (!class_exists(\Generic\AbstractModule::class)) {
require file_exists(dirname(__DIR__) . '/Generic/AbstractModule.php')
? dirname(__DIR__) . '/Generic/AbstractModule.php'
: __DIR__ . '/src/Generic/AbstractModule.php';
}

use Generic\AbstractModule;
// use Laminas\EventManager\Event;
use Laminas\Mvc\MvcEvent;
// use Laminas\EventManager\SharedEventManagerInterface;
use Omeka\Module\Exception\ModuleCannotInstallException;


class Module extends AbstractModule
{
const NAMESPACE = __NAMESPACE__;

public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}

public function onBootstrap(MvcEvent $event): void
{
parent::onBootstrap($event);

// load vendor sdk (eg., typesense-php)
require_once __DIR__ . '/vendor/autoload.php';
}

protected function preInstall(): void
{
if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
$t = $this->getServiceLocator()->get('MvcTranslator');
throw new ModuleCannotInstallException(
$t->translate('The Typesense library should be installed.') // @translate
. ' ' . $t->translate('See module’s installation documentation.') // @translate
);
}
}

// public function attachListeners(SharedEventManagerInterface $sharedEventManager)
// {
// $sharedEventManager->attach(
// '*',
// 'view.layout',
// [$this, 'addTypesense']
// );
// }

// public function addTypesense(Event $event): void
// {
// $view = $event->getTarget();
// $assetUrl = $view->plugin('assetUrl');
// $view->headScript()
// ->appendFile($assetUrl('js/typesense.min.js', 'TypesenseSearch'), 'text/javascript', ['defer' => 'defer']);
// }
}
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Omeka-s Typesense Module

This module allows you to use Typesense as the search engine for your Omeka-s site. Typesense is an open-source, typo-tolerant search engine that delivers fast and relevant search results.

## Installation

* Install the Typesense server. Follow the instructions at https://docs.typesense.org/getting-started/installation/ to install Typesense.

* Install the Typesense PHP client library by running the following command:

```bash
composer require typesense/typesense
```

* Install this module by copying the Typesense directory into the modules directory of your Omeka-s installation.

* Enable the module from the Admin → Modules menu.

* Configure the module by going to the Configure form (located at /admin/module/Typesense). Enter the host and API key for your Typesense server.

## Configuration

The configuration form for this module allows you to specify the following options:

* Typesense Host: The hostname of your Typesense server.

* API Key: The API key for your Typesense server. This can be found in the Typesense Admin Dashboard.

## Usage

Once the module is installed and configured, search on your Omeka-s site will be powered by Typesense.
2 changes: 2 additions & 0 deletions asset/js/typesense.min.js

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"require": {
"laminas/laminas-mvc": "^3.3",
"php-http/curl-client": "^2.2",
"typesense/typesense-php": "^4.8",
"symfony/http-client": "^5.4"
}
}
Loading

0 comments on commit a699df7

Please sign in to comment.