<commit_before>package controller

import (
	"fmt"
	"net/http"
	"strings"

	"github.com/gin-gonic/gin"

	"../cfg"
)

func render(c *gin.Context, template string, ctx map[string]interface{}) {
	ui := []string{"lang", "title", "heading", "intro", "theme", "author", "description", "date_format"}
	for i := 0; i < len(ui); i++ {
		if _, ok := ctx[ui[i]]; !ok {
			ctx[ui[i]] = cfg.String("ui." + ui[i])
		}
	}

	ctx["instance_id"] = cfg.GetInstanceId()
	ctx["url_path"] = c.Request.URL.Path

	uiAbout := cfg.String("ui.about")
	if len(uiAbout) > 0 {
		ctx["about_path"] = uiAbout
	} else {
		ctx["about_path"] = "./partial/about.html"
	}

	// enabled plugins and their settings
	enabledPlugins := strings.Split(cfg.String("plugins"), " ")
	plugin := make(map[string]map[string]string)
	plugins := make(map[string]bool)
	for i := 0; i < len(enabledPlugins); i++ {
		plugin[enabledPlugins[i]] = make(map[string]string)
		plugins[enabledPlugins[i]] = true

		pluginParams := strings.Split(cfg.String(fmt.Sprintf("plugin.%s._", enabledPlugins[i])), " ")
		for j := 0; j < len(pluginParams); j++ {
			plugin[enabledPlugins[i]][pluginParams[j]] = cfg.String(fmt.Sprintf("plugin.%s.%s", enabledPlugins[i], pluginParams[j]))
		}
	}
	ctx["plugins"] = plugins
	ctx["plugin"] = plugin

	c.Set("template", fmt.Sprintf("./templates/%v/%s", ctx["theme"], template))
	c.Set("data", ctx)<commit_msg>fixed relative path for templates<commit_after>package controller

import (
	"fmt"
	"net/http"
	"strings"

	"github.com/gin-gonic/gin"

	"../cfg"
)

func render(c *gin.Context, template string, ctx map[string]interface{}) {
	ui := []string{"lang", "title", "heading", "intro", "theme", "author", "description", "date_format"}
	for i := 0; i < len(ui); i++ {
		if _, ok := ctx[ui[i]]; !ok {
			ctx[ui[i]] = cfg.String("ui." + ui[i])
		}
	}

	ctx["instance_id"] = cfg.GetInstanceId()
	ctx["url_path"] = c.Request.URL.Path

	uiAbout := cfg.String("ui.about")
	if len(uiAbout) > 0 {
		ctx["about_path"] = uiAbout
	} else {
		ctx["about_path"] = "./partial/about.html"
	}

	// enabled plugins and their settings
	enabledPlugins := strings.Split(cfg.String("plugins"), " ")
	plugin := make(map[string]map[string]string)
	plugins := make(map[string]bool)
	for i := 0; i < len(enabledPlugins); i++ {
		plugin[enabledPlugins[i]] = make(map[string]string)
		plugins[enabledPlugins[i]] = true

		pluginParams := strings.Split(cfg.String(fmt.Sprintf("plugin.%s._", enabledPlugins[i])), " ")
		for j := 0; j < len(pluginParams); j++ {
			plugin[enabledPlugins[i]][pluginParams[j]] = cfg.String(fmt.Sprintf("plugin.%s.%s", enabledPlugins[i], pluginParams[j]))
		}
	}
	ctx["plugins"] = plugins
	ctx["plugin"] = plugin

	c.Set("template", fmt.Sprintf("%s/templates/%v/%s", cfg.GetRootDir(), ctx["theme"], template))
	c.Set("data", ctx)
{'fraction_non_alphanumeric': 0.2150768131475527, 'fraction_numerical': 0.0028581636298678098, 'mean_word_length': 4.809128630705394, 'pattern_counts': {'":': 0, '<': 9, '<?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': '7442156', 'n_tokens_mistral': 1078, 'n_tokens_neox': 1018, 'n_words': 194}