Skip to content

Commit

Permalink
Add vuecket-extensions (issue #1). Markdown, fullcalendar, chat
Browse files Browse the repository at this point in the history
  • Loading branch information
PhantomYdn committed Jun 2, 2021
1 parent af6403e commit fa9d975
Show file tree
Hide file tree
Showing 10 changed files with 506 additions and 8 deletions.
8 changes: 3 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<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/xsd/maven-4.0.0.xsd">
--><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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.orienteer.vuecket</groupId>
Expand Down Expand Up @@ -251,5 +248,6 @@
<modules>
<module>vuecket</module>
<module>vuecket-demo</module>
</modules>
<module>vuecket-extensions</module>
</modules>
</project>
5 changes: 5 additions & 0 deletions vuecket-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<artifactId>vuecket</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.orienteer.vuecket</groupId>
<artifactId>vuecket-extensions</artifactId>
<version>${project.version}</version>
</dependency>
<!-- LOGGING DEPENDENCIES - SLF4J-SIMPLE -->
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.PackageResourceReference;
import org.orienteer.vuecket.VueComponent;
import org.orienteer.vuecket.extensions.VueMarkdown;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.WebPage;

Expand Down
106 changes: 106 additions & 0 deletions vuecket-extensions/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>vuecket-parent</artifactId>
<groupId>org.orienteer.vuecket</groupId>
<version>1.0-SNAPSHOT</version>
</parent>

<artifactId>vuecket-extensions</artifactId>

<name>vuecket-extensions</name>

<dependencies>
<dependency>
<groupId>org.orienteer.vuecket</groupId>
<artifactId>vuecket</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty9.version}</version>
<configuration>
<systemProperties>
<systemProperty>
<name>maven.project.build.directory.test-classes</name>
<value>${project.build.directory}/test-classes</value>
</systemProperty>
</systemProperties>
<useProvidedScope>true</useProvidedScope>
<useTestScope>true</useTestScope>
<supportedPackagings>
<supportedPackaging>jar</supportedPackaging>
</supportedPackagings>
<jettyXml>${project.basedir}/../vuecket-demo/src/test/jetty/jetty.xml,${project.basedir}/../vuecket-demo/src/test/jetty/jetty-http.xml</jettyXml>
<webApp>
<descriptor>${project.basedir}/src/test/jetty/web.xml</descriptor>
<contextPath>/</contextPath>
<resourceBase>src/test/resources</resourceBase>
<containerIncludeJarPattern>^$</containerIncludeJarPattern>
<webInfIncludeJarPattern>^$</webInfIncludeJarPattern>
</webApp>
</configuration>
</plugin>
</plugins>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<reporting>
<plugins>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
package org.orienteer.vuecket.extensions;

import java.util.Date;
import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.markup.head.CssHeaderItem;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.JavaScriptHeaderItem;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.io.IClusterable;
import org.orienteer.vuecket.VueComponent;
import org.orienteer.vuecket.VueSettings;
import org.orienteer.vuecket.VueSettings.INPMPackageProvider;
import org.orienteer.vuecket.descriptor.VueNpm;
import org.orienteer.vuecket.method.IVuecketMethod.Context;
import org.orienteer.vuecket.method.JsFunction;

import com.fasterxml.jackson.annotation.JsonInclude;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import org.orienteer.vuecket.method.VueMethod;
import org.orienteer.vuecket.util.VuecketUtils;

/**
* Vuecket component for FullCalendar js library
* https://fullcalendar.io/docs/vue
*/
@VueNpm(packageName = "@fullcalendar/vue", path = "dist/main.global.js", enablement = "")
@Slf4j
public class FullCalendar extends VueComponent<FullCalendar.Options> {

/**
* Class for passing infor about events requests
*/
@Data
public static class EventsRequestInfo implements IClusterable {
private Date start;
private Date end;
private String startStr;
private String endStr;
private String timeZone;
}

/**
* Container for events data
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class Event implements IClusterable {
private String id;
private String groupId;
private Boolean allDay;
private Date start;
private Date end;
private String title;
private String url;
}

/**
* Options for FullCalendar
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public static class Options implements IClusterable {
private Object events;
private Object headerToolbar = VuecketUtils.toJsonNode("{ center: 'dayGridMonth,timeGridWeek' }");

public Options(Object events) {
this.events = events;
}

public Options(FullCalendar calendar) {
this(JsFunction.call(calendar, "lookupEvents"));
}
}

public FullCalendar(String id) {
super(id);
setDefaultModel(Model.of(new Options(this)));
}

public FullCalendar(String id, IModel<Options> optionsModel) {
super(id, optionsModel);
}

@Override
protected void onInitialize() {
super.onInitialize();
dataFiberBuilder("options").bindToProperty().init().build();
}

@Override
public void renderHead(IHeaderResponse response) {
INPMPackageProvider provider = VueSettings.get().getNpmPackageProvider();
response.render(CssHeaderItem.forReference(provider.provide("fullcalendar", "main.css")));
response.render(JavaScriptHeaderItem.forReference(provider.provide("fullcalendar", "main.min.js"), "fullcalendar"));
super.renderHead(response);
}

@VueMethod("lookupEvents")
public final List<Event> lookupEvents(Context ctx, EventsRequestInfo eventsRequestInfo) {
return lookupEvents(eventsRequestInfo.getStart(), eventsRequestInfo.getEnd());
}

public List<Event> lookupEvents(Date start, Date end) {
return new ArrayList<FullCalendar.Event>();
}
}
Loading

0 comments on commit fa9d975

Please sign in to comment.