Search in sources :

Example 1 with NestedTagValue

use of tools.utils.TagValue.NestedTagValue in project AuthMeReloaded by AuthMe.

the class PermissionsListWriter method generatePermissionsList.

private static NestedTagValue generatePermissionsList() {
    PermissionNodesGatherer gatherer = new PermissionNodesGatherer();
    Map<String, String> permissions = gatherer.gatherNodesWithJavaDoc();
    NestedTagValue permissionTags = new NestedTagValue();
    for (Map.Entry<String, String> entry : permissions.entrySet()) {
        permissionTags.add(TagValueHolder.create().put("node", entry.getKey()).put("description", entry.getValue()));
    }
    return permissionTags;
}
Also used : NestedTagValue(tools.utils.TagValue.NestedTagValue) Map(java.util.Map)

Example 2 with NestedTagValue

use of tools.utils.TagValue.NestedTagValue in project AuthMeReloaded by AuthMe.

the class HashAlgorithmsDescriptionTask method constructMethodRows.

private static NestedTagValue constructMethodRows(Map<HashAlgorithm, MethodDescription> descriptions) {
    NestedTagValue methodTags = new NestedTagValue();
    for (Map.Entry<HashAlgorithm, MethodDescription> entry : descriptions.entrySet()) {
        MethodDescription description = entry.getValue();
        TagValueHolder tags = TagValueHolder.create().put("name", asString(entry.getKey())).put("recommendation", asString(description.getUsage())).put("hash_length", asString(description.getHashLength())).put("ascii_restricted", asString(description.isAsciiRestricted())).put("salt_type", asString(description.getSaltType())).put("salt_length", asString(description.getSaltLength())).put("separate_salt", asString(description.hasSeparateSalt()));
        methodTags.add(tags);
    }
    return methodTags;
}
Also used : TagValueHolder(tools.utils.TagValueHolder) NestedTagValue(tools.utils.TagValue.NestedTagValue) Map(java.util.Map) HashAlgorithm(fr.xephi.authme.security.HashAlgorithm)

Example 3 with NestedTagValue

use of tools.utils.TagValue.NestedTagValue in project AuthMeReloaded by AuthMe.

the class TagReplacer method applyReplacements.

/**
 * Replace a template with default tags and custom ones supplied by a map.
 *
 * @param template The template to process
 * @param tagValues Container with tags and their associated values
 * @return The filled template
 */
public static String applyReplacements(String template, TagValueHolder tagValues) {
    String result = template;
    for (Map.Entry<String, TagValue<?>> tagRule : tagValues.getValues().entrySet()) {
        final String name = tagRule.getKey();
        if (tagRule.getValue() instanceof TextTagValue) {
            final TextTagValue value = (TextTagValue) tagRule.getValue();
            result = replaceOptionalTag(result, name, value).replace("{" + name + "}", value.getValue());
        } else if (tagRule.getValue() instanceof NestedTagValue) {
            final NestedTagValue value = (NestedTagValue) tagRule.getValue();
            result = replaceIterateTag(replaceOptionalTag(result, name, value), name, value);
        } else {
            throw new IllegalStateException("Unknown tag value type");
        }
    }
    return applyReplacements(result);
}
Also used : TextTagValue(tools.utils.TagValue.TextTagValue) NestedTagValue(tools.utils.TagValue.NestedTagValue) NestedTagValue(tools.utils.TagValue.NestedTagValue) TextTagValue(tools.utils.TagValue.TextTagValue) Map(java.util.Map)

Example 4 with NestedTagValue

use of tools.utils.TagValue.NestedTagValue in project AuthMeReloaded by AuthMe.

the class TranslationPageGenerator method executeDefault.

@Override
public void executeDefault() {
    TranslationsGatherer gatherer = new TranslationsGatherer();
    NestedTagValue translationValuesHolder = new NestedTagValue();
    for (TranslationInfo translation : gatherer.getTranslationInfo()) {
        int percentage = (int) Math.round(translation.getPercentTranslated() * 100);
        String name = Optional.ofNullable(LANGUAGE_NAMES.get(translation.getCode())).orElse("?");
        TagValueHolder valueHolder = TagValueHolder.create().put("code", translation.getCode()).put("name", name).put("percentage", Integer.toString(percentage)).put("color", computeColor(percentage));
        translationValuesHolder.add(valueHolder);
    }
    TagValueHolder tags = TagValueHolder.create().put("languages", translationValuesHolder);
    FileIoUtils.generateFileFromTemplate(TEMPLATE_FILE, DOCS_PAGE, tags);
    System.out.println("Wrote to '" + DOCS_PAGE + "'");
}
Also used : TagValueHolder(tools.utils.TagValueHolder) NestedTagValue(tools.utils.TagValue.NestedTagValue) TranslationInfo(tools.docs.translations.TranslationsGatherer.TranslationInfo)

Example 5 with NestedTagValue

use of tools.utils.TagValue.NestedTagValue in project AuthMeReloaded by AuthMe.

the class CommandPageCreater method executeDefault.

@Override
public void executeDefault() {
    CommandInitializer commandInitializer = new CommandInitializer();
    final Collection<CommandDescription> baseCommands = commandInitializer.getCommands();
    NestedTagValue commandTags = new NestedTagValue();
    addCommandsInfo(commandTags, baseCommands);
    FileIoUtils.generateFileFromTemplate(ToolsConstants.TOOLS_SOURCE_ROOT + "docs/commands/commands.tpl.md", OUTPUT_FILE, TagValueHolder.create().put("commands", commandTags));
    System.out.println("Wrote to '" + OUTPUT_FILE + "' with " + baseCommands.size() + " base commands.");
}
Also used : CommandDescription(fr.xephi.authme.command.CommandDescription) CommandInitializer(fr.xephi.authme.command.CommandInitializer) NestedTagValue(tools.utils.TagValue.NestedTagValue)

Aggregations

NestedTagValue (tools.utils.TagValue.NestedTagValue)7 TagValueHolder (tools.utils.TagValueHolder)4 Map (java.util.Map)3 HashAlgorithm (fr.xephi.authme.security.HashAlgorithm)2 CommandDescription (fr.xephi.authme.command.CommandDescription)1 CommandInitializer (fr.xephi.authme.command.CommandInitializer)1 TranslationInfo (tools.docs.translations.TranslationsGatherer.TranslationInfo)1 TextTagValue (tools.utils.TagValue.TextTagValue)1