-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from TheCoder4eu/master
Update
- Loading branch information
Showing
183 changed files
with
28,395 additions
and
23,721 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,5 @@ download.xhtml | |
nbactions.xml | ||
faces-config.NavData | ||
nb-configuration.xml | ||
.idea/ | ||
BootsFacesWeb.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#Fri Apr 28 16:18:17 CEST 2017 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4.1-bin.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class Admin { | ||
private String id; | ||
|
||
private List<AdminSkill> skills = Arrays.asList(new AdminSkill("sleep"), new AdminSkill("work"), new AdminSkill("drink coffee")); | ||
|
||
public Admin(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
public List<AdminSkill> getSkills() { | ||
return skills; | ||
} | ||
|
||
public void setSkills(List<AdminSkill> skills) { | ||
this.skills = skills; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.faces.bean.ManagedBean; | ||
import javax.faces.bean.ViewScoped; | ||
|
||
@ManagedBean | ||
@ViewScoped | ||
public class AdminController implements Serializable { | ||
private static final long serialVersionUID = 1L; | ||
|
||
private List<Admin> admins = new ArrayList<>(); | ||
|
||
private Admin selectedAdmin = null; | ||
|
||
public AdminController() { | ||
admins.add(new Admin("Hugo")); | ||
admins.add(new Admin("Erwin")); | ||
admins.add(new Admin("Helga")); | ||
} | ||
|
||
public List<Admin> getAdmins() { | ||
return admins; | ||
} | ||
|
||
public void setAdmins(List<Admin> admins) { | ||
this.admins = admins; | ||
} | ||
|
||
public void onSelect(Admin admin) { | ||
this.selectedAdmin = admin; | ||
} | ||
|
||
public List<AdminSkill> getAdminSkills() { | ||
if (null == selectedAdmin) { | ||
return new ArrayList<>(); | ||
} | ||
return selectedAdmin.getSkills(); | ||
} | ||
|
||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
public class AdminSkill { | ||
private String id; | ||
|
||
public AdminSkill(String id) { | ||
this.id = id; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public void setId(String id) { | ||
this.id = id; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
import java.io.BufferedReader; | ||
import java.io.BufferedWriter; | ||
import java.io.File; | ||
import java.io.FileReader; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class Collector { | ||
|
||
public static void main(String[] args) throws IOException { | ||
scanFolder(new File("src/main/webapp")); | ||
} | ||
|
||
public static void scanFolder(File folder) throws IOException { | ||
File[] files = folder.listFiles(); | ||
for (File file : files) { | ||
if (file.isDirectory()) { | ||
scanFolder(file); | ||
} else if (file.getName().endsWith(".xhtml")) { | ||
if (!file.getName().endsWith("Attributes.xhtml")) { | ||
String newFile = readFile(file.getAbsolutePath()); | ||
if (newFile != null) { | ||
writeFile(file.getAbsolutePath(), newFile); | ||
//System.exit(1); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
public static void writeFile(String filename, String content) throws IOException { | ||
new File(filename).delete(); | ||
try (FileWriter fw = new FileWriter(filename); BufferedWriter bw = new BufferedWriter(fw)) { | ||
bw.write(content); | ||
} | ||
} | ||
|
||
public static String readFile(String filename) { | ||
Map<String, String> chapters = new HashMap<>(); | ||
List<String> tags = new ArrayList<>(); | ||
StringBuilder result = new StringBuilder(); | ||
String previousLine = ""; | ||
|
||
try (FileReader fr = new FileReader(filename); BufferedReader br = new BufferedReader(fr)) { | ||
String line; | ||
|
||
while ((line = br.readLine()) != null) { | ||
if (line.contains("<ui:define name=\"content-navigator\">")) { | ||
return null; | ||
} | ||
while (line.contains("<h1") && (!line.contains("</h1>"))) { | ||
line = line.trim() + br.readLine().trim(); | ||
} | ||
line = examineLine(filename, chapters, tags, previousLine, line, "<h1>"); | ||
line = examineLine(filename, chapters, tags, previousLine, line, "<h2>"); | ||
line = examineLine(filename, chapters, tags, previousLine, line, "<h3>"); | ||
result.append(line); | ||
result.append('\n'); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
if (tags.size() > 1) { | ||
int pos = result.indexOf("<ui:define name=\"content\">"); | ||
if (pos < 0) { | ||
return null; | ||
} | ||
if (pos > 0) { | ||
pos = result.lastIndexOf("\n", pos); | ||
} | ||
String start = result.substring(0, pos); | ||
String end = result.substring(pos); | ||
StringBuilder navigator = new StringBuilder(); | ||
navigator.append("\n\n<ui:define name=\"content-navigator\">\n"); | ||
navigator.append(" <b:listLinks>\n"); | ||
for (String tag : tags) { | ||
navigator.append(" <b:navLink href=\"#" + tag + "\" value=\"" + chapters.get(tag) + "\" />\n"); | ||
} | ||
|
||
navigator.append(" </b:listLinks>\n"); | ||
navigator.append("</ui:define>\n\n"); | ||
System.out.println(filename + ": " + tags.size()); | ||
return start + navigator.toString() + end; | ||
|
||
} | ||
return null; | ||
} | ||
|
||
private static String examineLine(String filename, Map<String, String> chapters, List<String> tags, | ||
String previousLine, String line, String headerTag) { | ||
String newHeaderTag = "<h2>"; | ||
if (headerTag.equals("<h1>")) { | ||
newHeaderTag = "<h1>"; | ||
} | ||
if (line.contains(headerTag)) { | ||
if (line.contains("<a ")) { | ||
int posh = line.indexOf(headerTag); | ||
int posa = line.indexOf("<a"); | ||
if (posa < posh) { | ||
System.out.println("Reorder!" + line); | ||
} | ||
} else if (previousLine.contains("<a ")) { | ||
System.out.println("Previous line contains an anchor! " + line); | ||
} else { | ||
// add the anchor tag | ||
int start = line.indexOf(headerTag) + 4; | ||
int end = line.indexOf("<", start); | ||
if (end < 0) { | ||
System.out.println("Error: " + filename); | ||
} | ||
if (end < start) { | ||
System.out.println("Weird!"); | ||
} | ||
String innerText = line.substring(start, end).trim(); | ||
if (innerText.length() > 0) { | ||
innerText = innerText.replace("(Virtually no)", ""); | ||
int end2 = 0; | ||
while (end2 < innerText.length() && (Character.isLetter(innerText.charAt(end2)) | ||
|| Character.isWhitespace(innerText.charAt(end2)) || '&' == innerText.charAt(end2) | ||
|| '/' == innerText.charAt(end2) || ';' == innerText.charAt(end2) | ||
|| ':' == innerText.charAt(end2))) { | ||
end2++; | ||
} | ||
String tag = innerText.substring(0, end2).replace("<", "").replace(">", "").replace(":", "_") | ||
.replace("/", "").toLowerCase(); | ||
tag = tag.trim().replace(" ", "_"); | ||
if (tag.length() == 0) { | ||
System.out.println("Empty tag?"); | ||
} else { | ||
line = line.substring(0, line.indexOf(headerTag)) + newHeaderTag + "<a id=\"" + tag + "\">" + innerText | ||
+ "</a>" + line.substring(end); | ||
line = line.replace("</" + headerTag.substring(1), "</" + newHeaderTag.substring(1)); | ||
chapters.put(tag, innerText); | ||
tags.add(tag); | ||
newHeaderTag = "<h2>"; | ||
} | ||
} | ||
} | ||
} | ||
return line; | ||
} | ||
} |
Oops, something went wrong.