Skip to content

Commit

Permalink
restore the old hydroshare plugin and fix some style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
romer8 committed Mar 25, 2024
1 parent be5c5f7 commit ba185bd
Show file tree
Hide file tree
Showing 5 changed files with 137 additions and 26 deletions.
12 changes: 5 additions & 7 deletions backend/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django.utils.translation import gettext_lazy as _
from .models import (
HydroShareResource,
)
from .models import HydroShareResourceList

import logging

logger = logging.getLogger(__name__)


@plugin_pool.register_plugin
class HydroShareResourcePlugin(CMSPluginBase):
model = HydroShareResource
name = _("HydroShare Resource Plugin")
render_template = "hydroshare_resource_template.html"
class HydroShareResourceListPlugin(CMSPluginBase):
model = HydroShareResourceList
name = _("HydroShare Resource List Plugin")
render_template = "hydroshare_list_resources.html"
cache = False

def render(self, context, instance, placeholder):
Expand Down
24 changes: 24 additions & 0 deletions backend/migrations/0031_auto_20240325_1836.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 3.2 on 2024-03-25 18:36

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('cms', '0022_auto_20180620_1551'),
('backend', '0030_zoterobibliographyresource_is_saving'),
]

operations = [
migrations.RemoveField(
model_name='zoterobibliographyresource',
name='cmsplugin_ptr',
),
migrations.DeleteModel(
name='HydroLearnModulesList',
),
migrations.DeleteModel(
name='ZoteroBibliographyResource',
),
]
24 changes: 8 additions & 16 deletions backend/models.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,18 @@
from cms.models.pluginmodel import CMSPlugin
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models

import uuid

import logging

logger = logging.getLogger(__name__)


class HydroShareResource(CMSPlugin):
title = models.CharField(max_length=200, default="resource title")
subtitle = models.CharField(max_length=200, default="resource subtitle")
image = models.CharField(max_length=200, default="https://picsum.photos/200")
width = models.PositiveIntegerField(
default=200, validators=[MinValueValidator(150), MaxValueValidator(400)]
class HydroShareResourceList(CMSPlugin):
user = models.CharField(max_length=200, default="", blank=True)
password = models.CharField(max_length=200, default="", blank=True)
placeholder_image = models.CharField(
max_length=200, default="https://picsum.photos/200"
)
height = models.PositiveIntegerField(
default=200, validators=[MinValueValidator(150), MaxValueValidator(400)]
)
description = models.TextField(default="resource description")
github_url = models.CharField(max_length=200, default="", blank=True)
documentation_url = models.CharField(max_length=200, default="", blank=True)
web_site_url = models.CharField(max_length=200, default="", blank=True)
unique_identifier = models.UUIDField(default=uuid.uuid4, editable=False)
tags = models.CharField(max_length=200, default="")
updated_version = models.IntegerField(default=0, editable=False)
resources = models.JSONField(editable=False, default=dict)
95 changes: 95 additions & 0 deletions backend/templates/hydroshare_list_resources.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{% load cms_tags sekizai_tags %}

{% addtoblock "css" %}
<style>
:root {
--image-width: 200px;
--image-height: 200px;
}

.img-tile{
object-fit: cover;
}

.name{
height: 150px;
cursor: pointer;
}

/* Hide scrollbar for Chrome, Safari and Opera */
.name::-webkit-scrollbar {
display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.name {
-ms-overflow-style: none; /* IE and Edge */
scrollbar-width: none; /* Firefox */
}

.hydroshare_resource{
box-shadow: 0 1px 10px 0 rgba(0,0,0,0.125), inset 0 0 0 1px rgba(255,255,255,0.75);
border-color: white;
border-bottom: 3px solid #255f9c;
}
.hydroshare_resource:hover,
.hydroshare_resource:focus {
background: #f5f5f5;
border-color: #bebebe;
box-shadow: 0 1px 4px 0 rgba(0,117,180,0.4);
}
.cover-image {
position: relative;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
cursor: pointer;
}

.cover-image img {
display: block;
width: 100%;
transition: filter 0.5s ease; /* Smooth transition for the filter */
}

.learn-more {
position: absolute;
color: white;
padding: 5px 10px;
visibility: hidden;
transition: visibility 0s, opacity 0.5s linear; /* Smooth transition for visibility and opacity */
opacity: 0;
border-color: #255f9c;
border-radius: 3px;
background: #255f9c;
}

.cover-image:hover .learn-more {
visibility: visible;
opacity: 1; /* Make it fully opaque on hover */
}

.cover-image:hover img {
filter: brightness(50%); /* Darken the image */
}
.learn-more > a {
color: inherit;
text-decoration: none;
}

</style>
{% endaddtoblock %}
<div>

</div>


<div class="container-hydroshare-resource-list-plugin">
{% for key, values in instance.resources.items %}
<div class="wrapper-publication-set">


</div>
{% endfor %}
</div>
8 changes: 5 additions & 3 deletions hydroshare_resources_app/static/js/hs_resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ const fetchHydroShareResources = () => {
<div class="col-12 col-sm-6 col-md-8 col-lg-8 border-light">
<div class="card-body h-100">
<div class="d-flex align-items-baseline gap-2 justify-content-center justify-content-lg-start justify-content-md-start">
<h5 class="card-title card-h5">${resource.title}</h5>`
<h6 class="card-title card-h5">${resource.title}</h6>`

resourcesHTML += `<div style="width:fit-content;">`
resourcesHTML +=`<p class="card-text my-2 fs-6 lh-1.5 fw-light d-flex flex-row justify-content-between w-100 gap-3 rounded p-1" style="max-width:300px;">`
Expand All @@ -74,10 +75,11 @@ const fetchHydroShareResources = () => {
}
// resourcesHTML +=`<a href="${resource.resource_url}" target="_blank" class="text-decoration-none text-secondary" style="font-size: 0.80rem !important;" title="Open HydroShare Resource"> <span class="badge text-bg-secondary">HydroShare</span></a>`
resourcesHTML +=`</p></div></div>`


resourcesHTML +=`<p class="card-subtitle mb-2 text-muted"><a href="${resource.resource_url}" target="_blank" class="text-decoration-none text-secondary" style="font-size: 0.80rem !important;" title="Open HydroShare Resource"> <span class="badge text-bg-secondary">View on HydroShare</span></a></p>`
resourcesHTML +=`<p class="card-subtitle mb-2 text-muted d-flex justify-content-center justify-content-lg-start justify-content-md-start justify-content-xl-start"><a href="${resource.resource_url}" target="_blank" class="text-decoration-none text-secondary" style="font-size: 0.80rem !important;" title="Open HydroShare Resource"> <span class="badge text-bg-secondary">View on HydroShare</span></a></p>`

resourcesHTML +=`<div class="d-flex flex-column justify-content-center justify-content-lg-start justify-content-md-start text-center text-lg-start text-md-start h-100">
resourcesHTML +=`<div class="d-flex flex-column justify-content-lg-start justify-content-md-start text-center text-lg-start text-md-start h-100">
<p class="name w-100 mb-3 overflow-auto">
${resource.abstract}
</p>
Expand Down

0 comments on commit ba185bd

Please sign in to comment.