forked from geonetwork/core-geonetwork
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
adf18df
commit 3d50fc0
Showing
75 changed files
with
1,502 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Customize your GeoNetwork UI {#tuto-customui} | ||
|
||
- [Search Index](search/index.md) | ||
- [View Index](view/index.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Customizing default view {#tuto-search-customview} | ||
|
||
Follow [instructions](customview.md) and create your first custom view. | ||
|
||
## Exercices | ||
|
||
1. Create a new view with almost no content | ||
2. Make your new view looks like the default one | ||
3. Create your own result list template | ||
4. Make main templates url customizable. | ||
5. Put the search map upon facets | ||
6. Let's build a new search page quickly | ||
|
||
## Corrections | ||
|
||
Go to <https://github.com/fgravin/core-geonetwork/commits/foss4g> | ||
|
||
1. step-1 | ||
2. step-2 | ||
3. step-3 | ||
4. step-4 | ||
5. step-5 | ||
6. step-6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Customizing default view {#tuto-search-defaultview} | ||
|
||
## Objectives | ||
|
||
Read instructions about [default view customization](configdefaultview.md). | ||
|
||
- Understand view settings. | ||
- Be able to customize the default view. | ||
|
||
## Exercices | ||
|
||
- Propose 4 hits per page options for search result list : 2, 5, 10, 20. | ||
|
||
- Propose to sort only by change date and title. | ||
|
||
- Use Stamen layer source for search map background. | ||
|
||
- Recenter search map on Seoul | ||
|
||
- | ||
|
||
Change full map configuration | ||
|
||
: - play with initial extent | ||
- change brackground layer list | ||
- add WMS layers to the default map | ||
|
||
- Change default location for map search | ||
|
||
- Change WMS/WMTS default services | ||
|
||
- Customize full map without OWS Context | ||
|
||
- Disable map viewer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Search page {#tuto-customui-search} | ||
|
||
- [Loadpage](loadpage.md) | ||
- [Defaultview](defaultview.md) | ||
- [Customview](customview.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Understand loading page mechanisms {#tuto-search-loadpage} | ||
|
||
## Objectives | ||
|
||
Read instructions in [customization section](loadsearchpage.md). | ||
|
||
- understand the XSL service output | ||
- look at the `view` parameter | ||
- understand main template loading | ||
- understand javascript modules bootstrap | ||
|
||
## Resources | ||
|
||
- XSLT files | ||
- [base layout](https://github.com/geonetwork/core-geonetwork/blob/main/web/src/main/webapp/xslt/base-layout.xsl). | ||
- [js and css loader](https://github.com/geonetwork/core-geonetwork/blob/main/web/src/main/webapp/xslt/base-layout-cssjs-loader.xsl). | ||
- [variables](https://github.com/geonetwork/core-geonetwork/blob/main/web/src/main/webapp/xslt/common/base-variables.xsl). | ||
- [search page](https://github.com/geonetwork/core-geonetwork/blob/main/web/src/main/webapp/xslt/ui-search/search.xsl). | ||
- Template files | ||
|
||
<https://github.com/geonetwork/core-geonetwork/blob/main/web-ui/src/main/resources/catalog/views/default/templates/index.html> | ||
|
||
- AngularJS module | ||
|
||
<https://github.com/geonetwork/core-geonetwork/blob/main/web-ui/src/main/resources/catalog/views/default/module.js> | ||
|
||
- Less file | ||
|
||
<https://github.com/geonetwork/core-geonetwork/blob/main/web-ui/src/main/resources/catalog/views/default/module.js> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
# Create a new formatter {#tuto-formatter} | ||
|
||
## Objectives | ||
|
||
- oversee groovy formatter mechnism | ||
- understand handlers, matchers concepts | ||
- create a small formatter | ||
|
||
## Exercices | ||
|
||
1. Add a new formatter that display all text information of the metadata in basic layout. | ||
2. Update previous formatter to display labels of the text fields. | ||
3. Use formatter templating system to render the handler's view | ||
4. Add styling to your formatter view. | ||
5. Create a tree for rendering elements | ||
6. Use translation of iso elements | ||
7. Use default tree styling | ||
8. Use all default view formatter elements | ||
9. Customise default formatter view | ||
10. Overload handlers methods | ||
|
||
## Corrections | ||
|
||
Go to <https://github.com/fgravin/core-geonetwork/commits/foss4g> | ||
|
||
1\. Create a new formatter - create a new folder named 'foss4g" in /schemas/iso19139/src/main/plugin/iso19139/formatter - create a new groovy file in this new folder - text information are stored in `gco:CharacterString` | ||
|
||
> handlers.add 'gco:CharacterString', {el -> "<div>${el.text()}</div>"} | ||
2. Add a matcher and play with `name` and `text` properties. | ||
|
||
> handlers.add select: {el -> !el.'gco:CharacterString'.text().isEmpty()}, {el -> | ||
> "<div><b>${el.name()}</b> - ${el.text()}</div>" | ||
> } | ||
3. Use `handlers.fileResult` function | ||
|
||
- view.groovy | ||
|
||
handlers.add select: {el -> !el.'gco:CharacterString'.text().isEmpty()}, {el -> | ||
handlers.fileResult('foss4g/elem.html', [name: el.name(), text: el.text()]) | ||
} | ||
|
||
- elem.html | ||
|
||
<dl> | ||
<dt>{{name}}</dt> | ||
<dd>{{text}}</dd> | ||
</dl> | ||
|
||
4. Add a custom less file in wro4j inspected folders and link it to your formatter | ||
|
||
- formatter.less | ||
|
||
dt { | ||
width: 230px; | ||
font-weight: normal; | ||
font-style: italic; | ||
color: #555555; | ||
clear: none; | ||
padding-left: 15px; | ||
text-align: left; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
white-space: nowrap; | ||
float: left; | ||
} | ||
|
||
dd { | ||
margin-left: 250px; | ||
border-left: 1px solid #999999; | ||
padding-left: 1em; | ||
background: #eeeeee; | ||
} | ||
|
||
- view.groovy | ||
|
||
handlers.start { | ||
'''<link rel="stylesheet" href="../../static/formatter.css"/> | ||
<div class="container">''' | ||
} | ||
handlers.end { | ||
'</div>' | ||
} | ||
|
||
handlers.add select: {el -> !el.'gco:CharacterString'.text().isEmpty()}, {el -> | ||
handlers.fileResult('foss4g/elem.html', [name: el.name(), text: el.text()]) | ||
} | ||
|
||
5. Use `fmt-repeat-only-children` in template and `prent()` function. | ||
|
||
- view.groovy | ||
|
||
... | ||
handlers.add select: {el -> !el.'gco:CharacterString'.text().isEmpty()}, | ||
group: true, {els -> | ||
def elements = els.collect {el -> | ||
[name: el.name(), text: el.text()] | ||
} | ||
handlers.fileResult('foss4g/elem.html', | ||
[elements: elements, parent: els[0].parent().name()]) | ||
} | ||
|
||
- elem.html | ||
|
||
<dl> | ||
<h3>{{parent}}</h3> | ||
<div fmt-repeat="el in elements" fmt-repeat-only-children="true"> | ||
<dt>{{el.name}}</dt> | ||
<dd>{{el.text}}</dd> | ||
</div> | ||
</dl> | ||
|
||
6. See `nodeLabel` function | ||
|
||
- view.groovy | ||
|
||
> ... | ||
> handlers.add select: {el -> !el.'gco:CharacterString'.text().isEmpty()}, | ||
> group: true, {els -> | ||
> def elements = els.collect {el -> | ||
> [name: f.nodeLabel(el), text: el.text()] | ||
> } | ||
> handlers.fileResult('foss4g/elem.html', | ||
> [elements: elements, parent: f.nodeLabel(els[0].parent())]) | ||
> } | ||
7. Add `gn-metadata-view` class to your container update your handler. | ||
|
||
- view.groovy | ||
|
||
> handlers.start { | ||
> '''<div class="gn-metadata-view container">''' | ||
> } | ||
> handlers.end { | ||
> '</div>' | ||
> } | ||
> | ||
> def isoHandlers = new iso19139.Handlers(handlers, f, env) | ||
> | ||
> handlers.add select: isoHandlers.matchers.isTextEl, isoHandlers.isoTextEl | ||
> handlers.add name: 'Container Elements', | ||
> select: isoHandlers.matchers.isContainerEl, | ||
> priority: -1, | ||
> isoHandlers.commonHandlers.entryEl(f.&nodeLabel, | ||
> isoHandlers.addPackageViewClass) | ||
> isoHandlers.addExtentHandlers() | ||
8. See `SummaryFactory` class. | ||
|
||
- view.groovy | ||
|
||
> import iso19139.SummaryFactory | ||
> | ||
> def isoHandlers = new iso19139.Handlers(handlers, f, env) | ||
> | ||
> SummaryFactory.summaryHandler({it.parent() is it.parent()}, isoHandlers) | ||
> | ||
> isoHandlers.addDefaultHandlers() | ||
9. Add custom option to the `SummaryFactory` | ||
|
||
- view.groovy | ||
|
||
> import iso19139.SummaryFactory | ||
> | ||
> def isoHandlers = new iso19139.Handlers(handlers, f, env) | ||
> | ||
> def factory = new SummaryFactory(isoHandlers, {summary -> | ||
> summary.title = "My Title" | ||
> summary.addCompleteNavItem = false | ||
> summary.addOverviewNavItem = false | ||
> summary.associated.clear() | ||
> }) | ||
> | ||
> | ||
> handlers.add name: "Summary Handler", | ||
> select: {it.parent() is it.parent()}, | ||
> {factory.create(it).getResult()} | ||
> isoHandlers.addDefaultHandlers() | ||
10. Add custom behavior to `iso19139.Handlers` constructor | ||
|
||
- view.groovy | ||
|
||
> def isoHandlers = new iso19139.Handlers(handlers, f, env) { | ||
> { | ||
> def oldImpl = super.isoTextEl | ||
> isoTextEl = { el -> | ||
> "----------- ${oldImpl(el)}" | ||
> } | ||
> } | ||
> } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Formatter {#tuto-customui-viw} | ||
|
||
- [Formatter](formatter.md) |
73 changes: 73 additions & 0 deletions
73
docs/manual/docs/tutorials/hookcustomizations/events/index.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Using Events {#tuto-hookcustomizations-events} | ||
|
||
From GeoNetwork 3.0.x on, there are a number of events you can listen to on your Java code. | ||
|
||
## Enabling Event Listeners | ||
|
||
To enable this on your Maven project, you have to add the event dependencies. Edit the file **`custom/pom.xml`** and add the dependencies tag: | ||
|
||
``` xml | ||
<dependencies> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>events</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>core</artifactId> | ||
<version>${project.version}</version> | ||
</dependency> | ||
</dependencies> | ||
``` | ||
|
||
Then create the file custom/src/main/resources/config-spring-geonetwork.xml to tell Spring to load your custom beans adding the following content: | ||
|
||
``` xml | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" | ||
xmlns:util="http://www.springframework.org/schema/util" | ||
xmlns:context="http://www.springframework.org/schema/context" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation= | ||
"http://www.springframework.org/schema/beans | ||
http://www.springframework.org/schema/beans/spring-beans.xsd | ||
http://www.springframework.org/schema/util | ||
http://www.springframework.org/schema/util/spring-util.xsd | ||
http://www.springframework.org/schema/context | ||
http://www.springframework.org/schema/context/spring-context-3.2.xsd"> | ||
<bean class="org.fao.geonet.events.listeners.MyCustomListener" ></bean> | ||
</beans> | ||
``` | ||
|
||
This file should contain a list of all the classes that listen to events inside GeoNetwork scope. | ||
|
||
## Simple Example | ||
|
||
We can add a simple example listener like this one, which will print a string every time a metadata gets removed. | ||
|
||
``` java | ||
package org.fao.geonet.events.listeners; | ||
|
||
import org.fao.geonet.domain.*; | ||
|
||
import org.fao.geonet.events.md.MetadataRemove; | ||
|
||
import org.springframework.context.ApplicationListener; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
public class MyCustomListener implements ApplicationListener<MetadataRemove> { | ||
@Override | ||
public void onApplicationEvent(MetadataRemove event) { | ||
System.out.println("REMOVED"); | ||
} | ||
} | ||
``` | ||
|
||
For example, we can call an external REST API that gets triggered every time a Metadata gets removed or updated. | ||
|
||
## GeoNetwork API | ||
|
||
There is also a new API you can use to interact with GeoNetwork from an external script. See more on [api-guide](api-guide.md). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Hook your own code {#tuto-hookcustomizations} | ||
|
||
At the end of this tutorial, you should be able to customize your own code into GeoNetwork on a clean and easy to upgrade way. You should start with the [tuto-introduction](tuto-introduction.md) tutorial first. | ||
|
||
- [Newproject Index](newproject/index.md) | ||
- [Events Index](events/index.md) | ||
- [Ui Index](ui/index.md) | ||
- [Schemaplugins Index](schemaplugins/index.md) | ||
- [Searchfields Index](searchfields/index.md) |
Binary file added
BIN
+58.7 KB
docs/manual/docs/tutorials/hookcustomizations/newproject/img/listprojects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.