Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
06cacf0
Update file.scala.html
MBcode Mar 2, 2022
e014ef7
Update dataset.scala.html
MBcode Mar 2, 2022
9b5be93
Update LicenseData.scala
MBcode Mar 11, 2022
d5045cd
Update dataset.scala.html
MBcode Mar 11, 2022
ff1ec59
Update User.scala
MBcode Mar 11, 2022
0af5154
Update dataset.scala.html
MBcode Mar 11, 2022
ff58e12
all but quotes
MBcode Mar 13, 2022
0f73b47
Update dataset.scala.html
MBcode Mar 17, 2022
8f6f5b9
Update User.scala
MBcode Mar 18, 2022
bd92415
Update dataset.scala.html
MBcode Mar 18, 2022
06801a5
Update User.scala
MBcode Mar 18, 2022
735bb2b
Update User.scala
MBcode Mar 18, 2022
73c9395
Update file.scala.html
MBcode Mar 19, 2022
19b735d
urlViaAttributes infers license url from other attributes
MBcode Mar 28, 2022
19740e6
indent ld+json script/s
MBcode Mar 28, 2022
9539154
space-v-tab indenting
MBcode Mar 28, 2022
d1978da
Update CHANGELOG.md
MBcode Mar 28, 2022
88013db
try commas in list before making array and try All_rights_reserved de…
MBcode Apr 1, 2022
fd5cb39
add name:fullName
MBcode Apr 1, 2022
f2084c4
license has id now
MBcode Apr 1, 2022
84957bd
transitioning to dataset.to_jsonld
MBcode Apr 1, 2022
89067d5
to_jsonLD Json.obj even a little cleaner
MBcode Apr 1, 2022
40020b6
fix license to_jsonld ready2drop extra dataset methods
MBcode Apr 4, 2022
d18eea2
rm to_jsonLD call _all but2 List elts ret as js arrays now
MBcode Apr 4, 2022
b76a6b5
rm to_jsonLD method _fix thumbnail null value
MBcode Apr 4, 2022
9acbec7
to_jsonld method on tag class to return name
MBcode Apr 4, 2022
5d82811
add file.to_jsonld and for Stats and Section
MBcode Apr 4, 2022
aec38ef
leave only 1-line to_jsonld in dataset+file now
MBcode Apr 4, 2022
45694f7
put CLOWDER_URL or default in Server global to map fileIDs to fileURLs
MBcode Apr 5, 2022
2067a7f
Json.prettyPring dataset+file
MBcode Apr 5, 2022
0dd5664
handle either Server url ending slash case
MBcode Apr 5, 2022
489cdf5
in no CLOWEDER_URL make Server url from server IPaddress
MBcode Apr 5, 2022
db80df5
baseURLstr = Utils.baseUrl ( request ) .toString in dataset controlle…
MBcode Apr 7, 2022
bc9bd02
request.host gets url
MBcode Apr 8, 2022
6300fa4
clean/rm of save of hosturl
MBcode Apr 8, 2022
9e5d9d2
check Utils.baseUrl vs request.host
MBcode Apr 8, 2022
2a8dfca
rh2baseUrl a version of baseUrl that can take a requestHeader
MBcode Apr 8, 2022
2eaef00
baseUrl on RequestHeader now/was RequestAny
MBcode Apr 11, 2022
ece8fa1
rm rh2baseUrl now that baseUrl can handle RequestHeader
MBcode Apr 11, 2022
7095e8e
baseUrl signature change in CHANGELOG
MBcode Apr 11, 2022
9fab7c4
commiting to_jsonld w/url for dataset
MBcode Apr 15, 2022
277405b
Merge branch 'develop' into class2SOmetadata
MBcode Apr 18, 2022
61934c3
tmp/dbg try rest dataset files request
MBcode Apr 20, 2022
8a48bb5
edits to make
MBcode Apr 21, 2022
2a6a1ae
working mid iteration of last fixes
MBcode Apr 21, 2022
b7e66c1
looking for iso8601 date formater that works
MBcode Apr 22, 2022
e54fbd1
got iso8601 date
MBcode Apr 22, 2022
6f5244c
cap method does .take
MBcode Apr 22, 2022
b208833
want to cap_map then add ...
MBcode Apr 22, 2022
5961e93
cap_files w/o appending ... yet
MBcode Apr 22, 2022
1ebfc5c
got 1st of cap_ list methods cap_files
MBcode Apr 22, 2022
949aaec
start of cap_collections
MBcode Apr 25, 2022
0398594
cap_api_list files,collections,...
MBcode Apr 25, 2022
5c5816d
DataCatalog cap_spaces
MBcode Apr 26, 2022
7866c80
switch to Formatters.iso8601 ..
MBcode Apr 26, 2022
51e634b
custom/conf w/on log in/out GoTo
MBcode Apr 28, 2022
0a9947e
space=so:collection vs datacatalog _skip clowder collection all together
MBcode Apr 28, 2022
90baa13
fix thumbnail re comments
MBcode Apr 28, 2022
e2f1846
rm comments
MBcode Apr 28, 2022
336fe19
restructure cap_api_list desecription incl issue354 todo to make conf…
MBcode Apr 29, 2022
b5055cb
add iso date to File, max=10
MBcode Apr 29, 2022
18b2a9e
baseUrl take out dbg and add note about type signature change
MBcode Apr 29, 2022
90eb883
take out test root
MBcode Apr 29, 2022
b7ee03c
LicenseData comments
MBcode Apr 29, 2022
85e0034
Merge branch 'develop' into class2SOmetadata
MBcode May 4, 2022
ce28162
Merge branch 'develop' into class2SOmetadata
lmarini Jun 13, 2022
5ec4645
@context
MBcode Jun 23, 2022
177fb3c
rm comments/formating..
MBcode Jun 24, 2022
9b3563d
else format
MBcode Jun 26, 2022
b92991d
last rm-line/resolved comments
MBcode Jul 8, 2022
1df2be6
remove only 2 comments
MBcode Jul 28, 2022
0556fbb
Merge branch 'develop' into class2SOmetadata
robkooper Sep 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
## Unreleased

