-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up product pages with related publications (#445)
- Loading branch information
Showing
13 changed files
with
402 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function simpleId(url) { | ||
return url.slice(url.lastIndexOf("/") + 1, url.lastIndexOf(".")); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from "react"; | ||
import md5 from 'md5'; | ||
import { simpleId } from './helpers.js' | ||
|
||
import Header from "./header.html"; | ||
import Footer from "./footer.html"; | ||
import Publications from "./publications.html"; | ||
|
||
import "./css/lobid.css"; | ||
import "./css/bootstrap.min.css"; | ||
import "./css/font-awesome.min.css"; | ||
|
||
import jsonLdPng from "./images/json-ld.png"; | ||
|
||
export class Product extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
this.props = props; | ||
} | ||
|
||
asLinks(field) { | ||
return this.props.product[field] && <tr><td>{this.props[field]}</td><td>{this.props.product[field].map((link) => | ||
<div key={link.id}><a href={link.id}>{link.id.replace('https://', '').replace('http://', '')}</a><br /></div> | ||
)}</td></tr> | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="container"> | ||
<p /> | ||
<Header | ||
language={this.props.language} | ||
languageLink={this.props.languageLink} | ||
languageTooltip={this.props.languageTooltip} | ||
publications={this.props.publications} | ||
teamLink={this.props.teamLink} | ||
contactPointId={this.props.contactPointId} | ||
/> | ||
<div> | ||
<div className="page-header"> | ||
<h1> | ||
{this.props.product.name.label} | ||
<small> | ||
{this.props.product.slogan && [this.props.product.slogan].map(s => <span>— {s.label}</span>)} | ||
<a title="Beschreibung als JSON-LD anzeigen" href={'/product/' + simpleId(this.props.product.id) + '.json'}><img className='json-ld-icon' src={jsonLdPng} alt="JSON-LD" /></a></small> | ||
</h1> | ||
</div> | ||
|
||
<div className="row"> | ||
<div className="col-md-9"> | ||
<p className="lead">{this.props.product.description.label}</p> | ||
<table className="table table-striped table-condensed"> | ||
<thead> | ||
<tr><th width="20%" /><th width="80%" /></tr> | ||
</thead> | ||
<tbody> | ||
<tr><td>Website</td><td><a href={this.props.product.id}>{this.props.product.id}</a></td></tr> | ||
{this.asLinks("hasPart")} | ||
{this.asLinks("isBasedOn")} | ||
{this.asLinks("isRelatedTo")} | ||
</tbody> | ||
<tfoot /> | ||
</table> | ||
</div> | ||
<div className="col-md-3"> | ||
<img alt={this.props.product.name.label} id="index-image" src={this.props.product.image || `https://gravatar.com/avatar/${md5(this.props.product.id)}?s=300&d=identicon`} /> | ||
</div> | ||
</div> | ||
<Publications pubs={this.props.pubs} publications={this.props.publications} /> | ||
<Footer companyDetails={this.props.companyDetails} privacy={this.props.privacy} /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import React from "react" | ||
import { simpleId } from './helpers.js' | ||
|
||
import jsonLdPng from "./images/json-ld.png"; | ||
|
||
export default class Publications extends React.Component { | ||
render() { | ||
return ( | ||
this.props.pubs.length > 0 && | ||
<div className="row"> | ||
<div className="col-md-12"> | ||
<p className="lead">{this.props.publications}</p> | ||
<table className="table table-striped table-condensed"> | ||
<thead> | ||
<tr><th width="10%" /><th width="65%" /><th width="12%" /><th width="10%" /><th width="3%" /></tr> | ||
</thead> | ||
<tbody> | ||
{this.props.pubs.map(publication => | ||
<tr key={publication.id}> | ||
<td><small>{publication.datePublished}</small></td> | ||
<td><a href={publication.id}>{publication.name.de || publication.name.en || publication.id}</a></td> | ||
<td>{publication.about && publication.about.map(a => | ||
<p key={a.id}><small><span className="glyphicon glyphicon-tag" aria-hidden="true"></span></small> <a href={a.id}>{simpleId(a.id)}</a></p> | ||
)}</td> | ||
<td align="right"><small><a href={"https://schema.org/" + publication.type}>{publication.type}</a></small></td> | ||
<td><a title="Beschreibung als JSON-LD anzeigen" href={publication.fields.jsonFile}><img height="20px" src={jsonLdPng} alt="JSON-LD" /></a></td> | ||
</tr> | ||
)} | ||
</tbody> | ||
<tfoot /> | ||
</table> | ||
</div> | ||
</div> | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.