<commit_before>package com.lukechenshui.jresume.themes;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.lukechenshui.jresume.Config;
import com.lukechenshui.jresume.resume.Resume;
import j2html.tags.ContainerTag;

import java.io.File;
import java.lang.reflect.Constructor;
import java.nio.file.Paths;
import java.util.Map;

import static j2html.TagCreator.*;

/**
 * Created by luke on 12/31/16.
 */
public abstract class BaseTheme {
    protected String htmlString;
    protected ContainerTag html;
    protected Resume resumeBeingOperatedOn;
    protected String themeName;

    public BaseTheme() {
        try {
            if (themeName == null) {
                System.err.println("You must either set the name of the theme manually as an attribute of the class or use " +
                        "the constructor that takes the name of the theme as an argument.");
            }
        } catch (Exception exc) {
            exc.printStackTrace();
        }

    }

    public BaseTheme(String themeName) {
        this.themeName = themeName;
    }

    public static void registerTheme(String name, Class classObj) {
        try {
            Constructor constructor = classObj.getConstructor(String.class);
            Config.addTheme(constructor.newInstance(name));
        } catch (Exception exc) {
            exc.printStackTrace();
        }

    }

    protected  void generateHead(){

    }

    protected  void generateBody(){
        ContainerTag body = body();
        JsonObject jsonObject = resumeBeingOperatedOn.getJsonObject();

        for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
            String key = entry.getKey();
            switch (key.toLowerCase()) {
                case "person":
                    body.with(generatePerson());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "jobwork":
                    body.with(generateJobWork());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "volunteerwork":
                    body.with(generateVolunteerWork());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "skills":
                    body.with(generateSkills());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "projects":
                    body.with(generateProjects());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "education":
                    body.with(generateEducation());
                    //body.with(div().withClass("ui divider"));
                    break;
            }
        }
        body.with(br());
        body.with(br());
        body.with(br());
        html = html.with(body);
    }

    protected abstract ContainerTag generatePerson();

    public  String generate(Resume resume){
        html = html();
        html.with(document());
        resumeBeingOperatedOn = resume;
        generateHead();
        generateBody();
        htmlString = html.render();
        return htmlString;
    }

    protected abstract ContainerTag generateJobWork();

    protected abstract ContainerTag generateVolunteerWork();

    protected abstract ContainerTag generateSkills();

    protected abstract ContainerTag generateProjects();

    protected abstract ContainerTag generateEducation();

    protected String getResource(String fileName) {
        String dirToRemove = Config.getOutputDirectory();
        //System.out.println(dirToRemove);
        String resourceDirectory = Paths.get(Config.getOutputDirectory(), "resources", fileName).toString();
        resourceDirectory = resourceDirectory.replace(dirToRemove + File.separator, "");
        return resourceDirectory;
    }

    public String getThemeName() {
        return themeName;
    }

    public void setThemeName(String themeName) {
        this.themeName = themeName;
    }
}<commit_msg>Fixed resource links for CSS and JS files.<commit_after>package com.lukechenshui.jresume.themes;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.lukechenshui.jresume.Config;
import com.lukechenshui.jresume.resume.Resume;
import j2html.tags.ContainerTag;

import java.io.File;
import java.lang.reflect.Constructor;
import java.nio.file.Paths;
import java.util.Map;

import static j2html.TagCreator.*;

/**
 * Created by luke on 12/31/16.
 */
public abstract class BaseTheme {
    protected String htmlString;
    protected ContainerTag html;
    protected Resume resumeBeingOperatedOn;
    protected String themeName;

    public BaseTheme() {
        try {
            if (themeName == null) {
                System.err.println("You must either set the name of the theme manually as an attribute of the class or use " +
                        "the constructor that takes the name of the theme as an argument.");
            }
        } catch (Exception exc) {
            exc.printStackTrace();
        }

    }

    public BaseTheme(String themeName) {
        this.themeName = themeName;
    }

    public static void registerTheme(String name, Class classObj) {
        try {
            Constructor constructor = classObj.getConstructor(String.class);
            Config.addTheme(constructor.newInstance(name));
        } catch (Exception exc) {
            exc.printStackTrace();
        }

    }

    protected  void generateHead(){

    }

    protected  void generateBody(){
        ContainerTag body = body();
        JsonObject jsonObject = resumeBeingOperatedOn.getJsonObject();

        for (Map.Entry<String, JsonElement> entry : jsonObject.entrySet()) {
            String key = entry.getKey();
            switch (key.toLowerCase()) {
                case "person":
                    body.with(generatePerson());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "jobwork":
                    body.with(generateJobWork());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "volunteerwork":
                    body.with(generateVolunteerWork());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "skills":
                    body.with(generateSkills());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "projects":
                    body.with(generateProjects());
                    //body.with(div().withClass("ui divider"));
                    break;
                case "education":
                    body.with(generateEducation());
                    //body.with(div().withClass("ui divider"));
                    break;
            }
        }
        body.with(br());
        body.with(br());
        body.with(br());
        html = html.with(body);
    }

    protected abstract ContainerTag generatePerson();

    public  String generate(Resume resume){
        html = html();
        html.with(document());
        resumeBeingOperatedOn = resume;
        generateHead();
        generateBody();
        htmlString = html.render();
        return htmlString;
    }

    protected abstract ContainerTag generateJobWork();

    protected abstract ContainerTag generateVolunteerWork();

    protected abstract ContainerTag generateSkills();

    protected abstract ContainerTag generateProjects();

    protected abstract ContainerTag generateEducation();

    protected String getResource(String fileName) {
        String dirToRemove = new File(Config.getOutputDirectory()).getAbsolutePath();
        //System.out.println(dirToRemove);
        String resourceDirectory = Paths.get(new File(Config.getOutputDirectory()).getAbsolutePath(), "resources", fileName).toString();
        resourceDirectory = resourceDirectory.replace(dirToRemove + File.separator, "");
        return resourceDirectory;
    }

    public String getThemeName() {
        return themeName;
    }

    public void setThemeName(String themeName) {
        this.themeName = themeName;
    }
}
{'fraction_non_alphanumeric': 0.10467222021006882, 'fraction_numerical': 0.0019316672703126887, 'mean_word_length': 2.0288848263254113, 'pattern_counts': {'":': 12, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6200831', 'n_tokens_mistral': 2114, 'n_tokens_neox': 2014, 'n_words': 481}