### Added
- Dataset and file scala.html pages incl schema.org jsonld metadata for (google)datasetsearch [#335](https://github.com/clowder-framework/clowder/issues/335)
- MiniUser and LicenseData now have to_jsonld methods to return string part of [#335](https://github.com/clowder-framework/clowder/issues/335) metadata
- LicenseData has urlViaAttributes used by it's to_jsonld to guess url when empty, for [#335](https://github.com/clowder-framework/clowder/issues/335)
- MRI previewer for NIFTY (.nii) files.

### Fixed
- Send email to all admins in a single email when a user submits 'Request access' for a space
- Send email to all admins and request user in a single email when any admin accepts/rejects 'Request access' for a space [#330](https://github.com/clowder-framework/clowder/issues/330)
- github actions would fail for docker builds due to secrets not existing

### Changed
- Utils.baseURL now on RequestHeader instead of Request[Any]

## 1.20.3 - 2022-06-10

### Fixed
Expand Down Expand Up @@ -49,6 +55,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Documentation: Added "How to contribute documentation" page
- Documentation: New Sphinx plugins for dropdowns and menus.


## 1.20.0 - 2022-02-07

### Added
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/Datasets.scala
Original file line number Diff line number Diff line change
Expand Up @@ -836,4 +836,4 @@ class Datasets @Inject() (
implicit val user = request.user
Ok(views.html.generalMetadataSearch())
}
}
}
9 changes: 5 additions & 4 deletions app/controllers/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ object Utils {
/**
* Return base url given a request. This will add http or https to the front, for example
* https://localhost:9443 will be returned if it is using https.
*
*/
def baseUrl(request: Request[Any], absolute: Boolean = true) = {
def baseUrl(request: RequestHeader, absolute: Boolean = true) = {
if (absolute) {
routes.Files.list().absoluteURL(https(request))(request).replace("/files", "")
routes.Files.list().absoluteURL(https(request))(request).replace("/files", "")
} else {
routes.Files.list().url.replace("/files", "")
routes.Files.list().url.replace("/files", "")
}
}

Expand Down Expand Up @@ -171,4 +172,4 @@ object Utils {
decodedReplies.toList
}
}
}
}
51 changes: 50 additions & 1 deletion app/models/Dataset.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import java.util.Date
import play.api.libs.json.{Writes, Json}
import play.api.libs.json._
import play.api.libs.functional.syntax._
import _root_.util.Formatters

