Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ jobs:
lint:
needs: build
runs-on: ubuntu-latest
# TODO: Fix the linting errors
# Report the failure, but don't stop the job
continue-on-error: true
env:
COMPOSE_FILE: docker-compose.yml:docker-compose.ci.override.yml
COMPOSE_PROJECT_NAME: ci-${{ github.job }}-${{ github.run_id }}
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ RUN apk add --no-cache \
COPY --from=composer:2.8 /usr/bin/composer /usr/bin/composer
COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
RUN mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini"
COPY php-fpm/99-findingaid.ini $PHP_INI_DIR/conf.d/

WORKDIR /opt/findingaid

Expand Down Expand Up @@ -60,6 +61,7 @@ WORKDIR /app

COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
COPY --from=development /opt/findingaid/vendor /opt/findingaid/vendor
COPY php-fpm/99-findingaid.ini $PHP_INI_DIR/conf.d/
COPY ./phpunit.xml /opt/findingaid/phpunit.xml
COPY /app .

Expand All @@ -82,6 +84,7 @@ RUN apk add --no-cache \
COPY --from=jsmin /usr/bin/jsmin /usr/bin/jsmin
COPY --from=prod-builder /composer/vendor /opt/findingaid/vendor
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
COPY php-fpm/99-findingaid.ini $PHP_INI_DIR/conf.d/

WORKDIR /opt/findingaid

Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
COMPOSE_DEV = docker compose -f docker-compose.yml -f docker-compose.dev.override.yml

.PHONY: help dev build down test lint lint-fix check logs test-watch findingaid-sh web-sh sample
.PHONY: help dev build down test lint lint-fix check logs test-watch lint-watch findingaid-sh web-sh sample

help: ## Show this help
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
Expand Down Expand Up @@ -33,6 +33,9 @@ logs: ## Tail container logs
test-watch: ## Run tests on each file change (requires: watchexec)
watchexec -w app -w public -w tests --no-process-group 'make test'

lint-watch: ## Run linter on each file change (requires: watchexec)
watchexec -w app -w tests --no-process-group 'make lint'

sample: ## Download and extract sample finding aid data (~1GB)
wget -O xml.tar.gz https://solrindex.uky.edu/fa/findingaid/xml.tar.gz
tar zxf xml.tar.gz
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
22 changes: 11 additions & 11 deletions app/config/config.php → app/Config/Config.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php

namespace App\Config;

