Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Jessica Hawkwell
/
lang-toolkit
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0a1d1014
authored
Jul 09, 2017
by
Jessica Hawkwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added Velocity support
1 parent
ba317d60
Pipeline
#189
passed
in 3 minutes 5 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
140 additions
and
24 deletions
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/ui/WelcomeWindow.java
apps/langbuilder/src/main/resources/VELOCITY/me/felinewith/lang_toolkit/apps/langbuilder/ui/WelcomeWindow.vm
library/liblangbuilder/pom.xml
library/liblangbuilder/src/main/java/me/felinewith/lang_toolkit/library/velocity/VelocityHelper.java
library/liblangbuilder/src/main/resources/VELOCITY/page.vm
pom.xml
apps/langbuilder/src/main/java/me/felinewith/lang_toolkit/apps/langbuilder/ui/WelcomeWindow.java
View file @
0a1d101
package
me
.
felinewith
.
lang_toolkit
.
apps
.
langbuilder
.
ui
;
import
java.awt.BorderLayout
;
import
java.util.HashMap
;
import
javax.swing.JEditorPane
;
import
javax.swing.JPanel
;
import
me.felinewith.lang_toolkit.library.IStrappedPlugin
;
import
me.felinewith.lang_toolkit.library.velocity.VelocityHelper
;
/**
*
...
...
@@ -23,6 +25,11 @@ public class WelcomeWindow extends IStrappedPlugin {
jInternalFrame.add(jScrollPane); // */
viewer
.
setContentType
(
"text/html; charset=UTF-8"
);
viewer
.
setEditable
(
false
);
VelocityHelper
vh
=
VelocityHelper
.
getInstance
();
HashMap
<
String
,
Object
>
hm
=
new
HashMap
<>();
hm
.
put
(
"page.title"
,
"Welcome!"
);
viewer
.
setText
(
vh
.
generate
(
null
,
hm
));
}
@Override
public
String
getName
()
{
return
"WelconeWindow"
;
}
...
...
apps/langbuilder/src/main/resources/VELOCITY/me/felinewith/lang_toolkit/apps/langbuilder/ui/WelcomeWindow.vm
0 → 100644
View file @
0a1d101
Welcome to <b>LangBuilder</b>!
library/liblangbuilder/pom.xml
View file @
0a1d101
...
...
@@ -30,6 +30,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<artifactId>
log4j-core
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity
</artifactId>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity-tools
</artifactId>
</dependency>
<dependency>
<groupId>
org.freedesktop.tango
</groupId>
<artifactId>
tango-icon-theme
</artifactId>
</dependency>
...
...
library/liblangbuilder/src/main/java/me/felinewith/lang_toolkit/library/velocity/VelocityHelper.java
0 → 100644
View file @
0a1d101
package
me
.
felinewith
.
lang_toolkit
.
library
.
velocity
;
import
java.io.StringWriter
;
import
java.io.Writer
;
import
java.util.HashMap
;
import
java.util.Properties
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.apache.velocity.Template
;
import
org.apache.velocity.VelocityContext
;
import
org.apache.velocity.app.VelocityEngine
;
import
org.apache.velocity.runtime.RuntimeConstants
;
import
org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
;
/**
*
* @author jlhawkwell
*/
public
class
VelocityHelper
{
private
static
VelocityHelper
helperrrrrr
;
private
Logger
log
;
private
VelocityEngine
speeder
;
private
VelocityHelper
()
{
log
=
LogManager
.
getLogger
();
speeder
=
new
VelocityEngine
();
speeder
.
setProperty
(
RuntimeConstants
.
RESOURCE_LOADER
,
"classpath"
);
speeder
.
setProperty
(
"classpath.resource.loader.class"
,
ClasspathResourceLoader
.
class
.
getName
());
speeder
.
setProperty
(
RuntimeConstants
.
INPUT_ENCODING
,
"UTF-8"
);
speeder
.
setProperty
(
RuntimeConstants
.
OUTPUT_ENCODING
,
"UTF-8"
);
speeder
.
init
();
}
public
static
VelocityHelper
getInstance
()
{
if
(
helperrrrrr
==
null
)
{
helperrrrrr
=
new
VelocityHelper
();
}
return
helperrrrrr
;
}
public
static
VelocityHelper
newInstance
()
{
return
getInstance
();
}
public
String
generate
(
String
template
,
Properties
content
)
{
String
pt
=
tplFix
(
template
);
VelocityContext
vc
=
new
VelocityContext
();
content
.
entrySet
().
iterator
().
forEachRemaining
((
t
)
->
{
vc
.
put
(
t
.
getKey
().
toString
().
replaceAll
(
"\\."
,
"_"
),
t
.
getValue
());
});
return
generate
(
pt
,
vc
);
}
public
String
generate
(
String
template
,
HashMap
<
String
,
Object
>
content
)
{
String
pt
=
tplFix
(
template
);
VelocityContext
vc
=
new
VelocityContext
();
content
.
entrySet
().
iterator
().
forEachRemaining
((
t
)
->
{
vc
.
put
(
t
.
getKey
().
replaceAll
(
"\\."
,
"_"
),
t
.
getValue
());
});
return
generate
(
pt
,
vc
);
}
private
String
generate
(
String
template
,
VelocityContext
context
)
{
StringWriter
sw
=
new
StringWriter
();
context
.
put
(
"main_template"
,
template
);
generate
(
"/VELOCITY/page.vm"
,
context
,
sw
);
return
sw
.
toString
();
}
private
void
generate
(
String
template
,
VelocityContext
context
,
Writer
writer
)
{
Template
tpl
=
speeder
.
getTemplate
(
template
);
tpl
.
merge
(
context
,
writer
);
}
private
String
tplFix
(
String
input
)
{
StringBuilder
sb
;
String
pt
;
if
(
input
==
null
)
{
sb
=
new
StringBuilder
();
sb
.
append
(
new
Exception
().
getStackTrace
()[
2
].
getClassName
());
pt
=
sb
.
toString
().
replaceAll
(
"\\."
,
"/"
);
}
else
{
pt
=
input
;
}
sb
=
new
StringBuilder
();
if
(
!
pt
.
startsWith
(
"/VELOCITY/"
)
)
{
sb
.
append
(
"/VELOCITY/"
);
}
sb
.
append
(
pt
);
if
(
!
pt
.
endsWith
(
".vm"
)
)
{
sb
.
append
(
".vm"
);
}
return
sb
.
toString
();
}
}
library/liblangbuilder/src/main/resources/VELOCITY/page.vm
0 → 100644
View file @
0a1d101
<html>
<head>
<title>
${page_title}
</title>
</head>
<body>
<h2>
${page_title}
</h2>
<hr>
#include(${main_template})
</body>
</html>
pom.xml
View file @
0a1d101
...
...
@@ -33,7 +33,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<license>
<distribution>
repo
</distribution>
<name>
Apache License 2.0
</name>
<url>
LICENSE
</url>
<url>
https://felinewith.me/LadySerenaKitty/lang-toolkit/raw/master/
LICENSE
</url>
</license>
</licenses>
...
...
@@ -53,6 +53,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<name>
${project.name}
</name>
<url>
${gl.pages}
</url>
</site>
<downloadUrl>
https://mvn.felinewith.me/#artifact-details-download-content/${project.groupId}/${project.artifactId}
</downloadUrl>
</distributionManagement>
<issueManagement>
...
...
@@ -80,6 +81,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<module>
apps/langbuilder
</module>
</modules>
<organization>
<name>
StarPhoenix Media
</name>
<url>
https://starphoenixmedia.com/
</url>
</organization>
<developers>
<developer>
<id>
jlhawkwell
</id>
...
...
@@ -93,28 +99,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<repositories>
<repository>
<id>
releases
</id>
<name>
SPM Releases
</name>
<url>
https://mvn.felinewith.me/repository/releases
</url>
<releases>
<enabled>
true
</enabled>
</releases>
<snapshots>
<enabled>
false
</enabled>
</snapshots>
</repository>
<repository>
<id>
snapshots
</id>
<name>
SPM Snapshots
</name>
<url>
https://mvn.felinewith.me/repository/snapshots
</url>
<releases>
<enabled>
false
</enabled>
</releases>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
<!-- repository>
<id>
external
</id>
<name>
SPM Externals
</name>
<url>
https://mvn.felinewith.me/repository/external
</url>
...
...
@@ -124,7 +108,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository
--
>
</repository>
</repositories>
<dependencyManagement>
...
...
@@ -156,6 +140,11 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<version>
1.7
</version>
</dependency>
<dependency>
<groupId>
org.apache.velocity
</groupId>
<artifactId>
velocity-tools
</artifactId>
<version>
2.0
</version>
</dependency>
<dependency>
<groupId>
org.freedesktop.tango
</groupId>
<artifactId>
tango-icon-theme
</artifactId>
<version>
0.8.90
</version>
...
...
@@ -350,6 +339,9 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/ma
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-project-info-reports-plugin
</artifactId>
<version>
2.9
</version>
<configuration>
<version>
1.0-SNAPSHOT
</version>
</configuration>
</plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment