<commit_before>package main

import (
	"fmt"
	"html/template"
	"io/ioutil"
	"net/http"
	"path"
	"regexp"
	"strconv"
	"strings"

	"github.com/boltdb/bolt"
	"github.com/gin-gonic/gin"
	"github.com/microcosm-cc/bluemonday"
	"github.com/russross/blackfriday"
)

func newNote(c *gin.Context) {
	title := randomAlliterateCombo()
	c.Redirect(302, "/"+title)
}

func editNote(c *gin.Context) {
	title := c.Param("title")
	if title == "ws" {
		wshandler(c.Writer, c.Request)
	} else if title == "robots.txt" {
		c.Data(200, "text/plain", []byte(robots_txt))
	} else if strings.ToLower(title) == "about" { //}&& strings.Contains(AllowedIPs, c.ClientIP()) != true {
		c.Redirect(302, "/about/view")
	} else {
		locked, _ := hasPassword(title)
		if locked {
			c.Redirect(302, "/"+title+"/view")
		} else {
			version := c.DefaultQuery("version", "-1")
			versionNum, _ := strconv.Atoi(version)
			currentText, versions, currentVersion := getCurrentText(title, versionNum)
			numRows := len(strings.Split(currentText, "\n")) + 10
			if currentVersion {
				c.HTML(http.StatusOK, "index.tmpl", gin.H{
					"Title":       title,
					"ExternalIP":  RuntimeArgs.ExternalIP,
					"CurrentText": currentText,
					"NumRows":     numRows,
					"Versions":    versions,
				})
			} else {
				c.HTML(http.StatusOK, "index.tmpl", gin.H{
					"Title":       title,
					"ExternalIP":  RuntimeArgs.ExternalIP,
					"CurrentText": currentText,
					"NumRows":     numRows,
					"Versions":    versions,
					"NoEdit":      true,
				})
			}

		}
	}
}

func everythingElse(c *gin.Context) {
	option := c.Param("option")
	title := c.Param("title")
	if option == "/view" {
		version := c.DefaultQuery("version", "-1")
		versionNum, _ := strconv.Atoi(version)
		currentText, versions, _ := getCurrentText(title, versionNum)
		renderMarkdown(c, currentText, title, versions)
	} else if title == "ls" && option == "/"+RuntimeArgs.AdminKey && len(RuntimeArgs.AdminKey) > 1 {<commit_msg>Fixed about sticky page<commit_after>package main

import (
	"fmt"
	"html/template"
	"io/ioutil"
	"net/http"
	"path"
	"regexp"
	"strconv"
	"strings"

	"github.com/boltdb/bolt"
	"github.com/gin-gonic/gin"
	"github.com/microcosm-cc/bluemonday"
	"github.com/russross/blackfriday"
)

func newNote(c *gin.Context) {
	title := randomAlliterateCombo()
	c.Redirect(302, "/"+title)
}

func editNote(c *gin.Context) {
	title := c.Param("title")
	if title == "ws" {
		wshandler(c.Writer, c.Request)
	} else if title == "robots.txt" {
		c.Data(200, "text/plain", []byte(robots_txt))
	} else if strings.ToLower(title) == "about" { //}&& strings.Contains(AllowedIPs, c.ClientIP()) != true {
		c.Redirect(302, "/about/view")
	} else {
		locked, _ := hasPassword(title)
		if locked {
			c.Redirect(302, "/"+title+"/view")
		} else {
			version := c.DefaultQuery("version", "-1")
			versionNum, _ := strconv.Atoi(version)
			currentText, versions, currentVersion := getCurrentText(title, versionNum)
			numRows := len(strings.Split(currentText, "\n")) + 10
			if currentVersion {
				c.HTML(http.StatusOK, "index.tmpl", gin.H{
					"Title":       title,
					"ExternalIP":  RuntimeArgs.ExternalIP,
					"CurrentText": currentText,
					"NumRows":     numRows,
					"Versions":    versions,
				})
			} else {
				c.HTML(http.StatusOK, "index.tmpl", gin.H{
					"Title":       title,
					"ExternalIP":  RuntimeArgs.ExternalIP,
					"CurrentText": currentText,
					"NumRows":     numRows,
					"Versions":    versions,
					"NoEdit":      true,
				})
			}

		}
	}
}

func everythingElse(c *gin.Context) {
	option := c.Param("option")
	title := c.Param("title")
	if option == "/view" {
		version := c.DefaultQuery("version", "-1")
		versionNum, _ := strconv.Atoi(version)
		if strings.ToLower(title) == "about" {
			versionNum = -1
		}
		currentText, versions, _ := getCurrentText(title, versionNum)
		renderMarkdown(c, currentText, title, versions)
	} else if title == "ls" && option == "/"+RuntimeArgs.AdminKey && len(RuntimeArgs.AdminKey) > 1 {
{'fraction_non_alphanumeric': 0.17686904164576017, 'fraction_numerical': 0.008780732563973909, 'mean_word_length': 3.510180995475113, 'pattern_counts': {'":': 22, '<': 3, '<?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': '5464906', 'n_tokens_mistral': 1672, 'n_tokens_neox': 1464, 'n_words': 272}