diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0bf36c4..50fe92b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 }} diff --git a/Dockerfile b/Dockerfile index dddc516..180eac4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 . @@ -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 diff --git a/Makefile b/Makefile index c4a6a30..94c7032 100644 --- a/Makefile +++ b/Makefile @@ -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}' @@ -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 diff --git a/app/assets/css/bootstrap-theme.css b/app/Assets/css/bootstrap-theme.css similarity index 100% rename from app/assets/css/bootstrap-theme.css rename to app/Assets/css/bootstrap-theme.css diff --git a/app/assets/css/bootstrap-theme.css.map b/app/Assets/css/bootstrap-theme.css.map similarity index 100% rename from app/assets/css/bootstrap-theme.css.map rename to app/Assets/css/bootstrap-theme.css.map diff --git a/app/assets/css/bootstrap-theme.min.css b/app/Assets/css/bootstrap-theme.min.css similarity index 100% rename from app/assets/css/bootstrap-theme.min.css rename to app/Assets/css/bootstrap-theme.min.css diff --git a/app/assets/css/bootstrap.css b/app/Assets/css/bootstrap.css similarity index 100% rename from app/assets/css/bootstrap.css rename to app/Assets/css/bootstrap.css diff --git a/app/assets/css/bootstrap.css.map b/app/Assets/css/bootstrap.css.map similarity index 100% rename from app/assets/css/bootstrap.css.map rename to app/Assets/css/bootstrap.css.map diff --git a/app/assets/css/bootstrap.min.css b/app/Assets/css/bootstrap.min.css similarity index 100% rename from app/assets/css/bootstrap.min.css rename to app/Assets/css/bootstrap.min.css diff --git a/app/assets/css/controls.png b/app/Assets/css/controls.png similarity index 100% rename from app/assets/css/controls.png rename to app/Assets/css/controls.png diff --git a/app/assets/css/controls.svg b/app/Assets/css/controls.svg similarity index 100% rename from app/assets/css/controls.svg rename to app/Assets/css/controls.svg diff --git a/app/assets/css/extra.css b/app/Assets/css/extra.css similarity index 100% rename from app/assets/css/extra.css rename to app/Assets/css/extra.css diff --git a/app/assets/css/footer.css b/app/Assets/css/footer.css similarity index 100% rename from app/assets/css/footer.css rename to app/Assets/css/footer.css diff --git a/app/assets/css/images b/app/Assets/css/images similarity index 100% rename from app/assets/css/images rename to app/Assets/css/images diff --git a/app/assets/css/jquery-ui.min.css b/app/Assets/css/jquery-ui.min.css similarity index 100% rename from app/assets/css/jquery-ui.min.css rename to app/Assets/css/jquery-ui.min.css diff --git a/app/assets/css/lity.min.css b/app/Assets/css/lity.min.css similarity index 100% rename from app/assets/css/lity.min.css rename to app/Assets/css/lity.min.css diff --git a/app/assets/css/mediaelementplayer.min.css b/app/Assets/css/mediaelementplayer.min.css similarity index 100% rename from app/assets/css/mediaelementplayer.min.css rename to app/Assets/css/mediaelementplayer.min.css diff --git a/app/assets/js/bootstrap.min.js b/app/Assets/js/bootstrap.min.js similarity index 100% rename from app/assets/js/bootstrap.min.js rename to app/Assets/js/bootstrap.min.js diff --git a/app/assets/js/jquery-ui.min.js b/app/Assets/js/jquery-ui.min.js similarity index 100% rename from app/assets/js/jquery-ui.min.js rename to app/Assets/js/jquery-ui.min.js diff --git a/app/assets/js/jquery.min.js b/app/Assets/js/jquery.min.js similarity index 100% rename from app/assets/js/jquery.min.js rename to app/Assets/js/jquery.min.js diff --git a/app/assets/js/jquery.unveil.js b/app/Assets/js/jquery.unveil.js similarity index 100% rename from app/assets/js/jquery.unveil.js rename to app/Assets/js/jquery.unveil.js diff --git a/app/assets/js/lity.min.js b/app/Assets/js/lity.min.js similarity index 100% rename from app/assets/js/lity.min.js rename to app/Assets/js/lity.min.js diff --git a/app/assets/js/manifest.txt b/app/Assets/js/manifest.txt similarity index 100% rename from app/assets/js/manifest.txt rename to app/Assets/js/manifest.txt diff --git a/app/assets/js/mediaelementplayer.min.js b/app/Assets/js/mediaelementplayer.min.js similarity index 100% rename from app/assets/js/mediaelementplayer.min.js rename to app/Assets/js/mediaelementplayer.min.js diff --git a/app/assets/js/mousetrap.min.js b/app/Assets/js/mousetrap.min.js similarity index 100% rename from app/assets/js/mousetrap.min.js rename to app/Assets/js/mousetrap.min.js diff --git a/app/assets/js/requests.js b/app/Assets/js/requests.js similarity index 100% rename from app/assets/js/requests.js rename to app/Assets/js/requests.js diff --git a/app/assets/js/reveal.js b/app/Assets/js/reveal.js similarity index 100% rename from app/assets/js/reveal.js rename to app/Assets/js/reveal.js diff --git a/app/assets/js/ui.js b/app/Assets/js/ui.js similarity index 100% rename from app/assets/js/ui.js rename to app/Assets/js/ui.js diff --git a/app/config/config.php b/app/Config/Config.php similarity index 86% rename from app/config/config.php rename to app/Config/Config.php index cd3f6dc..013163f 100644 --- a/app/config/config.php +++ b/app/Config/Config.php @@ -1,4 +1,7 @@ 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)) { @@ -59,8 +60,7 @@ public function get_nonuk($key) } if (array_key_exists($key, $this->nonuk)) { return $this->nonuk[$key]; - } - else { + } else { return false; } } diff --git a/app/config/config.json b/app/Config/config.json similarity index 100% rename from app/config/config.json rename to app/Config/config.json diff --git a/app/config/nonuk-metadata.json b/app/Config/nonuk-metadata.json similarity index 100% rename from app/config/nonuk-metadata.json rename to app/Config/nonuk-metadata.json diff --git a/app/config/repo.json b/app/Config/repo.json similarity index 100% rename from app/config/repo.json rename to app/Config/repo.json diff --git a/app/controllers/component.php b/app/Controllers/Component.php similarity index 87% rename from app/controllers/component.php rename to app/Controllers/Component.php index 569ccbb..b8e6d9e 100644 --- a/app/controllers/component.php +++ b/app/Controllers/Component.php @@ -1,4 +1,12 @@ container_lists() as $container_list) { + foreach ($model->containerLists() as $container_list) { $container_list_content = $m->render( $container_list_template, $container_list diff --git a/app/controllers/findingaid.php b/app/Controllers/Findingaid.php similarity index 92% rename from app/controllers/findingaid.php rename to app/Controllers/Findingaid.php index f843921..a919053 100644 --- a/app/controllers/findingaid.php +++ b/app/Controllers/Findingaid.php @@ -1,4 +1,13 @@ xpath("//{$entry['field']}"); @@ -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], ]; @@ -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) { @@ -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']), @@ -275,8 +281,7 @@ public function show() 'item_url' => '/catalog/' . $model->id() . '/', ] ); - } - else { + } else { $requests = ''; } @@ -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, @@ -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'); @@ -360,16 +364,15 @@ 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'], @@ -377,8 +380,7 @@ public function show() ] ); } - } - else { + } else { # This is probably a deleted ExploreUK finding aid header("Location: /"); die(); @@ -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(); @@ -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 @@ -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 [ diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php new file mode 100644 index 0000000..4d5e0c5 --- /dev/null +++ b/app/Controllers/Home.php @@ -0,0 +1,15 @@ +render(load_template('Home/index')); + } +} diff --git a/app/controllers/overview.php b/app/Controllers/Overview.php similarity index 87% rename from app/controllers/overview.php rename to app/Controllers/Overview.php index 1eba540..6662487 100644 --- a/app/controllers/overview.php +++ b/app/Controllers/Overview.php @@ -1,4 +1,12 @@ render( - load_template('layouts/overview'), + load_template('Layouts/overview'), [ 'title' => $model->title(), 'bioghist' => $model->bioghist(), diff --git a/app/core/application.php b/app/Core/Application.php similarity index 72% rename from app/core/application.php rename to app/Core/Application.php index 111687e..a8e56f7 100644 --- a/app/core/application.php +++ b/app/Core/Application.php @@ -1,16 +1,26 @@ \App\Controllers\Home::class, + 'findingaid' => \App\Controllers\Findingaid::class, + 'component' => \App\Controllers\Component::class, + 'overview' => \App\Controllers\Overview::class + ]; public function __construct() { $this->splitUrl(); - load_path(APP, 'controllers/' . $this->url_controller); - $this->url_controller = new $this->url_controller($this->url_params); - $this->url_controller->show(); + $route = $this->url_controller; + $controllerClass = $this->controllers[$route]; + $controller = new $controllerClass($this->url_params); + $controller->show(); } private function splitUrl() @@ -21,8 +31,7 @@ private function splitUrl() if (isset($argv[1]) && preg_match('/^[a-z0-9]+$/', $argv[1])) { $_GET['id'] = $argv[1]; $_GET['cache'] = 1; - } - else { + } else { sleep(10); $_GET['id'] = 'xt73xs5jd22r'; } @@ -42,28 +51,25 @@ private function splitUrl() } } # temp -if (isset($_GET['suggest']) and $_GET['suggest'] == 1) { - $this->url_params['suggest'] = 1; -} + if (isset($_GET['suggest']) and $_GET['suggest'] == 1) { + $this->url_params['suggest'] = 1; + } if (isset($_GET['invalidate_cache']) and $_GET['invalidate_cache'] == 1) { $this->url_params['invalidate_cache'] = 1; } if (preg_match('/^([0-9a-z]+)_([0-9a-z]+)$/', $this->url_params['id'], $matches)) { $this->url_controller = 'component'; - } - else { + } else { $this->url_controller = 'findingaid'; } if (isset($_GET['overview']) and $_GET['overview'] == 1) { $this->url_controller = 'overview'; } - } - else { + } else { $this->url_controller = 'home'; } - } - else { + } else { $this->url_controller = 'home'; } } diff --git a/app/core/brevity.php b/app/Core/Brevity.php similarity index 94% rename from app/core/brevity.php rename to app/Core/Brevity.php index f314e74..1b714c5 100644 --- a/app/core/brevity.php +++ b/app/Core/Brevity.php @@ -16,16 +16,14 @@ function fa_brevity($message, $length = 0) if (($current_length == 0) || $current_length + strlen($word) <= $length) { $target_words[] = $word; $current_length += strlen($word); - } - else { + } else { break; } } $count = count($target_words); if ($count == 0) { $message = '…'; - } - else { + } else { $terminal = $target_words[$count - 1]; if (preg_match('/^\W+$/', $terminal)) { array_pop($target_words); diff --git a/app/core/controller.php b/app/Core/Controller.php similarity index 89% rename from app/core/controller.php rename to app/Core/Controller.php index 75c2847..4373916 100644 --- a/app/core/controller.php +++ b/app/Core/Controller.php @@ -1,4 +1,7 @@ id; while (strlen($tree) >= 2) { - $prefix = substr($tree, 0, 2); - $tree = substr($tree, 2); - $array[] = $prefix; + $prefix = substr($tree, 0, 2); + $tree = substr($tree, 2); + $array[] = $prefix; } $array[] = $this->id; return implode(DIRECTORY_SEPARATOR, $array); diff --git a/app/core/render.php b/app/Core/Render.php similarity index 96% rename from app/core/render.php rename to app/Core/Render.php index 697ffd3..a775231 100644 --- a/app/core/render.php +++ b/app/Core/Render.php @@ -35,11 +35,9 @@ function fa_render_extref($node) $render = ''; if ($node->hasAttribute('href')) { $render = fa_render_extref_ns($node, ""); - } - else if ($node->hasAttribute('xlink:href')) { + } elseif ($node->hasAttribute('xlink:href')) { $render = fa_render_extref_ns($node, "xlink"); - } - else { + } else { $render = $node->textContent; } return $render; diff --git a/app/models/component_model.php b/app/Models/Component.php similarity index 69% rename from app/models/component_model.php rename to app/Models/Component.php index 6ee4f45..4411506 100644 --- a/app/models/component_model.php +++ b/app/Models/Component.php @@ -1,5 +1,11 @@ config = $g_config; $component_file = $this->ppath() . DIRECTORY_SEPARATOR . $this->basename; if (file_exists($component_file)) { - $this->xml = new SimpleXMLElement(file_get_contents($component_file)); + $this->xml = new SimpleXMLElement(file_get_contents($component_file)); } $this->links = $this->links(); $contents_config = $this->config->get('contents'); foreach ($this->xpath($contents_config['component']) as $c) { $cattrs = $c->attributes(); $cid = $cattrs['id']; - $this->subcomponents[] = new ComponentModel($this->id, $cid); + $this->subcomponents[] = new Component($this->id, $cid); } } @@ -51,49 +57,47 @@ public function links() foreach ($link_raw['links'] as $use => $href) { $use = str_replace(' ', '_', $use); switch ($use) { - case 'thumbnail': - $thumb_count++; - if ($thumb_count <= $image_threshold) { - $field = 'image'; - } - else { - $field = 'image_overflow'; - } - if (empty($link[$field])) { - $link[$field] = []; - } - $link[$field]['thumb'] = $href; - break; - case 'reference_image': - $ref_count++; - if ($ref_count <= $image_threshold) { - $field = 'image'; - } - else { - $field = 'image_overflow'; - } - if (empty($link[$field])) { - $link[$field] = []; - } - $link[$field]['full'] = $href; - $link[$field]['href_id'] = $g_minter->mint(); - break; - case 'reference_audio': - if (empty($link['audio'])) { - $link['audio'] = []; - } - $link['audio']['href'] = $href; - $link['audio']['href_id'] = $g_minter->mint(); - break; - case 'reference_video': - if (empty($link['video'])) { - $link['video'] = []; - } - $link['video']['href'] = $href; - $link['video']['href_id'] = $g_minter->mint(); - break; - default: - break; + case 'thumbnail': + $thumb_count++; + if ($thumb_count <= $image_threshold) { + $field = 'image'; + } else { + $field = 'image_overflow'; + } + if (empty($link[$field])) { + $link[$field] = []; + } + $link[$field]['thumb'] = $href; + break; + case 'reference_image': + $ref_count++; + if ($ref_count <= $image_threshold) { + $field = 'image'; + } else { + $field = 'image_overflow'; + } + if (empty($link[$field])) { + $link[$field] = []; + } + $link[$field]['full'] = $href; + $link[$field]['href_id'] = $g_minter->mint(); + break; + case 'reference_audio': + if (empty($link['audio'])) { + $link['audio'] = []; + } + $link['audio']['href'] = $href; + $link['audio']['href_id'] = $g_minter->mint(); + break; + case 'reference_video': + if (empty($link['video'])) { + $link['video'] = []; + } + $link['video']['href'] = $href; + $link['video']['href_id'] = $g_minter->mint(); + break; + default: + break; } } $links[] = $link; @@ -113,8 +117,7 @@ public function title() $this->xpath('did/unittitle'), $this->xpath('did/unitdate') ); - } - else { + } else { $pieces = array_merge($pieces, $this->xpath('did/unittitle')); } $segments = []; @@ -124,7 +127,7 @@ public function title() return implode(', ', $segments); } - public function container_lists() + public function containerLists() { $container_lists = []; $order = []; @@ -142,14 +145,13 @@ public function container_lists() foreach ($this->xpath($contents_config['container']) as $container) { $attributes = $container->attributes(); $aspect = [ - 'type' => $this->container_type($attributes), + 'type' => $this->containerType($attributes), 'content' => (string)$container, ]; if (isset($attributes['id'])) { $id = trim($attributes['id']); - } - else { + } else { $id = md5((string) $container->asXML()); } $aspect['id'] = $id; @@ -159,8 +161,7 @@ public function container_lists() $ancestor = $section_id_for[$pid]; $section_id_for[$id] = $ancestor; $section[$ancestor][] = $aspect; - } - else { + } else { $section_id_for[$id] = $id; $section[$id] = [$aspect]; $section_ids[] = $id; @@ -194,7 +195,7 @@ public function container_lists() } $volume = $container_list_pieces[0]; $summary = implode(', ', $container_list_pieces); - $full_container_list = fa_brevity($summary . ': '. $this->title(), FA_AEON_MAX); + $full_container_list = fa_brevity($summary . ': ' . $this->title(), FA_AEON_MAX); array_shift($container_list_pieces); $rest = implode(', ', $container_list_pieces); $container_list = [ @@ -216,40 +217,40 @@ public function container_lists() public function bioghistHead() { $contents_config = $this->config->get('contents'); - return $this->render_paragraphs($this->xpath($contents_config['bioghist_head'])); + return $this->renderParagraphs($this->xpath($contents_config['bioghist_head'])); } public function scopecontentHead() { $contents_config = $this->config->get('contents'); - return $this->render_paragraphs($this->xpath($contents_config['scopecontent_head'])); + return $this->renderParagraphs($this->xpath($contents_config['scopecontent_head'])); } public function processinfoHead() { $contents_config = $this->config->get('contents'); - return $this->render_paragraphs($this->xpath($contents_config['processinfo_head'])); + return $this->renderParagraphs($this->xpath($contents_config['processinfo_head'])); } public function bioghist() { $contents_config = $this->config->get('contents'); - return $this->render_paragraphs($this->xpath($contents_config['bioghist'])); + return $this->renderParagraphs($this->xpath($contents_config['bioghist'])); } public function scopecontent() { $contents_config = $this->config->get('contents'); - return $this->render_paragraphs($this->xpath($contents_config['scopecontent'])); + return $this->renderParagraphs($this->xpath($contents_config['scopecontent'])); } public function processinfo() { $contents_config = $this->config->get('contents'); - return $this->render_paragraphs($this->xpath($contents_config['processinfo'])); + return $this->renderParagraphs($this->xpath($contents_config['processinfo'])); } - public function render_paragraphs($p_list) + public function renderParagraphs($p_list) { $render = []; foreach ($p_list as $p) { @@ -274,26 +275,22 @@ public function level() return $attributes['level']; } - private function container_type($attributes) + private function containerType($attributes) { if (isset($attributes['type'])) { $type = trim($attributes['type']); if ($type === 'othertype') { if (isset($attributes['label'])) { return trim($attributes['label']); - } - else { + } else { return 'container'; } - } - else { + } else { return $type; } - } - else if (isset($attributes['label'])) { + } elseif (isset($attributes['label'])) { return trim($attributes['label']); - } - else { + } else { return 'container'; } } diff --git a/app/models/findingaid_model.php b/app/Models/Findingaid.php similarity index 93% rename from app/models/findingaid_model.php rename to app/Models/Findingaid.php index ab6c573..ec1c1a9 100644 --- a/app/models/findingaid_model.php +++ b/app/Models/Findingaid.php @@ -1,5 +1,11 @@ 0) { $repository = $repositories[0]; return trim(dom_import_simplexml($repository)->textContent); - } - else { + } else { return 'Unknown repository'; } } @@ -50,8 +55,7 @@ public function unitid() $unitid = $this->metadata('//archdesc/did/unitid'); if (count($unitid) > 0) { $unitid = $unitid[0]; - } - else { + } else { return "no unitid"; } return $unitid; diff --git a/app/models/overview_model.php b/app/Models/Overview.php similarity index 87% rename from app/models/overview_model.php rename to app/Models/Overview.php index 4bb4658..85bab1e 100644 --- a/app/models/overview_model.php +++ b/app/Models/Overview.php @@ -1,5 +1,11 @@ xml->collection_overview->scopecontent->p as $p) { $result[] = ['text' => $p]; diff --git a/app/views/findingaid/advance_note.mustache b/app/Views/Findingaid/advance_note.mustache similarity index 100% rename from app/views/findingaid/advance_note.mustache rename to app/Views/Findingaid/advance_note.mustache diff --git a/app/views/findingaid/component.mustache b/app/Views/Findingaid/component.mustache similarity index 100% rename from app/views/findingaid/component.mustache rename to app/Views/Findingaid/component.mustache diff --git a/app/views/findingaid/container_list.mustache b/app/Views/Findingaid/container_list.mustache similarity index 100% rename from app/views/findingaid/container_list.mustache rename to app/Views/Findingaid/container_list.mustache diff --git a/app/views/findingaid/harmful_language_statement.mustache b/app/Views/Findingaid/harmful_language_statement.mustache similarity index 100% rename from app/views/findingaid/harmful_language_statement.mustache rename to app/Views/Findingaid/harmful_language_statement.mustache diff --git a/app/views/findingaid/image_controls.mustache b/app/Views/Findingaid/image_controls.mustache similarity index 100% rename from app/views/findingaid/image_controls.mustache rename to app/Views/Findingaid/image_controls.mustache diff --git a/app/views/findingaid/media.mustache b/app/Views/Findingaid/media.mustache similarity index 100% rename from app/views/findingaid/media.mustache rename to app/Views/Findingaid/media.mustache diff --git a/app/views/findingaid/panel.mustache b/app/Views/Findingaid/panel.mustache similarity index 100% rename from app/views/findingaid/panel.mustache rename to app/Views/Findingaid/panel.mustache diff --git a/app/views/findingaid/requests.mustache b/app/Views/Findingaid/requests.mustache similarity index 100% rename from app/views/findingaid/requests.mustache rename to app/Views/Findingaid/requests.mustache diff --git a/app/views/findingaid/show.mustache b/app/Views/Findingaid/show.mustache similarity index 100% rename from app/views/findingaid/show.mustache rename to app/Views/Findingaid/show.mustache diff --git a/app/views/findingaid/toc.mustache b/app/Views/Findingaid/toc.mustache similarity index 100% rename from app/views/findingaid/toc.mustache rename to app/Views/Findingaid/toc.mustache diff --git a/app/views/home/index.mustache b/app/Views/Home/index.mustache similarity index 100% rename from app/views/home/index.mustache rename to app/Views/Home/index.mustache diff --git a/app/views/layouts/application.mustache b/app/Views/Layouts/application.mustache similarity index 100% rename from app/views/layouts/application.mustache rename to app/Views/Layouts/application.mustache diff --git a/app/views/layouts/footer.mustache b/app/Views/Layouts/footer.mustache similarity index 100% rename from app/views/layouts/footer.mustache rename to app/Views/Layouts/footer.mustache diff --git a/app/views/layouts/maintenance_notice.mustache b/app/Views/Layouts/maintenance_notice.mustache similarity index 100% rename from app/views/layouts/maintenance_notice.mustache rename to app/Views/Layouts/maintenance_notice.mustache diff --git a/app/views/layouts/nav.mustache b/app/Views/Layouts/nav.mustache similarity index 100% rename from app/views/layouts/nav.mustache rename to app/Views/Layouts/nav.mustache diff --git a/app/views/layouts/overview.mustache b/app/Views/Layouts/overview.mustache similarity index 100% rename from app/views/layouts/overview.mustache rename to app/Views/Layouts/overview.mustache diff --git a/app/views/layouts/repo.mustache b/app/Views/Layouts/repo.mustache similarity index 100% rename from app/views/layouts/repo.mustache rename to app/Views/Layouts/repo.mustache diff --git a/app/views/layouts/search.mustache b/app/Views/Layouts/search.mustache similarity index 100% rename from app/views/layouts/search.mustache rename to app/Views/Layouts/search.mustache diff --git a/app/views/layouts/suggest_former_kdl.mustache b/app/Views/Layouts/suggest_former_kdl.mustache similarity index 100% rename from app/views/layouts/suggest_former_kdl.mustache rename to app/Views/Layouts/suggest_former_kdl.mustache diff --git a/app/views/layouts/suggest_kdl.mustache b/app/Views/Layouts/suggest_kdl.mustache similarity index 100% rename from app/views/layouts/suggest_kdl.mustache rename to app/Views/Layouts/suggest_kdl.mustache diff --git a/app/views/layouts/viewer.mustache b/app/Views/Layouts/viewer.mustache similarity index 100% rename from app/views/layouts/viewer.mustache rename to app/Views/Layouts/viewer.mustache diff --git a/app/controllers/home.php b/app/controllers/home.php deleted file mode 100644 index 23cf688..0000000 --- a/app/controllers/home.php +++ /dev/null @@ -1,9 +0,0 @@ -render(load_template('home/index')); - } -} diff --git a/app/init.php b/app/init.php index dc5fa42..de3c532 100644 --- a/app/init.php +++ b/app/init.php @@ -1,113 +1,13 @@ - diff --git a/public/css b/public/css index 475a62d..2019512 120000 --- a/public/css +++ b/public/css @@ -1 +1 @@ -../app/assets/css \ No newline at end of file +../app/Assets/css \ No newline at end of file diff --git a/public/index.php b/public/index.php index 031e120..8b53d36 100644 --- a/public/index.php +++ b/public/index.php @@ -1,4 +1,7 @@ get('panels'); + + $this->assertIsArray($panels); + } + + public function testModelsLoadable(): void + { + $this->assertTrue(class_exists('App\Models\Findingaid')); + $this->assertTrue(class_exists('App\Models\Component')); + $this->assertTrue(class_exists('App\Models\Overview')); + } + + public function testBrevityFunction(): void + { + $this->assertSame('Hello world', fa_brevity('Hello world', 100)); + $this->assertSame('Hello…', fa_brevity('Hello world', 1)); + } +}