Add go.mod and remove /robots.txt

pull/1/head
Leonid Maslakov 1 year ago
parent d9117ff753
commit f7cd306717

@ -22,11 +22,10 @@
package main
import (
"../internal/api"
"../internal/assets"
"../internal/config"
"../internal/pages"
"../internal/storage"
"git.lcomrade.su/root/lenpaste/internal/api"
"git.lcomrade.su/root/lenpaste/internal/config"
"git.lcomrade.su/root/lenpaste/internal/pages"
"git.lcomrade.su/root/lenpaste/internal/storage"
"errors"
"io"
"log"
@ -175,12 +174,6 @@ func main() {
//Log start
infoLog.Println("## Start Lenpaste ##")
//Load assets
err = assets.Load()
if err != nil {
errLog.Fatal("load assets:", err)
}
//Load pages
err = pages.Load()
if err != nil {
@ -189,7 +182,6 @@ func main() {
//Handlers
http.HandleFunc("/style.css", pages.Style)
http.HandleFunc("/robots.txt", assets.RobotsTxt)
http.HandleFunc("/", pages.GetPaste)
http.HandleFunc("/new", pages.NewPaste)

@ -0,0 +1,5 @@
module git.lcomrade.su/root/lenpaste
go 1.11
replace git.lcomrade.su/root/lenpaste/internal => ./internal

@ -0,0 +1,2 @@
github.com/mattn/go-sqlite3 v1.14.13/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
github.com/yuin/goldmark v1.4.12/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=

@ -21,8 +21,8 @@
package api
import (
"../config"
"../storage"
"git.lcomrade.su/root/lenpaste/internal/config"
"git.lcomrade.su/root/lenpaste/internal/storage"
"encoding/json"
"net/http"
"path/filepath"

@ -1,71 +0,0 @@
/*
Copyright 2021 Leonid Maslakov
License: GPL-3.0-or-later
This file is part of Lenpaste.
Lenpaste is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Lenpaste is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Lenpaste. If not, see <https://www.gnu.org/licenses/>.
*/
package assets
import (
"io"
"io/ioutil"
"net/http"
"os"
)
const (
robotsTxtPath = "./data/robots.txt"
)
//robots.txt
func RobotsTxt(rw http.ResponseWriter, req *http.Request) {
//Return response
rw.Header().Set("Content-Type", "text/plain")
io.WriteString(rw, robotsTxt)
}
//Load robots.txt
func loadRobotsTxt() string {
robotsTxt := `
User-agent: *
Disallow: /`
//Open file
file, err := os.Open(robotsTxtPath)
if err != nil {
return robotsTxt
}
defer file.Close()
//Read file
fileByte, err := ioutil.ReadAll(file)
if err != nil {
return robotsTxt
}
return string(fileByte)
}
var robotsTxt string
//Load
func Load() error {
robotsTxt = loadRobotsTxt()
return nil
}

@ -21,8 +21,8 @@
package pages
import (
"../config"
"../storage"
"git.lcomrade.su/root/lenpaste/internal/config"
"git.lcomrade.su/root/lenpaste/internal/storage"
"bytes"
"html/template"
"io"

Loading…
Cancel
Save