/**
* A dataset is a collection of files, and streams.
Expand Down Expand Up @@ -38,6 +39,53 @@ case class Dataset(
def isDefault:Boolean = status == DatasetStatus.DEFAULT.toString
def isTRIAL:Boolean = status == DatasetStatus.TRIAL.toString
def inSpace:Boolean = spaces.size > 0

/**
* Caps a list at 'max'
* then turns it's ID's into resolvable URLs of that 'apiRoute' type
* end with appending "..." to the List, to signify that it was abridged
*
* todo: issue 354 to the max configurable
*/
def cap_api_list (l: List[UUID], max: Int, URLb: String, apiRoute: String) : List[String] = {
if (l.length <= max) {
return l.map(f => URLb + apiRoute + f)
} else {
val cl = l.take(max)
val r : List[String] = cl.map(f => URLb + apiRoute + f)
return r.::("...").reverse
}
}

/**
* return Dataset as JsValue in jsonld format
*/
def to_jsonld(url: String) : JsValue = {
val so = JsObject(Seq("@vocab" -> JsString("https://schema.org/")))
val URLb = url.replaceAll("/$", "")
var pic_id = thumbnail_id.getOrElse("")
if (pic_id != "") {
pic_id = URLb + pic_id
} else {
""
}
val datasetLD = Json.obj(
"@context" -> so,
"identifier" -> id.toString,
"name" -> name,
"author" -> author.to_jsonld(),
"description" -> description,
"dateCreated" -> Formatters.iso8601(created),
"DigitalDocument" -> Json.toJson(cap_api_list(files, 10, URLb, "/files/")),
"Collection" -> Json.toJson(cap_api_list(spaces, 10, URLb, "/spaces/")),
"thumbnail" -> Json.toJson(pic_id),
"license" -> licenseData.to_jsonld(),
"dateModfied" -> Formatters.iso8601(lastModifiedDate),
"keywords" -> tags.map(x => x.to_json()),
"creator" -> Json.toJson(creators)
)
return datasetLD
}
}

object DatasetStatus extends Enumeration {
Expand Down Expand Up @@ -68,8 +116,9 @@ object Dataset {
}



case class DatasetAccess(
showAccess: Boolean = false,
access: String = "N/A",
accessOptions: List[String] = List.empty
)
)
30 changes: 29 additions & 1 deletion app/models/File.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import java.util.Date

import models.FileStatus.FileStatus
import play.api.libs.json.{JsObject, Json, Writes}
import play.api.libs.json._
import _root_.util.Formatters

/**
* Uploaded files.
Expand Down Expand Up @@ -32,7 +34,33 @@ case class File(
licenseData: LicenseData = new LicenseData(),
followers: List[UUID] = List.empty,
stats: Statistics = new Statistics(),
status: String = FileStatus.UNKNOWN.toString) // can't use enums in salat
status: String = FileStatus.UNKNOWN.toString) { // can't use enums in salat
/**
* return File as JsValue in jsonld format
*/
def to_jsonld() : JsValue = {
val so = JsObject(Seq("@vocab" -> JsString("https://schema.org/")))
val fileLD = Json.obj(
"@context" -> so,
"identifier" -> id.toString,
"name" -> filename,
"author" -> author.to_jsonld(),
"isBasedOn" -> originalname,
"uploadDate" -> Formatters.iso8601(uploadDate),
"contentType" -> contentType,
"MenuSection" -> sections.map(x => x.to_jsonld()),
"keywords" -> tags.map(x => x.to_json()),
"thumbnail" -> Json.toJson(thumbnail_id.filterNot(_.isEmpty).getOrElse("")),
"description" -> description,
"license" -> licenseData.to_jsonld(),
"FollowAction" -> Json.toJson(followers),
"interactionStatistic" -> stats.to_jsonld,
"status" -> status
)
return fileLD
}
}


