Skip to content

Commit

Permalink
Clean up various parts after using this template myself
Browse files Browse the repository at this point in the history
  • Loading branch information
wetneb committed May 24, 2024
1 parent 8e2df93 commit 2f40c27
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 27 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ Sample OpenRefine extension
This repository contains a scaffold of an OpenRefine extension, which you can use as a basis to write your own.
See [our guide to writing extensions](https://openrefine.org/docs/technical-reference/writing-extensions) for more information about the process.

### Getting started

To start your own extension, click the "Use this template" button in the top right corner of this page.
This will create a copy of this repository, where you can then change:
* The extension name and description in `module/MOD-INF/module.properties`
* The `groupId`, `artifactId`, `name` and `description` fields in `pom.xml`
* Edit this `README.md` file to describe your extension to potential users and contributors instead of the sample extension's own instructions

25 changes: 3 additions & 22 deletions module/MOD-INF/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ var ClientSideResourceManager = Packages.com.google.refine.ClientSideResourceMan
* Function invoked to initialize the extension.
*/
function init() {
// Packages.java.lang.System.err.println("Initializing sample extension");
// Packages.java.lang.System.err.println(module.getMountPoint());

// Script files to inject into /project page
ClientSideResourceManager.addPaths(
"project/scripts",
Expand All @@ -59,25 +56,9 @@ function init() {
"styles/project-injection.css"
]
);
}

/*
* Function invoked to handle each request in a custom way.
*/
function process(path, request, response) {
// Analyze path and handle this request yourself.

if (path == "/" || path == "") {
var context = {};
// here's how to pass things into the .vt templates
context.someList = ["Superior","Michigan","Huron","Erie","Ontario"];
context.someString = "foo";
context.someInt = Packages.com.google.refine.sampleExtension.SampleUtil.stringArrayLength(context.someList);

send(request, response, "index.vt", context);
}
// Here you can register all sorts of server-side components following the extension points listed in:
// https://openrefine.org/docs/technical-reference/writing-extensions#server-side-ajax-commands
}

function send(request, response, template, context) {
butterfly.sendTextFromTemplate(request, response, context, template, encoding, html);
}

4 changes: 2 additions & 2 deletions module/MOD-INF/module.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name = sample
description = Google Refine Sample Extension
name = my-sample-extension
description = a short description of your extension goes here
templating.macros = macros.vm
requires = core
5 changes: 2 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.openrefine</groupId>
Expand All @@ -12,7 +12,6 @@
<url>http://openrefine.org/</url>

<build>
<finalName>openrefine-sample</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -47,7 +46,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<version>3.6.1</version>
<executions>
<execution>
<phase>compile</phase>
Expand Down

0 comments on commit 2f40c27

Please sign in to comment.