diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..6d6f5c3
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..ea8c4bf
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+/target
diff --git a/.project b/.project
new file mode 100644
index 0000000..d540f9f
--- /dev/null
+++ b/.project
@@ -0,0 +1,23 @@
+
+
+ bs3-eclipse-snippets
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+ org.eclipse.m2e.core.maven2Nature
+
+
diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..4ede96d
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/eclipse-snippets/snippets-skeleton.xml b/eclipse-snippets/snippets-skeleton.xml
new file mode 100644
index 0000000..dc01d15
--- /dev/null
+++ b/eclipse-snippets/snippets-skeleton.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/output-snippets.xml b/output-snippets.xml
new file mode 100644
index 0000000..ea97059
--- /dev/null
+++ b/output-snippets.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+ × ${name_1} ${name_2} ]]> × ${name_1} ${name_2} ]]> × ${name_1} ${name_2} ]]> × ${name_1} ${name_2} ]]> × ${name_1} ${name_2} ]]> ${name_1}]]> ${name_2} ${name_3} ${name_4} ]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_4}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_4}${name_1}>]]> <${name_1} ${name_2} class="btn btn-default">Top${name_1}> <${name_1} ${name_2} class="btn btn-default">Middle${name_1}> <${name_1} ${name_2} class="btn btn-default">Bottom${name_1}> ]]> <${name_1} ${name_2} class="btn btn-default">Left${name_1}> <${name_1} ${name_2} class="btn btn-default">Middle${name_1}> <${name_1} ${name_2} class="btn btn-default">Right${name_1}> ]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]>
]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_4}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_4}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_4}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> ${name_3}${name_1}>]]> Example headline. Note: If you're viewing this page via a file://
URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.
Sign up today
Another example headline. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
Learn more
One more for good measure. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.
Browse gallery
]]> ]]> ${name_1} ]]> ${name_1} ]]> ]]> ${name_2}
${0} ]]> ${name_2} ${0} ${name_3} ]]> ${3}]]> ${name_2} ${name_3}
${0} ${name_4} ]]> ${name_1} ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ]]> ${3}]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${name_2} ]]> ${1/(\w+)/\u\1/g}:
]]> ]]>
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}: ${name_3}
]]> ${name_1} ]]> ${name_2}
]]> ${name_1}]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}:
]]> ]]> ${1/(\w+)/\u\1/g}: ${0}
]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ${0} ]]> ]]> ]]> ]]> ]]> ]]> ]]> ]]> ${name_1}]]> ${name_1}]]> ${name_1}]]> ${name_1}]]> ${name_1}]]> ${name_1}]]> 5 Item 1 10 Item 2 15 Item 3 ]]> ${name_1} ${name_2}
]]> Item 1 Item 2 Item 3 ]]> Item 1 Item 2 Item 3 ]]> ]]> Trigger modal} ]]> ${name_1} ]]> ${name_2}]]> ${name_2} ]]> ${name_2} ]]> ${name_3} ]]> ${name_1} ]]> ${name_3}
]]> ${name_2} ${name_4} ]]> ]]> ${name_2} ]]> ${name_1}]]> ]]> ${name_1}${name_2} ]]> ← Older Newer → ]]> Previous Next ]]> « 1 2 3 4 5 » ]]> « 1 2 3 4 5 » ]]> « 1 2 3 4 5 » ]]>
Panel title ${name_2}
]]> ${name_1}
]]>
Panel title ${name_2}
]]>
Panel title ${name_2}
]]>
Panel title ${name_2}
]]>
Panel title ${name_2}
]]> Panel heading
${name_2} ${name_3} ${name_4} ${name_5}
]]>
Panel title ${name_2}
]]> ${name_2}
]]> ]]> ]]> ]]> ]]> ]]> ]]> ${name_1} ${name_3} ]]>
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..d7cc732
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,18 @@
+
+ 4.0.0
+ bs3-eclipse-snippets
+ bs3-eclipse-snippets
+ 0.0.1-SNAPSHOT
+
+
+ dom4j
+ dom4j
+ 1.6.1
+
+
+ jaxen
+ jaxen
+ 1.1.4
+
+
+
\ No newline at end of file
diff --git a/src/com/azudio/bootstrap3snippetgenerator/Bootstrap3SnippetGenerator.java b/src/com/azudio/bootstrap3snippetgenerator/Bootstrap3SnippetGenerator.java
new file mode 100644
index 0000000..a4b7de3
--- /dev/null
+++ b/src/com/azudio/bootstrap3snippetgenerator/Bootstrap3SnippetGenerator.java
@@ -0,0 +1,215 @@
+package com.azudio.bootstrap3snippetgenerator;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
+import org.dom4j.io.DocumentResult;
+import org.dom4j.io.DocumentSource;
+import org.dom4j.io.OutputFormat;
+import org.dom4j.io.SAXReader;
+import org.dom4j.io.XMLWriter;
+
+public class Bootstrap3SnippetGenerator {
+
+ private Document d, s;
+ private String categoryId;
+ private Long categoryNumber;
+ private Long itemNumber;
+ private Integer variableNameNumber;
+
+ public static void main(String[] args) throws DocumentException, IOException {
+ Bootstrap3SnippetGenerator g = new Bootstrap3SnippetGenerator();
+
+ g.start();
+ }
+
+ private void start() throws DocumentException, IOException {
+
+ init();
+ findFiles();
+
+ System.out.println(d.asXML());
+
+ write(d);
+
+ }
+
+ Element cat;
+
+ private void init() throws MalformedURLException, DocumentException {
+ d = parse(new URL("file:eclipse-snippets/snippets-skeleton.xml"));
+
+ cat = (Element) d.selectSingleNode("//category");
+
+ setCategoryId(cat.attribute("id").getValue());
+
+ categoryNumber = Long.parseLong(getCategoryId().substring(getCategoryId().indexOf("_") + 1, getCategoryId().length()));
+ setItemNumber(categoryNumber);
+
+ }
+
+ private void findFiles() throws DocumentException {
+ String rootPath = ".";
+ File[] domains = new File(rootPath).listFiles();
+ for (File domain : domains) {
+ if (domain.isDirectory()) {
+ File[] files = new File(domain.getAbsolutePath()).listFiles();
+ for (File file : files) {
+ if (file.isFile() && file.getAbsolutePath().endsWith(".sublime-snippet")) {
+ System.out.println(file.getAbsolutePath());
+ try {
+ String simple = file.getName().replaceAll("\\..*", "");
+ System.out.println(simple);
+ System.out.println(file.toURI().toURL().toString());
+
+ s = parse(file.toURI().toURL());
+
+ Element content = (Element) s.selectSingleNode("//content");
+
+ cat.add(createItem(simple, simple + " Description", content.getTextTrim()));
+
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private Element createItem(String label, String description, String content) {
+ Element e = DocumentHelper.createElement("item");
+ e.addAttribute("category", getCategoryId());
+ e.addAttribute("id", "item_" + ++itemNumber);
+ e.addAttribute("label", label);
+
+ e.addElement("description").addCDATA(description);
+
+ for (Variable v : parseVariables(content)) {
+ Element variableElement = e.addElement("variable");
+ variableElement.addAttribute("default", v.getDefaultValue());
+ variableElement.addAttribute("id", v.getName());
+ variableElement.addAttribute("name", v.getName());
+ variableElement.addElement("description").addCDATA(v.getDescription());
+ }
+
+ e.addElement("content").addCDATA(swapVariableNames(content));
+
+ System.out.println(e.asXML());
+
+ return e;
+ }
+
+ private String swapVariableNames(String content) {
+ Pattern p = Pattern.compile("(\\$\\{(\\d):(.*?)\\})");
+ Matcher m = p.matcher(content);
+
+ variableNameNumber = 1;
+
+ while (m.find()) {
+ content = content.replace(m.group(0), "${name_" + variableNameNumber + "}");
+ variableNameNumber++;
+ }
+
+ System.out.println(content);
+
+ return content;
+ }
+
+ private List parseVariables(String content) {
+ List l = new ArrayList();
+
+ Pattern p = Pattern.compile("(\\$\\{(\\d):(.*?)\\})");
+ Matcher m = p.matcher(content);
+
+ variableNameNumber = 1;
+
+ while (m.find()) {
+ // System.out.println("0" + m.group(0));
+ // System.out.println("1" + m.group(1));
+ System.out.println("Var Num: " + variableNameNumber);
+ System.out.println("Param No: " + m.group(2));
+ System.out.println("Default Value: " + m.group(3));
+ l.add(new Variable("name_" + variableNameNumber, "", m.group(3)));
+
+ variableNameNumber++;
+ }
+
+ System.out.println(content);
+
+ return l;
+ }
+
+ private Document parse(URL url) throws DocumentException {
+ SAXReader reader = new SAXReader();
+ Document document = reader.read(url);
+
+ return document;
+ }
+
+ private Document styleDocument(Document document, String stylesheet) throws Exception {
+
+ // load the transformer using JAXP
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(new StreamSource(stylesheet));
+
+ // now lets style the given document
+ DocumentSource source = new DocumentSource(document);
+ DocumentResult result = new DocumentResult();
+ transformer.transform(source, result);
+
+ // return the transformed document
+ Document transformedDoc = result.getDocument();
+ return transformedDoc;
+ }
+
+ public String getCategoryId() {
+ return categoryId;
+ }
+
+ public void setCategoryId(String categoryId) {
+ this.categoryId = categoryId;
+ }
+
+ public Long getItemNumber() {
+ return itemNumber;
+ }
+
+ public void setItemNumber(Long itemNumber) {
+ this.itemNumber = itemNumber;
+ }
+
+ public void write(Document document) throws IOException {
+
+ // lets write to a file
+ XMLWriter writer = new XMLWriter(new FileWriter("output-snippets.xml"));
+ writer.write(document);
+ writer.close();
+
+ // Pretty print the document to System.out
+ OutputFormat format = OutputFormat.createPrettyPrint();
+ writer = new XMLWriter(System.out, format);
+ writer.write(document);
+
+ // Compact format to System.out
+ format = OutputFormat.createCompactFormat();
+ writer = new XMLWriter(System.out, format);
+ writer.write(document);
+ }
+}
diff --git a/src/com/azudio/bootstrap3snippetgenerator/Variable.java b/src/com/azudio/bootstrap3snippetgenerator/Variable.java
new file mode 100644
index 0000000..4ae1768
--- /dev/null
+++ b/src/com/azudio/bootstrap3snippetgenerator/Variable.java
@@ -0,0 +1,81 @@
+package com.azudio.bootstrap3snippetgenerator;
+
+public class Variable {
+
+ private String defaultValue;
+ private String name;
+ private String description;
+
+ /**
+ * @param name
+ */
+ public Variable(String name) {
+ this(name, "");
+ }
+
+ /**
+ * @param defaultValue
+ * @param name
+ * @param description
+ */
+ public Variable(String name, String description) {
+ this(name, description, null);
+ }
+
+ /**
+ * @param defaultValue
+ * @param name
+ * @param description
+ */
+ public Variable(String name, String description, String defaultValue) {
+ this.name = name;
+ this.description = description;
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * @return the defaultValue
+ */
+ public String getDefaultValue() {
+ return defaultValue;
+ }
+
+ /**
+ * @param defaultValue
+ * the defaultValue to set
+ */
+ public void setDefaultValue(String defaultValue) {
+ this.defaultValue = defaultValue;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the description
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description
+ * the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+}
diff --git a/src/com/azudio/bootstrap3snippetgenerator/package-info.java b/src/com/azudio/bootstrap3snippetgenerator/package-info.java
new file mode 100644
index 0000000..049f51d
--- /dev/null
+++ b/src/com/azudio/bootstrap3snippetgenerator/package-info.java
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+/**
+ * @author adamhenderson
+ *
+ */
+package com.azudio.bootstrap3snippetgenerator;
\ No newline at end of file