// what is the status of the file
object FileStatus extends Enumeration {
Expand Down
67 changes: 66 additions & 1 deletion app/models/LicenseData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package models

import api.Permission

import play.api.libs.json._


/**
* case class to handle specific license information. Currently attached to individual Datasets and Files.
*/
Expand Down Expand Up @@ -41,5 +44,67 @@ case class LicenseData (
def isRightsOwner(aName: String) = {
m_rightsHolder == aName
}
}

/**
* Utility to return a url even if empty, but enough other attributes available to determine it
* this is repurposed from:
* function updateData(id, imageBase, sourceObject, authorName)
* in updateLicenseInfo.js line:88
*/
def urlViaAttributes() : String = {
if (m_licenseUrl != "") return m_licenseUrl
var licenseUrl = m_licenseUrl;
if (m_licenseType == "license2") {
//No checkboxes selected
if (!m_ccAllowCommercial && !m_ccAllowDerivative && !m_ccRequireShareAlike) {
licenseUrl = "http://creativecommons.org/licenses/by-nc-nd/3.0/";
}
//Only commercial selected
else if (m_ccAllowCommercial && !m_ccAllowDerivative && !m_ccRequireShareAlike) {
licenseUrl = "http://creativecommons.org/licenses/by-nd/3.0/";
}
//Only remixing selected
else if (!m_ccAllowCommercial && m_ccAllowDerivative && !m_ccRequireShareAlike) {
licenseUrl = "http://creativecommons.org/licenses/by-nc/3.0/";
}
//Remixing and Sharealike selected
else if (!m_ccAllowCommercial && m_ccAllowDerivative && m_ccRequireShareAlike) {
licenseUrl = "http://creativecommons.org/licenses/by-nc-sa/3.0/";
}
//All checkboxes selected
else if (m_ccAllowCommercial && m_ccAllowDerivative && m_ccRequireShareAlike) {
licenseUrl = "http://creativecommons.org/licenses/by-sa/3.0/";
}
//Commercial and Remixing selected
else if (m_ccAllowCommercial && m_ccAllowDerivative && !m_ccRequireShareAlike) {
licenseUrl = "http://creativecommons.org/licenses/by/3.0/";
}
//else { rightsHolder = 'Creative Commons';
// licenseText = 'Specific level info'; }
}
else if (m_licenseType == "license3") {
licenseUrl = "http://creativecommons.org/publicdomain/zero/1.0/";
}
else {
licenseUrl = "https://dbpedia.org/page/All_rights_reserved";
}
return licenseUrl
}

/**
* Utility function, similar to a json Write, to return string version in json-ld format
* Should also return key
*/
def to_jsonld () : JsValue = {
val licURI = this.urlViaAttributes() //URI = URL except in one case:
val licURL = if (licURI != "https://dbpedia.org/page/All_rights_reserved") licURI
else ""
val licLD = JsObject(Seq(
"@id" -> JsString(licURI),
"URL" -> JsString(licURL),
"@type" -> JsString("license"),
"Text" -> JsString(m_licenseText) //added this DataType
))
return licLD
}
}
11 changes: 9 additions & 2 deletions app/models/Section.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package models

import play.api.libs.json._

