Browse Source

added thematic boxes on homepage and reconfigured random function

main
Simon Bowie 2 years ago
parent
commit
25ed07c8b0
5 changed files with 140 additions and 85 deletions
  1. +6
    -0
      site/public/css/style.css
  2. +0
    -74
      site/public/index.html
  3. +121
    -0
      site/public/index.php
  4. +2
    -1
      site/public/random.php
  5. +11
    -10
      site/solr.php

+ 6
- 0
site/public/css/style.css View File

@@ -9,3 +9,9 @@
font-family: inherit;
font-size: inherit;
}

.verticaltext {
width:35px !important;
word-wrap: break-word;
white-space:pre-wrap;
}

+ 0
- 74
site/public/index.html View File

@@ -1,74 +0,0 @@
<!--

# @name: index.html
# @version: 0.1
# @creation_date: 2021-09-24
# @license: The MIT License <https://opensource.org/licenses/MIT>
# @author: Simon Bowie <ad7588@coventry.ac.uk>
# @purpose: Home page for the application

-->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</head>
<body>

<div class="container-fluid p-5 my-5 border">
<div class="row">
<div class="col text-center">
<p class="h1">Politics of Patents</p>
</div>
</div>

<div class="row justify-content-center p-3">
<div class="col-sm-6 text-center">
<form action="search.php" method="POST">
<input type="text" name="search" placeholder="search for a patent record">
<select name="searchopt" id="searchopt">
<option value="all">all</option>
<option value="active">active</option>
<option value="expanding">expanding</option>
<option value="invisible">invisible</option>
<option value="multispecies">multi-species</option>
<option value="surviving">surviving</option>
</select>
<input type="submit" id="submit" value="search">
</form>
</div>
</div>

<div class="row p-3">
<div class="col text-center">
<a href="./random.php">show a random record</a>
</div>

<div class="col text-center">
<a href="./compare.php">compare two random records</a>
</div>
</div>

<div class="row p-3">
<div class="col text-center">
<a href="./titles.php">ten random titles</a>
</div>

<div class="col text-center">
<a href="./abstracts.php">ten random abstracts</a>
</div>

<div class="col text-center">
<a href="./random_images.php">ten random images (takes a long time to load)</a>
</div>
</div>

</div>

</body>
</html>

+ 121
- 0
site/public/index.php View File

@@ -0,0 +1,121 @@
<?php

# @name: index.php
# @version: 0.1
# @creation_date: 2021-09-24
# @license: The MIT License <https://opensource.org/licenses/MIT>
# @author: Simon Bowie <ad7588@coventry.ac.uk>
# @purpose: Home page for the application

include '../solr.php';

$cores = array("active", "expanding", "invisible", "multispecies", "surviving");

?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
</head>
<body class="d-flex flex-column min-vh-100">

<main class="flex-shrink-0">
<div class="container-fluid p-5 my-5 border">
<div class="row">
<div class="col text-center">
<p class="h1">Politics of Patents</p>
</div>
</div>

<div class="row justify-content-center p-3">
<div class="col-sm-6 text-center">
<form action="search.php" method="POST">
<input type="text" name="search" placeholder="search for a patent record">
<select name="searchopt" id="searchopt">
<option value="all">all</option>
<option value="active">active</option>
<option value="expanding">expanding</option>
<option value="invisible">invisible</option>
<option value="multispecies">multi-species</option>
<option value="surviving">surviving</option>
</select>
<input type="submit" id="submit" value="search">
</form>
</div>
</div>

<div class="row p-3">
<div class="col text-center">
<a href="./random.php">show a random record</a>
</div>

<div class="col text-center">
<a href="./compare.php">compare two random records</a>
</div>
</div>

<div class="row p-3">
<div class="col text-center">
<a href="./titles.php">ten random titles</a>
</div>

<div class="col text-center">
<a href="./abstracts.php">ten random abstracts</a>
</div>

<div class="col text-center">
<a href="./random_images.php">ten random images (takes a long time to load)</a>
</div>
</div>

<?php
foreach($cores as $core):
?>

