Exemplo n.º 1
0
def palp_browse(identifier):

    r = plodlib.PLODResource(identifier)

    try:
        return palp_html_document(
            r,
            globals()[f'{r.rdf_type}_render']).render(
            )  # call p_h_d with right render function if it exists
    except KeyError as e:
        return palp_html_document(r, unknown_render).render()
Exemplo n.º 2
0
def palp_depicted_where(r, level_of_detail='feature'):

    element = div()
    with element:
        for i, row in pd.DataFrame(data=json.loads(
                r.depicted_where(level_of_detail=level_of_detail))).iterrows():
            with table(style="border: 1px solid black;margin-top:5px"):
                with tr():
                    with td(style="padding-top:5px"):
                        relative_url, label = urn_to_anchor(row['within'])
                        span("Within ")
                        a(label, href=relative_url)
                        span(" on wall or feature:")
                    with td(style="padding-top:5px"):
                        relative_url, label = urn_to_anchor(row['urn'])
                        a(label, href=relative_url)

                with tr():
                    if row['best_image'] != 'None':  # Has a best image
                        tilde_val = luna_tilde_val(row['best_image'])

                        with td(colspan=2):

                            img_src, img_description = img_src_from_luna_info(
                                l_collection_id=
                                f'umass~{tilde_val}~{tilde_val}',
                                l_record=row['l_record'],
                                l_media=row['l_media'])
                            img(src=img_src)

                            with div(style="width:500px"):
                                span(str(img_description))
                                span(' [')
                                a(f"about image {row['best_image']}...",
                                  href=
                                  f"https://umassamherst.lunaimaging.com/luna/servlet/detail/umass~{tilde_val}~{tilde_val}~{row['l_record']}~{row['l_media']}"
                                  )
                                span("]")

                    else:  # No best image
                        with td(colspan=2):
                            get_first_image_of = row['urn'].replace(
                                "urn:p-lod:id:", "")
                            palp_depicted_by_images(
                                plodlib.PLODResource(get_first_image_of),
                                first_only=True)

    return element
Exemplo n.º 3
0
def test_image_gallery(identifier):

    html_dom = dominate.document(title=f"Pompeii Artistic Landscape Project")

    r = plodlib.PLODResource(identifier)

    r_images = json.loads(r.images)

    palp_html_head(r, html_dom)
    html_dom.body

    with html_dom:
        with div(_class="galleria",
                 style="width: 700px; height: 400px; background: #000"):
            for i in r_images:
                tilde_val = luna_tilde_val(i['urn'])
                with div(_class="image"):
                    img(src=i['l_img_url'])
                    h2("", style="color:white")
                    with div(_class="desc"):
                        span('[')
                        a("More...",
                          href=
                          f"https://umassamherst.lunaimaging.com/luna/servlet/detail/umass~{tilde_val}~{tilde_val}~{i['l_record']}~{i['l_media']}"
                          )
                        span('] ')
                        span(i['l_description'], style="color:white")

        s = script(type="text/javascript")
        s += raw("""(function() {
                Galleria.loadTheme('https://cdnjs.cloudflare.com/ajax/libs/galleria/1.6.1/themes/twelve/galleria.twelve.min.js');
                Galleria.configure({lighgbox: true,
                                    imageCrop: false , 
                                    carousel: false,
                                    dataConfig: function(img) {
        return {
            title: $(img).next('h2').html(), // tell Galleria to use the h2 as title
            description: $(img).siblings('.desc').html() // tell Galleria to grab the content from the .desc div as caption
        };
    }})
                Galleria.run('.galleria');
            }());
""")

    return html_dom.render()
Exemplo n.º 4
0
def palp_start():
    r = plodlib.PLODResource("Pompeii")
    html_dom = dominate.document(title=f"Pompeii Artistic Landscape Project")

    palp_html_head(r, html_dom)
    html_dom.body
    palp_page_navbar(r, html_dom)

    with html_dom:
        with div(id="page-content-wrapper"):
            with div(id="container-fluid"):
                pi = p(
                    """Useful, appealing, and explanatory start page that looks like a PALP page.
    Eric Poehler (UMass), Director and Sebastian Heath (NYU/ISAW), Co-Director. Funded by Getty Foundation. Etc., etc., etc.
    """)
                pi.add(a("Pompeii", href="/browse/pompeii"))

    palp_page_footer(r, html_dom)
    return html_dom.render()
Exemplo n.º 5
0
def palp_spatial_children(r, images=False):

    element = span()
    with element:
        for i, c in enumerate(json.loads(r.spatial_children())):
            #relative_url, label = urn_to_anchor(i[0])
            #a(label, href=relative_url)
            #span(" /", style="color: LightGray")
            with table(style="border: 1px solid black;margin-top:5px"):
                with tr():
                    with td(style="padding-top:5px"):
                        relative_url, label = urn_to_anchor(c['urn'])
                        a(label, href=relative_url)

            if (images and (i < 10)):
                with tr():
                    with td(colspan=3):
                        get_first_image_of = c['urn'].replace(
                            "urn:p-lod:id:", "")
                        palp_depicted_by_images(
                            plodlib.PLODResource(get_first_image_of),
                            first_only=True)

    return element
Exemplo n.º 6
0
import plodlib

r_list = [
    'pompeii', 'r1', 'r1-i1', 'r1-i9-p1', 'bird', 'dog', 'ariadne',
    'bogus_id_bogus'
]

# run through instantiating ids and printing standard info
for r in r_list:
    c = plodlib.PLODResource(r)
    print(
        f'''*Made instance of PLODResource for "{r}" now reading from returned object
  Identifier: {c.identifier} (as passed: {c._identifier_parameter})
  Type: {c.rdf_type}
  Label: {c.label}
  P-in-P URL: {c.p_in_p_url}
  Wikidata URL: {c.wikidata_url}

		''')

# Call functions for each item in r_list

for r in r_list:
    print(f'*Spatial hierarchy for "{r}"')
    print(plodlib.PLODResource(r).spatial_hierarchy_up())

for r in r_list:
    print(f'*Spatial children for "{r}"')
    print(plodlib.PLODResource(r).spatial_children())

for r in r_list:
Exemplo n.º 7
0
def web_api_images(identifier):
    return plodlib.PLODResource(identifier).images_from_luna
Exemplo n.º 8
0
def web_api_geojson(identifier):
    return plodlib.PLODResource(identifier).geojson
Exemplo n.º 9
0
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "p-lod": "urn:p-lod:id:"
}

app = Flask(__name__)

# Connect to the remote triplestore with read-only connection
store = rdf.plugin.get("SPARQLStore", rdf.store.Store)(
    endpoint="http://52.170.134.25:3030/plod_endpoint/query",
    context_aware=False,
    returnFormat='json')
g = rdf.Graph(store)

# a 'global' available as a convenience
POMPEII = plodlib.PLODResource('pompeii')


def palp_html_head(r, html_dom):
    html_dom.head += meta(charset="utf-8")
    html_dom.head += meta(http_equiv="X-UA-Compatible", content="IE=edge")
    html_dom.head += meta(name="viewport",
                          content="width=device-width, initial-scale=1")
    html_dom.head += link(
        rel="stylesheet",
        href=
        "https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css",
        integrity=
        "sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2",
        crossorigin="anonymous")
    html_dom.head += script(