/**
* A portion of a file.
*
Expand All @@ -17,12 +19,17 @@ case class Section(
metadataCount: Long = 0,
@deprecated("use Metadata","since the use of jsonld") jsonldMetadata : List[Metadata]= List.empty,
thumbnail_id: Option[String] = None,
tags: List[Tag] = List.empty)
tags: List[Tag] = List.empty) {
def to_jsonld() : JsValue = {
return Json.toJson(description)
}
}


case class Rectangle(
x: Double,
y: Double,
w: Double,
h: Double) {
override def toString() = f"x: $x%.2f, y: $y%.2f, width: $w%.2f, height: $h%.2f"
}
}
3 changes: 2 additions & 1 deletion app/models/ServerStartTime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package models

import java.util.Date


/**
* Keeps track of server start time
* Used in Global Object
Expand All @@ -10,4 +11,4 @@ import java.util.Date
object ServerStartTime {
var startTime: Date=null

}
}
7 changes: 6 additions & 1 deletion app/models/Statistic.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ case class Statistics (
downloads: Int = 0,
last_viewed: Option[Date] = None,
last_downloaded: Option[Date] = None
)
) {
def to_jsonld() : JsValue = {
return Json.toJson(views)
}
}


case class StatisticUser (
user_id: UUID,
Expand Down
9 changes: 8 additions & 1 deletion app/models/Tag.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package models

import java.util.Date

import play.api.libs.json._


/**
* Add and remove tags
*
Expand All @@ -11,4 +14,8 @@ case class Tag(
name: String,
userId: Option[String],
extractor_id: Option[String],
created: Date)
created: Date) {
def to_json() : JsValue = {
return Json.toJson(name)
}
}
28 changes: 27 additions & 1 deletion app/models/User.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import play.api.libs.json.{JsObject, Json, Writes}
import securesocial.core._
import services.AppConfiguration

import play.api.libs.json._

object UserStatus extends Enumeration {
type UserStatus = Value
val Inactive, Active, Admin = Value
Expand Down Expand Up @@ -108,7 +110,31 @@ case class MiniUser(
id: UUID,
fullName: String,
avatarURL: String,
email: Option[String])
email: Option[String]) {
/**
* return MiniUser as string in jsonld format, w/fullName split into first and last
*/
def to_jsonld() : JsValue = {
var firstName = "";
var lastName = "";
if (fullName.split("\\w+").length > 1) {
lastName = fullName.substring(fullName.lastIndexOf(" ") + 1);
firstName = fullName.substring(0, fullName.lastIndexOf(' '));
} else {
firstName = fullName;
}
val authorLD = JsObject(Seq(
"@type" -> JsString("Person"),
"name" -> JsString(fullName),
"givenName" -> JsString(firstName),
"familyName" -> JsString(lastName),
"email" -> JsString(email.getOrElse("")),
"image" -> JsString(avatarURL)
))
return authorLD
}
}


case class ClowderUser(
id: UUID = UUID.generate(),
Expand Down
8 changes: 8 additions & 0 deletions app/views/dataset.scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
@import services.EventSinkService
@import services.DI

@import play.api.libs.json._


@main(dataset.name) {
<link rel="stylesheet" href="@routes.Assets.at("stylesheets/glyphicon-animations.css")">
<script src="@routes.Assets.at("javascripts/htmlEncodeDecode.js")" language="javascript"></script>
Expand Down Expand Up @@ -382,6 +385,11 @@ <h4>Statistics</h4>
<script src="@routes.Assets.at("javascripts/deleteUtils.js")" type="text/javascript"></script>
<script src="@routes.Assets.at("javascripts/people.js")" type="text/javascript"></script>
<script src="@routes.Assets.at("javascripts/creators.js")" type="text/javascript"></script>

<script type="application/ld+json">
@Html(Json.prettyPrint(dataset.to_jsonld(Utils.baseUrl(request))))
</script>

<script type="text/javascript">
var removeIndicator = false;
var parentId = "@dataset.id";
Expand Down
Loading