<div class="row p-3 m-3 border">
<div class="col-1 border border-dark text-center verticaltext">
<span class="text-uppercase"><?php echo $core; ?></span>
</div>
<div class="col-11">
<div class="row p-3">
<?php
$random_record = one_random_record($core);
?>
<a href="id_search.php?id=<? echo $random_record['id']; ?>&core=<? echo $core; ?>">
<?php
if(isset($random_record['title'])){
echo $random_record['title'];
}
?>
</a>
</div>
<div class="row p-3">
<?php
if(isset($random_record['abstract'])){
echo $random_record['abstract'];
}
?>
</div>
</div>
</div>

<?php
endforeach;
?>

</div>
</main>

<footer class="footer py-3 mt-auto bg-light">
<div class="container">
<span class="text-muted">Data from the <a href="https://www.epo.org/">European Patent Office's</a> <a href="https://worldwide.espacenet.com/">Espacenet patent search engine</a> and reconfigured by Goldsmiths University's Archival Conversations project.</span>
</div>
</footer>

</body>
</html>

+ 2
- 1
site/public/random.php View File

@@ -10,7 +10,8 @@
include '../solr.php';
include '../ops_api.php';

$random_record = one_random_record();
$core = 'all';
$random_record = one_random_record($core);
$publication_details = get_publication_details($random_record['doc_ref']);

?>

+ 11
- 10
site/solr.php View File

@@ -72,8 +72,9 @@ function parse_result($id, $input){
$output['id'] = $id;

//Set document reference number (used for OPS API)
preg_match('/=D\s(([^\s]*)\s([^\s]*)\s([^\s]*))/', $input, $doc_ref);
$output['doc_ref'] = str_replace(' ','',$doc_ref[1]);
if (preg_match('/=D\s(([^\s]*)\s([^\s]*)\s([^\s]*))/', $input, $doc_ref)){
$output['doc_ref'] = str_replace(' ','',$doc_ref[1]);
}

// Search for the application ID in the content element and display it
preg_match('/Application.*\n(.*)\n/', $input, $application_id);
@@ -88,28 +89,28 @@ function parse_result($id, $input){
$output['ipc_publication_url'] = $ipc_publication[1];

// Search for the title in the content element and display it
preg_match('/Title.*\n(.*)\n/', $input, $title);
$output['title'] = $title[1];
if (preg_match('/Title.*\n(.*)\n/', $input, $title)){
$output['title'] = $title[1];
}

// Search for the abstract in the content element and display it
if (preg_match('/Abstract.*\n(.*)\n/', $input, $abstract)){
$output['abstract'] = $abstract[1];
}
else {
preg_match('/\(.\) \\n\\n(.*)\\n/', $input, $abstract);
elseif (preg_match('/\(.\) \\n\\n(.*)\\n/', $input, $abstract)) {
$output['abstract'] = $abstract[1];
}
return $output;
}

function get_random_record(){
function get_random_record($core){

// Generate a random number for sorting by random
$random = rand();

// Assemble a query string to send to Solr. This uses the Solr hostname from config.env. Solr's query syntax can be found at many sites including https://lucene.apache.org/solr/guide/6_6/the-standard-query-parser.html
// This query retrieves only the bib identifier field for records which satisfy the search query
$solrurl = 'http://' . $_ENV["SOLR_HOSTNAME"] . ':' . $_ENV["SOLR_PORT"] . '/solr/' . $_ENV["SOLR_CORE"] . '/select?q.op=OR&q=*%3A*&wt=json&sort=random_' . $random . '%20asc';
$solrurl = 'http://' . $_ENV["SOLR_HOSTNAME"] . ':' . $_ENV["SOLR_PORT"] . '/solr/' . $core . '/select?q.op=OR&q=*%3A*&wt=json&sort=random_' . $random . '%20asc';

// Perform Curl request on the Solr API
$ch = curl_init();
@@ -138,9 +139,9 @@ function get_random_record(){
return $result_array;
}

function one_random_record (){
function one_random_record ($core){

$random = get_random_record();
$random = get_random_record($core);

foreach ($random as $id => $content){
$output = parse_result($id, $content);

Loading…
Cancel
Save