Commit 1f3cff00 authored by Ate Douma's avatar Ate Douma

TRIVIAL cleanup master

parent bc39c82a
/.idea/
*.iml
target/
demo/storage
This diff is collapsed.
Hippo Plugin Poll
Copyright 2009-2018 Hippo B.V. (http://www.onehippo.com)
This product includes software developed by:
Hippo B.V., Amsterdam, The Netherlands (http://www.onehippo.com/);
The Apache Software Foundation (http://www.apache.org/).
NOTICE: Only our own original work is licensed under the terms of the
Apache License Version 2.0. The licenses of some libraries might impose
different redistribution or general licensing terms than those stated in the
Apache License. Users and redistributors are hereby requested to verify these
conditions and agree upon them.
# Poll Plugin
# This is not the branch you're looking for...
This is the Poll plugin for Hippo CMS. Documentation on how to use this
plugin in your Hippo project can be found at:
BloomReach only provides the git trees for the release tags of Hippo CMS, as explained on https://www.onehippo.org/about/open-source-release-policy.html
http://www.onehippo.org/library/concepts/plugins/poll/about.html
To checkout the code for a specific release tag, after cloning this repository, use the following:
## Plugin Demo
## to show the available tags
A demo project is provided to see the plugin in action.
git tag
### Requirements
## to checkout a specific tag
* Java 8 JDK
* Maven 3
git checkout <tag name>
### Download, Build and Run the Demo Project
## to modify a project
If you want to make modifications to a project, for example to create a patch, create a new fork branch from the specific tag like this:
1. Download the plugin's source code from https://code.onehippo.org/cms-community/hippo-plugin-poll
* Alternatively you can clone the git repository on your local machine.
* Use the latest stable branch named "release/x" (or "demo/x" in case the
demo is tagged seperately) where "x" is the version number.
* If you want to build the master branch demo you must configure the Hippo
Maven snapshot repository. See
http://www.onehippo.org/library/development/build-hippo-cms-from-scratch.html
for instructions.
2. Extract the archive on your local file system.
3. Use Maven to build and run the demo project:
```bash
cd hippo-plugin-poll/demo
mvn verify
mvn -P cargo.run
```
4. Hippo CMS will be available at http://localhost:8080/cms/ (login using
credentials `admin`/`admin`).
The demo website will be available at http://localhost:8080/site/.
### Development Branches
To build and run the demo from a development branch you may need to configure
access to the Hippo Maven snapshots repository. For more information see the
following documentation page:
http://www.onehippo.org/library/development/build-hippo-cms-from-scratch.html
git checkout -b forked-<tag name> <tag name>
For the latter, also see the **Build from Source** documentation at https://www.onehippo.org/library/development/build-hippo-cms-from-scratch.html
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2015 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-plugin-poll</artifactId>
<version>4.3.0-SNAPSHOT</version>
</parent>
<artifactId>hippo-plugin-poll-addon-cms</artifactId>
<name>Hippo Plugin Poll CMS</name>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-api</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-cms-editor-frontend</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>${basedir}/src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.html</include>
<include>**/*.css</include>
<include>**/*.png</include>
<include>**/*.gif</include>
</includes>
</resource>
</resources>
</build>
</project>
/*
* Copyright 2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
package org.onehippo.forge.poll.cms;
import java.io.Serializable;
/**
* Used to save and retrieve poll results (value and number of votes)
*/
public class PollResult implements Serializable {
private static final long serialVersionUID = 1L;
private long count;
private String value;
public PollResult(String value, long count) {
this.value = value;
this.count = count;
}
public String getValue() {
return value;
}
public long getCount() {
return count;
}
public String getCountAsString() {
if (count == -1) {
return "";
} else {
return String.valueOf(getCount());
}
}
}
/*
* Copyright 2015 Hippo B.V. (http://www.onehippo.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.
*/
.poll-options td {
width: 50%;
}
.resulttable th {
font-weight: bold;
border-bottom: 1px solid #d4d6d8;
padding-bottom: 4px;
}
.resulttable th:first-child,
.resulttable td:first-child {
padding-right: 16px;
}
.resulttable td {
padding-top: 4px;
}
.resulttable .count {
text-align: right;
}
.hippo-poll-results.hippo-editor-compound-field .hippo-editor-field {
background-color: white;
}
.hippo-poll-results .hippo-editor-field-textarea {
border: 0;
padding: 0;
}
<!--
Copyright 2015 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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.
-->
<html xmlns:wicket="http://wicket.apache.org/">
<wicket:panel>
<div wicket:id="poll-results-panel"></div>
</wicket:panel>
<wicket:fragment wicket:id="poll-results">
<div class="hippo-editor-compound-field hippo-poll-results">
<div class="hippo-editor-field">
<h3 class="hippo-editor-field-title">
<span wicket:id="name-label">[name]</span>
</h3>
<div class="hippo-editor-field-subfield even">
<div class="hippo-editor-field-subfield-item">
<div class="hippo-editor-field-textarea">
<table class="resulttable">
<tr>
<th wicket:id="optionsvalue-label"></th>
<th class="count" wicket:id="count-label"></th>
</tr>
<tr wicket:id="row">
<td wicket:id="option">[Option]</td>
<td class="count" wicket:id="count">[199]</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</wicket:fragment>
</html>
count-label=Count
name-label=Poll results
optionsvalue-label=Option value
<?xml version="1.0"?>
<!--
Copyright 2009-2015 Hippo B.V. (http://www.onehippo.com)
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS"
BASIS, 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-plugin-poll</artifactId>
<version>4.3.0-SNAPSHOT</version>
</parent>
<artifactId>hippo-plugin-poll-addon-repository</artifactId>
<name>Hippo Plugin Poll Repository</name>
<dependencies>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-api</artifactId>
</dependency>
<dependency>
<groupId>org.onehippo.cms7</groupId>
<artifactId>hippo-repository-utilities</artifactId>
</dependency>
</dependencies>
</project>
definitions:
config:
/hippo:configuration/hippo:translations/hippo:hst/componentparameters/org/onehippo/forge:
jcr:primaryType: hipposys:resourcebundles
/poll:
jcr:primaryType: hipposys:resourcebundles
/component:
jcr:primaryType: hipposys:resourcebundles
/PollDocumentComponentInfo:
jcr:primaryType: hipposys:resourcebundles
/en:
jcr:primaryType: hipposys:resourcebundle
poll-docsPath: Poll document
/PollComponentInfo:
jcr:primaryType: hipposys:resourcebundles
/en:
jcr:primaryType: hipposys:resourcebundle
poll-dataPath: Path to store poll data
poll-docsClass: Poll documents class
poll-docsPath: Path to poll documents relative to site content root
poll-pollCompoundName: Name of poll compound
definitions:
config:
/hippo:configuration/hippo:domains/polldata:
jcr:primaryType: hipposys:domain
/readwrite:
jcr:primaryType: hipposys:authrole
hipposys:groups: [sitewriters]
hipposys:role: readwrite
/readonly:
jcr:primaryType: hipposys:authrole
hipposys:groups: [liveusers, previewusers]
hipposys:role: readonly
/poll-polldata:
jcr:primaryType: hipposys:domainrule
/poll-polldata-node:
jcr:primaryType: hipposys:facetrule
hipposys:equals: true
hipposys:facet: jcr:primaryType
hipposys:filter: false
hipposys:type: Name
hipposys:value: poll:polldata
/poll-vote:
jcr:primaryType: hipposys:domainrule
/poll-vote-node:
jcr:primaryType: hipposys:facetrule
hipposys:equals: true
hipposys:facet: jcr:primaryType
hipposys:filter: false
hipposys:type: Name
hipposys:value: poll:votes
definitions:
config:
/hippo:configuration/hippo:frontend/cms/cms-folder-views/hipposysedit:namespacefolder/root/filters:
/hidePollNamespace:
.meta:order-before: showOtherNamespaces
jcr:primaryType: frontend:pluginconfig
display: false
path: /hippo:namespaces/poll
/hippo:configuration/hippo:frontend/cms/cms-tree-views/configuration/configurationBrowser/filters:
/hidePollNamespace:
.meta:order-before: showOtherNamespaces
jcr:primaryType: frontend:pluginconfig
display: false
path: /hippo:namespaces/poll
definitions:
namespace:
poll:
uri: http://forge.onehippo.org/poll/nt/1.2
cnd: poll.cnd
definitions:
config:
/hst:hst/hst:configurations/hst:default/hst:catalog/poll-catalog:
jcr:primaryType: hst:containeritempackage
/poll:
jcr:primaryType: hst:containeritemcomponent
hst:componentclassname: org.onehippo.forge.poll.component.PollDocumentComponent
hst:iconpath: resources/poll/catalog-poll.png
hst:label: Poll
hst:parameternames: [poll-pollCompoundName, poll-docsPath, poll-dataPath,
poll-docsClass]
hst:parametervalues: ['poll:poll', /, polldata, org.onehippo.forge.poll.contentbean.PollDocument]
hst:template: poll.component.ftl
hst:xtype: HST.Item
definitions:
config:
/hippo:namespaces/poll:
jcr:primaryType: hipposysedit:namespace
jcr:mixinTypes: ['mix:referenceable']
definitions:
config:
/polldata:
.meta:residual-child-node-category: system
jcr:primaryType: poll:polldata
jcr:mixinTypes: ['hippo:lockable', 'mix:lockable']
hippo:lockExpirationTime:
.meta:category: system
jcr:lockOwner:
.meta:category: system
jcr:lockIsDeep:
.meta:category: system
definitions:
config:
/hst:hst/hst:configurations/hst:default/hst:templates/poll.component.ftl:
jcr:primaryType: hst:template
jcr:uuid: 8e1312b5-5756-4aba-aab3-54733e46741a
hst:script: "<#assign hst=JspTaglibs[\"http://www.hippoecm.org/jsp/hst/core\"\
]>\n\n<div id=\"poll\">\n <#if pollDocument??>\n <#if pollDocument.poll.text??>\n\
\ <h3>${pollDocument.poll.text}</h3>\n </#if>\n <span id=\"noCookieSupportMessage\"\
>The poll cannot be shown because the browser does not support cookies</span>\n\
\n <#-- Render Poll Form if not yet voted (voteSuccess not defined) or\
\ voting failed (voteSuccess is false) -->\n <#if !(voteSuccess??) || voteSuccess\
\ == false>\n <div id=\"pollDiv\">\n <#if pollDocument.poll.introduction??>\n\
\ <p id=\"\">${pollDocument.poll.introduction}</p>\n </#if>\n\
\n <!-- The Poll -->\n <form id=\"form-poll\" method=\"post\"\
\ action=\"<@hst.actionURL />\">\n <input type=\"hidden\" name=\"\
path\" value=\"${path}\"/>\n <div>\n <#list pollDocument.poll.options\
\ as curOption>\n <div>\n <input id=\"${curOption.value}\"\
\ name=\"option\" type=\"radio\" value=\"${curOption.value}\"\n \
\ <#if option?? && curOption == option>selected=\"true\"</#if>\
\ />\n <label for=\"${curOption.value}\">${curOption.label}</label>\n\
\ </div>\n </#list>\n </div>\n <button\
\ class=\"submit\" type=\"submit\">Vote</button>\n <#if voteSuccess??>\
\ <#-- Implies voteSuccess == \"false\" -->\n <div>Sorry, processing\
\ the vote has failed</div>\n </#if>\n </form>\n </div>\n\
\ </#if>\n\n <ul id=\"pollResults\" class=\"poll-results-list\">\n \
\ <#list pollVotes.options as curOption>\n <li>\n <div\
\ class=\"poll-graph-bar\">\n <span class=\"poll-meter\" style=\"\
width: ${curOption.votesPercentage}%\"> </span>\n </div>\n \
\ <#if curOption.votesCount == 1>\n ${curOption.label} - ${curOption.votesPercentage}%\
\ (${curOption.votesCount} vote)\n <#else>\n ${curOption.label}\
\ - ${curOption.votesPercentage}% (${curOption.votesCount} votes)\n \
\ </#if>\n </li>\n </#list>\n <#if pollVotes.totalVotesPercentage\
\ != 100>\n\t <li>\n\t \tDue to rounding the percentages don't add\
\ up to 100%\n\t </li>\n\t </#if>\n </ul>\n\n <script type=\"\
text/javascript\">\n if (<#if voteSuccess?? && voteSuccess == true>1<#else>0</#if>)\
\ {\n hide(\"noCookieSupportMessage\");\n } else if (checkBrowserSupportsCookies())\
\ {\n hide(\"noCookieSupportMessage\");\n hide(\"pollResults\"\
);\n } else {\n hide(\"pollDiv\");\n hide(\"pollResults\"\
);\n }\n\n function hide(id) {\n var element = document.getElementById(id);\n\
\ element.parentNode.removeChild(element);\n }\n\n function\
\ checkBrowserSupportsCookies() {\n var cookieDate=new Date();\n \
\ var cookieString=\"testCookieSupport\"+cookieDate.toUTCString();\n\
\ document.cookie=\"testCookieSupport=\"+cookieString;\n return\
\ document.cookie.length > 0;\n }\n </script>\n\n <#else>\n No\
\ poll available\n </#if>\n</div>"
<'poll'='http://forge.onehippo.org/poll/nt/1.2'>
<'hippo'='http://www.onehippo.org/jcr/hippo/nt/2.0'>
<'hippostd'='http://www.onehippo.org/jcr/hippostd/nt/2.0'>
<'hippostdpubwf'='http://www.onehippo.org/jcr/hippostdpubwf/nt/1.0'>
[poll:polldata] > hippostd:folder
[poll:votes]
- poll:count (long)
[poll:option]
- poll:value (string)
- poll:label (string)
[poll:poll] > hippo:compound
- poll:active (boolean)
- poll:text (string)
- poll:introduction (string)
+ poll:option (poll:option) multiple
[poll:polldocument] > hippo:document, hippostdpubwf:document, hippostd:publishableSummary
+ poll:poll (poll:poll)
definitions:
config:
/hippo:configuration/hippo:translations/hippo:types/poll:option:
jcr:primaryType: hipposys:resourcebundles
/en:
jcr:primaryType: hipposys:resourcebundle
jcr:name: Option
poll:label: Label
poll:value: Value
/hippo:configuration/hippo:translations/hippo:types/poll:poll:
jcr:primaryType: hipposys:resourcebundles
/en:
jcr:primaryType: hipposys:resourcebundle
jcr:name: Poll Compound
poll:introduction: Introduction (optional)
poll:options: Options
poll:text: Text
/hippo:configuration/hippo:translations/hippo:types/poll:polldocument:
jcr:primaryType: hipposys:resourcebundles
/en:
jcr:primaryType: hipposys:resourcebundle
jcr:name: Poll
poll:poll: Poll
definitions:
config:
/hippo:namespaces/poll/option:
jcr:primaryType: hipposysedit:templatetype
jcr:mixinTypes: ['mix:referenceable', 'editor:editable']
/hipposysedit:nodetype:
jcr:primaryType: hippo:handle
jcr:mixinTypes: ['mix:referenceable']
/hipposysedit:nodetype:
jcr:primaryType: hipposysedit:nodetype
jcr:mixinTypes: ['hipposysedit:remodel', 'mix:referenceable']
hipposysedit:node: true
hipposysedit:uri: http://forge.onehippo.org/poll/nt/1.2
/value:
jcr:primaryType: hipposysedit:field
hipposysedit:mandatory: false
hipposysedit:multiple: false
hipposysedit:ordered: false
hipposysedit:path: poll:value
hipposysedit:primary: false
hipposysedit:type: String
/label:
jcr:primaryType: hipposysedit:field
hipposysedit:mandatory: false
hipposysedit:multiple: false
hipposysedit:ordered: false
hipposysedit:path: poll:label
hipposysedit:primary: false
hipposysedit:type: String
/hipposysedit:prototypes:
jcr:primaryType: hipposysedit:prototypeset
/hipposysedit:prototype:
jcr:primaryType: poll:option
poll:label: ''
poll:value: ''
/editor:templates:
jcr:primaryType: editor:templateset
/_default_:
jcr:primaryType: frontend:plugincluster
frontend:properties: [mode]
frontend:references: [model.compareTo, wicket.model, engine]
frontend:services: [wicket.id]
type: poll:option
/root:
jcr:primaryType: frontend:plugin
item: ${cluster.id}.field
plugin.class: org.hippoecm.frontend.service.render.ListViewPlugin
wicket.id: ${wicket.id}
wicket.variant: row
/value:
jcr:primaryType: frontend:plugin
engine: ${engine}
field: value
mode: ${mode}
model.compareTo: ${model.compareTo}
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.css: poll-option-value
wicket.id: ${cluster.id}.field
wicket.model: ${wicket.model}
wicket.skin: skin/poll.css
/cluster.options:
jcr:primaryType: frontend:pluginconfig
/label:
jcr:primaryType: frontend:plugin
engine: ${engine}
field: label
mode: ${mode}
model.compareTo: ${model.compareTo}
plugin.class: org.hippoecm.frontend.editor.plugins.field.PropertyFieldPlugin
wicket.css: poll-option-label
wicket.id: ${cluster.id}.field
wicket.model: ${wicket.model}
wicket.skin: skin/poll.css
/cluster.options:
jcr:primaryType: frontend:pluginconfig
definitions:
config:
/hippo:namespaces/poll/poll:
jcr:primaryType: hipposysedit:templatetype
jcr:mixinTypes: ['mix:referenceable', 'editor:editable']
/hipposysedit:nodetype:
jcr:primaryType: hippo:handle
jcr:mixinTypes: ['mix:referenceable']
/hipposysedit:nodetype:
jcr:primaryType: hipposysedit:nodetype
jcr:mixinTypes: ['hipposysedit:remodel', 'mix:referenceable']
hipposysedit:node: true
hipposysedit:supertype: ['hippo:compound']
hipposysedit:uri: http://forge.onehippo.org/poll/nt/1.2
/text:
jcr:primaryType: hipposysedit:field
hipposysedit:mandatory: false
hipposysedit:multiple: false
hipposysedit:ordered: false
hipposysedit:path: poll:text
hipposysedit:primary: false
hipposysedit:type: String
/introduction:
jcr:primaryType: hipposysedit:field
hipposysedit:mandatory: false
hipposysedit:multiple: false
hipposysedit:ordered: false
hipposysedit:path: poll:introduction
hipposysedit:primary: false
hipposysedit:type: Text
/options:
jcr:primaryType: hipposysedit:field
hipposysedit:mandatory: false
hipposysedit:multiple: true
hipposysedit:ordered: false
hipposysedit:path: poll:option
hipposysedit:primary: false
hipposysedit:type: poll:option
/hipposysedit:prototypes:
jcr:primaryType: hipposysedit:prototypeset
/hipposysedit:prototype:
jcr:primaryType: poll:poll
poll:introduction: ''
poll:text: ''
/poll:option:
jcr:primaryType: poll:option
poll:label: ''
poll:value: ''
/editor:templates:
jcr:primaryType: editor:templateset
/_default_:
jcr:primaryType: frontend:plugincluster
frontend:properties: [mode]
frontend:references: [model.compareTo, wicket.model, engine]
frontend:services: [wicket.id]
type: poll:poll
/root:
jcr:primaryType: frontend:plugin
item: ${cluster.id}.field