Reorganise
This commit is contained in:
parent
0ddeff0c90
commit
12d1cff06a
|
@ -0,0 +1,14 @@
|
|||
.PHONY: build run clean
|
||||
|
||||
all: clean build run
|
||||
|
||||
build:
|
||||
mkdir -p bin
|
||||
go build -o ./bin/trakr .
|
||||
|
||||
run:
|
||||
./bin/trakr
|
||||
|
||||
clean:
|
||||
go clean
|
||||
rm -rf bin
|
17
create.html
17
create.html
|
@ -1,17 +0,0 @@
|
|||
<body>
|
||||
<div class="container">
|
||||
<h2>Your Tracking Pixel Link</h2>
|
||||
<input type="text" id="pixelLink" value="Generated Link Here" readonly>
|
||||
<button onclick="copyLink()">Copy Link</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function copyLink() {
|
||||
var copyText = document.getElementById("pixelLink");
|
||||
copyText.select();
|
||||
copyText.setSelectionRange(0, 99999); /* For mobile devices */
|
||||
document.execCommand("copy");
|
||||
alert("Copied the link: " + copyText.value);
|
||||
}
|
||||
</script>
|
||||
</body>
|
34
main.go
34
main.go
|
@ -1,39 +1,9 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"git.bhasher.com/bhasher/trakr/server"
|
||||
)
|
||||
|
||||
var onePixelGIF = []byte{
|
||||
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00,
|
||||
0x01, 0x00, 0x80, 0xff, 0x00, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
|
||||
0x01, 0x00, 0x3b,
|
||||
}
|
||||
|
||||
func main() {
|
||||
db = initDB("data.sqlite")
|
||||
|
||||
http.HandleFunc("/new", newPixelPageHandler)
|
||||
http.HandleFunc("/create-pixel", createPixelHandler)
|
||||
http.HandleFunc("/p/", pixelHandler)
|
||||
http.HandleFunc("/dashboard", dashboardHandler)
|
||||
|
||||
addr := ":8080"
|
||||
|
||||
fmt.Printf("Server is up and running on http://localhost%s\n", addr)
|
||||
|
||||
log.Fatal(http.ListenAndServe(addr, nil))
|
||||
}
|
||||
|
||||
type PixelStats struct {
|
||||
Title string
|
||||
TotalViews int
|
||||
UniqueViews int
|
||||
UUID string
|
||||
server.Server()
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"database/sql"
|
|
@ -1,4 +1,4 @@
|
|||
package main
|
||||
package server
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
func newPixelPageHandler(w http.ResponseWriter, r *http.Request) {
|
||||
tmpl, err := template.ParseFiles("new.html")
|
||||
tmpl, err := template.ParseFiles("public/html/new.html")
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
|
@ -120,7 +120,7 @@ func dashboardHandler(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
|
||||
// Render the template
|
||||
tmpl, err := template.ParseFiles("dashboard.html")
|
||||
tmpl, err := template.ParseFiles("public/html/dashboard.html")
|
||||
if err != nil {
|
||||
http.Error(w, "Error loading template", http.StatusInternalServerError)
|
||||
return
|
|
@ -0,0 +1,39 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
||||
var onePixelGIF = []byte{
|
||||
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00,
|
||||
0x01, 0x00, 0x80, 0xff, 0x00, 0xff, 0xff, 0xff,
|
||||
0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
|
||||
0x01, 0x00, 0x3b,
|
||||
}
|
||||
|
||||
func Server() {
|
||||
db = initDB("data.sqlite")
|
||||
|
||||
http.HandleFunc("/new", newPixelPageHandler)
|
||||
http.HandleFunc("/create-pixel", createPixelHandler)
|
||||
http.HandleFunc("/p/", pixelHandler)
|
||||
http.HandleFunc("/dashboard", dashboardHandler)
|
||||
|
||||
addr := ":8080"
|
||||
|
||||
fmt.Printf("Server is up and running on http://localhost%s\n", addr)
|
||||
|
||||
log.Fatal(http.ListenAndServe(addr, nil))
|
||||
}
|
||||
|
||||
type PixelStats struct {
|
||||
Title string
|
||||
TotalViews int
|
||||
UniqueViews int
|
||||
UUID string
|
||||
}
|
Loading…
Reference in New Issue