2022-11 Developing On DSpace 7.4 Webinar
2022-11 Developing On DSpace 7.4 Webinar
2022-11 Developing On DSpace 7.4 Webinar
DSpace 7.4
• using Postman
github:DSpace-Labs/DSpace7RestTutorial postman-config
• via a programming language… we haven’t yet a
client SDK: maybe is a side project that you want to
start?
The
developer
webtools of
your
browser is
the best
way to
understand
the REST
API!
Accessing the home page
Accessing the home page
Several
REST
requests
are sent to
the
backend.
Use the
The status Fetch/XHR
(/server/api/authn/status) request
is used to discover if there is a
filter to
loggedin user to setup the easily focus
corresponding menu
on them
Accessing the
home page
HAL Format
Links are expressed in a
standard/well-known way in the
json response (it is also suitable for
xml but DSpace7 will focus only on
JSON)
→ Allow the client to decide which details are included in the response
→ Save HTTP round-trip
→ Respect the security
Specified via the projection param
default: no embeds
full: include everything up to a default depth (2)
level: allow the client to set the depth via the embedLevelDepth
parameter
https://jwt.io/
eid → EPerson uuid
sg → Special group
exp → Expiration
time
CSRF / XSRF
• https://github.com/DSpace/RestContract
– Aims to be the source of truth for all the
implemented endpoints
– Use GitHub issues/pull requests to
suggest changes, missing or wrong
information
REST cheat sheet
Stateless (no session) HTTP methods
GET (read), HEAD (read headers only)
Specifications POST (create)
JSON web tokens (JWT)
PUT (replace), PATCH (partial update)
•
• Cross-Origin Resource Sharing ( DELETE (remove)
CORS) Headers OPTIONS (verify access, e.g. via CORS)
• Cross-Site Request Forgery
Prevention (CSRF Token) HTTP return codes
2xx (Success)
HTTP Resources
3xx (Redirect)
● URIs reference individual
resources or collections (of 4xx (Client error)
resources) 5xx (Server error)
● /items/{uuid} and /items
Formats: JSON
Customizing the
DSpace 7 UI
What is Angular?
How does it work?
What is Angular?
Architecture
Front End
Web Browser 1 Initial Request
4 Return JSON
Architecture
Front End
Web Browser 1 Initial Request
● <ds-header>
● <ds-breadcrumbs>
● <ds-item-page>
● <ds-thumbnail>
● <ds-item-page-
field>
Angular: Components
• Each component has
– a ts file that contains the logic.
e.g. header.component.ts
– an html file that contains the markup.
e.g. header.component.html
– an scss file that contains the style.
e.g. header.component.scss
Angular: Components
@Component({
selector: 'ds-header',
styleUrls: ['./header.component.scss'],
templateUrl: './header.component.html'
})
export class HeaderComponent {}
Sass
Sass =>
CSS
$primary =>
var(--bs-primary);
$success =>
var(--bs-success);
$spacer =>
var(--bs-spacer);
CSS variables
$blue: #2B3A67;
$cyan: #207698;
$red: #FF325D;
primary: $yellow,
Colors
• Override css variables in the file
styles/_theme_css_variable_overrides.scss in your
theme folder
• It also contains a few example variables as
comments
• Look for other variables you can change in
src/styles/_custom_variables.scss
Colors
--ds-header-icon-color: #{$blue};
@import url('https://fonts.googleapis.com/css?
family=Source+Sans+Pro');
$font-family-sans-serif: 'Source Sans Pro', -apple-system, …
Footer
• Open app/footer/footer.component.ts in your
theme folder
• swap the templateUrl and styleUrls comments
• Open the base
app/footer/footer.component.html file
• Copy the contents to your theme’s version
Footer
• Open footer.component.scss in your theme
folder
• Set the color to $light and the background to
$dark
Footer
footer {
color: $light;
background: $dark;
}
Footer
• In the html file, add margins to the footer-info
links using Bootstrap classes:
<a class="text-white mr-2" routerLink="info/privacy">
• mr-2 is short for margin-right 2
• See the Bootstrap docs for more of these:
https://getbootstrap.com/docs
Footer
• Enable the top footer in footer.component.ts
.banner {
background-image:
url('/assets/workshop/images/pexels-will-mu-
3802667.jpg');
background-size: cover;
}
Home page news
• Compensate for the padding of <main> and add
margin below
• Open community-list-element.component.ts in
app/shared/object-list/community-list-element
inside your theme folder
• swap the templateUrl and styleUrls properties
Community list element
• Add the theme name to the
@listableObjectComponent decorator:
@listableObjectComponent(Community,
ViewMode.ListElement, Context.Any, 'workshop')
• Add the component to ENTRY_COMPONENTS in
EagerThemeModule
Community list element
• Open the base community-list-
element.component.html file
• Copy the contents to your theme’s version
• Add the ds-thumbnail to the HTML using
object.logo as the image
Community list element
<div class="d-flex justify-content-start">
<div class="thumbnail mr-3">
<ds-thumbnail [thumbnail]="(object.logo | async)?.payload">
</ds-thumbnail>
</div>
<div>
…
</div>
Community list element
• Get the code to retrieve the logo from
community-grid-element.component.ts
@Input() set object(object: Community) {
this._object = object;
if (hasValue(this._object) && hasNoValue(this._object.logo)) {
this.linkService.resolveLink<Community>(this._object,
followLink('logo'));
}
}
Get the code
https://tinyurl.com/webinar-2022-11
Wrap-Up
Learn & help at the same time!