geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
474 stars 255 forks source link

display link or image if feature contains link #134

Closed pvgenuchten closed 5 years ago

pvgenuchten commented 5 years ago

if a feature property contains a link (starts with 'http') it should be displayed as a clickable hyperlink, i hope it can be implemented as filter in the template language:

{{ft.prop | link}}

This can be extended to convert links that end in .gif/.svg/.jpg/.png to

<a href="{{ft.prop}}"><img src="{{ft.prop}}" class="thumbnail"/></a>

A test service (as wfs2 source) could be this one http://services.rce.geovoorziening.nl/landschapsatlas/wfs?request=GetCapabilities&service=WFS (various featuretypes have image references; kastelen, hunebedden, etc)

pvgenuchten commented 5 years ago

jinja2 indeed has a filter for this

{{ft.prop|urlize}}
justb4 commented 5 years ago

Links in HTML work fine now! You folks still want to add thumbnail images? Think there is a simple way and an advanced method.

Simple: just look at the extension of the attr URL, if it ends with .jpeg|.jpg|.png|.gifetc. The RCE WFS @pvgenuchten mentioned above has an interesting layer "castles" (Dutch kastelen). E.g. Castle Kernhem in Ede:

image

image

(hmm more of a Mansion I would say).

The more advanced way would be to sniff Content-Type for each URL attribute and based on that display the image (or maybe other content like Audio or Video).

Would go for the simple way first using a Python regexp (something like \.(?i:jpg|gif|png|bmp)) for all valid Image extensions. Would make a great demo!

justb4 commented 5 years ago

I've added this castles layer to the demo services, but maybe also a nice layer for the default config. Shall I add there as well? As it contains links to HTML and images.

tomkralidis commented 5 years ago

Sure. Having said this, should we break out our sample configs? i.e.:

justb4 commented 5 years ago

Sure. Having said this, should we break out our sample configs? i.e.:

  • have a really simple configuration to get a user up and running as quickly as possible. I would propose a single collection which requires as little provider dependencies as possible
  • have an examples/ directory with various configurations for users to see how different providers are setup

Yes good idea, van you open an issue for that?

As a first time user back then I found 3 hurdles:

1) missing deps needed for default config (see above) 2) needing to generate openapi YAML (could this not be done within pygeoapi startup?) 3) use of (the two) environment variables

Related to 1) also I propose to split off Provider deps from requirements-dev.txt into a requirements-providers.txt. 2) and 3) are for later, I can add issue for that if needed. There is this 5 (10?) minute rule for FOSS software: the time to get up and running or abandon.

tomkralidis commented 5 years ago

Thanks @justb4, I will open a separate ticket.

In terms of ease of install, does the install documentation help? Once we get documentation up and running would this help?

justb4 commented 5 years ago

Yes (with docs), though still I the number of install/run steps could be more compact (requirements-dev.txt not needed for minimal install , so for a developer section and above 2)+3)). Maybe also a pypi install.

justb4 commented 5 years ago

IMO the way to go is to add a Jinja2 macro replacing urlize. This macro will analyze the URL. If it ends with an image regexp like \.(?i:jpg|gif|png|bmp) it will try to render an HTML <img> element, in all other cases a regular <a> link element.

justb4 commented 5 years ago

Can take this up, and PR next, made a Jinja2 macro that gives results like this (image size is macro param):

image