class Config
{
private $config = [];
Expand All @@ -9,15 +12,15 @@ public function __construct()
{
$config_file = implode(DIRECTORY_SEPARATOR, [
APP,
'config',
'Config',
'config.json',
]);
if (file_exists($config_file)) {
$this->config = json_decode(file_get_contents($config_file), true);
}
$repo_file = implode(DIRECTORY_SEPARATOR, [
APP,
'config',
'Config',
'repo.json',
]);
if (file_exists($repo_file)) {
Expand All @@ -29,28 +32,26 @@ public function get($key)
{
if (array_key_exists($key, $this->config)) {
return $this->config[$key];
}
else {
} else {
return null;
}
}

public function get_repo($key)
public function getRepo($key)
{
if (array_key_exists($key, $this->repo)) {
return $this->repo[$key];
}
else {
} else {
return $this->repo['default'];
}
}

public function get_nonuk($key)
public function getNonUK($key)
{
if (!isset($this->nonuk)) {
$nonuk_config_file = implode(DIRECTORY_SEPARATOR, [
APP,
'config',
'Config',
'nonuk-metadata.json',
]);
if (file_exists($nonuk_config_file)) {
Expand All @@ -59,8 +60,7 @@ public function get_nonuk($key)
}
if (array_key_exists($key, $this->nonuk)) {
return $this->nonuk[$key];
}
else {
} else {
return false;
}
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 13 additions & 5 deletions app/controllers/component.php → app/Controllers/Component.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php

namespace App\Controllers;

use App\Core\Controller;
use App\Models\Component as ComponentModel;
use Mustache_Engine;
use Mustache_Loader_FilesystemLoader;

class Component extends Controller
{
public function __construct($params = [])
Expand All @@ -20,8 +28,8 @@ public function render()
DIRECTORY_SEPARATOR,
[
APP,
'views',
'findingaid',
'Views',
'Findingaid',
]
)
),
Expand All @@ -32,11 +40,11 @@ public function render()
$component_id = $pieces[1];
$model = new ComponentModel($id, $component_id);

$container_list_template = load_template('findingaid/container_list');
$component_template = load_template('findingaid/component');
$container_list_template = load_template('Findingaid/container_list');
$component_template = load_template('Findingaid/component');

$container_lists = [];
foreach ($model->container_lists() as $container_list) {
foreach ($model->containerLists() as $container_list) {
$container_list_content = $m->render(
$container_list_template,
$container_list
Expand Down
71 changes: 36 additions & 35 deletions app/controllers/findingaid.php → app/Controllers/Findingaid.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php

namespace App\Controllers;

use App\Core\Controller;
use App\Models\Findingaid as FindingaidModel;
use App\Models\Component as ComponentModel;
use Mustache_Engine;
use Mustache_Loader_FilesystemLoader;

class Findingaid extends Controller
{
private $templates;
Expand Down Expand Up @@ -31,8 +40,8 @@ public function show()
DIRECTORY_SEPARATOR,
[
APP,
'views',
'findingaid',
'Views',
'Findingaid',
]
)
),
Expand Down Expand Up @@ -74,8 +83,7 @@ public function show()
}
}
}
}
elseif (array_key_exists('fields', $panel)) {
} elseif (array_key_exists('fields', $panel)) {
$panel['multi-field'] = [];
foreach ($panel['fields'] as $entry) {
$data = $model->xpath("//{$entry['field']}");
Expand Down Expand Up @@ -107,17 +115,16 @@ public function show()
}
}
}
}
else {
} else {
$component_count = count($model->xpath('contents/c'));
if ($component_count > 0) {
$skip = false;
$templates = ['container_list', 'component'];
foreach ($templates as $template) {
$this->templates[$template] = load_template("findingaid/$template");
$this->templates[$template] = load_template("Findingaid/$template");
}
foreach ($model->xpath('contents/c') as $c) {
$details = $this->render_component($m, $c);
$details = $this->renderComponent($m, $c);
$panel['components'][] = [
'component' => $details[0],
];
Expand Down Expand Up @@ -199,8 +206,7 @@ public function show()
}
}
$url = '/?' . $search_field . '=' . urlencode($raw_search);
}
else {
} else {
$data = $model->xpath("//{$link['field']}");
$url = false;
foreach ($data as $datum) {
Expand Down Expand Up @@ -251,19 +257,19 @@ public function show()
];

$toc = $m->render(
load_template('findingaid/toc'),
load_template('Findingaid/toc'),
$toc_options
);

$content = $m->render(
load_template('findingaid/show'),
load_template('Findingaid/show'),
$options
);

if ($requestable) {
$requests_config = $this->config->get('requests');
$requests = $m->render(
load_template('findingaid/requests'),
load_template('Findingaid/requests'),
[
'id' => $requests_config['summary']['id'],
'label' => fa_brevity($requests_config['summary']['label']),
Expand All @@ -275,8 +281,7 @@ public function show()
'item_url' => '/catalog/' . $model->id() . '/',
]
);
}
else {
} else {
$requests = '';
}

Expand All @@ -300,14 +305,14 @@ public function show()
DIRECTORY_SEPARATOR,
[
APP,
'views',
'layouts',
'Views',
'Layouts',
]
)
),
]);
$page = $layout->render(
load_template('layouts/application'),
load_template('Layouts/application'),
[
'content' => $content,
'toc' => $toc,
Expand All @@ -327,25 +332,24 @@ public function show()
]],
'title' => $model->title(),
'requestable' => $requestable,
'repository' => $this->config->get_repo($repository),
'repository' => $this->config->getRepo($repository),
]
);
set_cache($id, $page);
}
else {
} else {
$layout = new Mustache_Engine([
'partials_loader' => new Mustache_Loader_FilesystemLoader(
implode(
DIRECTORY_SEPARATOR,
[
APP,
'views',
'layouts',
'Views',
'Layouts',
]
)
),
]);
$meta = $this->config->get_nonuk($id);
$meta = $this->config->getNonUK($id);
if ($meta) {
$repo = $meta['repository'];
$former_kdl_partners = $this->config->get('partners');
Expand All @@ -360,25 +364,23 @@ public function show()

if ($is_kdl_partner) {
$page = $layout->render(
load_template('layouts/suggest_kdl'),
load_template('Layouts/suggest_kdl'),
[
'title' => $meta['title'],
'repository' => $meta['repository'],
]
);
}
else {
} else {
$page = $layout->render(
load_template('layouts/suggest_former_kdl'),
load_template('Layouts/suggest_former_kdl'),
[
'title' => $meta['title'],
'repository' => $meta['repository'],
'repo_url' => $repo_url,
]
);
}
}
else {
} else {
# This is probably a deleted ExploreUK finding aid
header("Location: /");
die();
Expand All @@ -391,7 +393,7 @@ public function show()
echo $page;
}

public function render_component($renderer, $component_xml)
public function renderComponent($renderer, $component_xml)
{
$component_content = '';
$attributes = $component_xml->attributes();
Expand All @@ -401,14 +403,14 @@ public function render_component($renderer, $component_xml)
$component = new ComponentModel($this->params['id'], $attributes['id']);
$subcomponent_content = [];
foreach ($component->subcomponents() as $subcomponent) {
$subcomponent_details = $this->render_component($renderer, $subcomponent->xml());
$subcomponent_details = $this->renderComponent($renderer, $subcomponent->xml());
$subcomponent_content[] = [
'subcomponent' => $subcomponent_details[0],
];
}

$container_lists = [];
foreach ($component->container_lists() as $container_list) {
foreach ($component->containerLists() as $container_list) {
$container_list_content = $renderer->render(
$this->templates['container_list'],
$container_list
Expand Down Expand Up @@ -436,8 +438,7 @@ public function render_component($renderer, $component_xml)
'body_id' => $body_id,
]
);
}
else {
} else {
error_log("FA: attributes_id not set");
}
return [
Expand Down
15 changes: 15 additions & 0 deletions app/Controllers/Home.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Controllers;

use App\Core\Controller;
use Mustache_Engine;

class Home extends Controller
{
public function show()
{
$m = new Mustache_Engine();
echo $m->render(load_template('Home/index'));
}
}
Loading
Loading