diff --git a/Advertisement_Panel b/Advertisement_Panel new file mode 100755 index 0000000..ac367ef Binary files /dev/null and b/Advertisement_Panel differ diff --git a/README.md b/README.md index 9e53864..8a43aca 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ # Advertisement_Panel + ## How To Run This Project ```bash go run main.go ``` +### Make the screen not turn off by +```bash +xset -dpms +xset s off +xset s noblank +``` + ## How To Add To This Project This project is written with go, and has hot realoding (rebuilding when sensing changes) for the main.go @@ -23,7 +31,9 @@ $(go env GOPATH)/bin/air -c .air.toml - [ ] ATB integration - [ ] ASCII ART support - [ ] show more spicy images after kl 22:00 -- [ ] more images??? +- [ ] Hide mouse cursor +- [ ] more images and memes??? + # NB!!!! Changes in the static directory will not rebuild the project, simple workaround is to just make a small change in main.go and save, for example adding a space diff --git a/file_handlers.go b/file_handlers.go new file mode 100644 index 0000000..d593d0e --- /dev/null +++ b/file_handlers.go @@ -0,0 +1,58 @@ +package main + +import ( + "encoding/json" + "net/http" + "os" + "path/filepath" + "strings" +) + +const staticDir = "static" + +// move FileData and AsciiEntry here if you want, or leave in main.go +func file_handler(w http.ResponseWriter, r *http.Request) { + data := FileData{ + ImageNames: []string{}, + SpicyImageNames: []string{}, + AsciiFiles: []AsciiEntry{}, + } + + dirs, err := os.ReadDir(staticDir) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + for _, dir := range dirs { + dirName := dir.Name() + + if strings.EqualFold(dirName, "images") { + + files, _ := os.ReadDir(filepath.Join(staticDir, dirName)) + for _, file := range files { + fileName := file.Name() + data.ImageNames = append(data.ImageNames, filepath.Join(staticDir, dirName, fileName)) + } + } else if strings.EqualFold(dirName, "spicy") { + + files, _ := os.ReadDir(filepath.Join(staticDir, dirName)) + for _, file := range files { + fileName := file.Name() + data.SpicyImageNames = append(data.SpicyImageNames, filepath.Join(staticDir, dirName, fileName)) + } + } else if strings.EqualFold(dirName, "ascii_art") { + + files, _ := os.ReadDir(filepath.Join(staticDir, dirName)) + for _, file := range files { + fileName := file.Name() + data.AsciiFiles = append(data.AsciiFiles, + AsciiEntry{Name: filepath.Join(staticDir, dirName, fileName), FontSize: 12}, + ) + } + } + } + + w.Header().Set("Content-Type", "application/json") + json.NewEncoder(w).Encode(data) +} diff --git a/main.go b/main.go index b97f6f8..4c3c743 100644 --- a/main.go +++ b/main.go @@ -1,48 +1,48 @@ package main import ( - "encoding/json" "fmt" + "html/template" "net/http" - "os" - "strings" ) +type FileData struct { + ImageNames []string + SpicyImageNames []string + AsciiFiles []AsciiEntry +} + +type AsciiEntry struct { + Name string + FontSize int +} + +var templ *template.Template + func main() { - fmt.Print("Now running server!") + templ, _ = template.ParseGlob("templates/*.html") + + fmt.Print("Now running server!\n") // Serves index http.HandleFunc("/", index_handler) // Serves json for html to find file names - http.HandleFunc("/files", files_handler) + http.HandleFunc("/files", file_handler) + + // Serves ascii page + http.HandleFunc("/ascii", ascii_handler) // Serves images - http.Handle("/images/", http.StripPrefix("/images/", http.FileServer(http.Dir("./static")))) + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static")))) - // Serves what ever the user is requesting based on above urls + // Serves what ever the user is requesting base on above urls http.ListenAndServe(":8080", nil) } func index_handler(w http.ResponseWriter, r *http.Request) { - http.ServeFile(w, r, "./static/index.html") + templ.ExecuteTemplate(w, "images.html", nil) } -func files_handler(w http.ResponseWriter, r *http.Request) { - files, err := os.ReadDir("./static") - if err != nil { - http.Error(w, err.Error(), http.StatusInternalServerError) - return - } - var names []string - for _, f := range files { - name := f.Name() - if strings.HasSuffix(name, ".jpg") || - strings.HasSuffix(name, ".png") || - strings.HasSuffix(name, ".gif") { - names = append(names, "/images/"+name) - } - } - - w.Header().Set("Content-Type", "application/json") - json.NewEncoder(w).Encode(names) +func ascii_handler(w http.ResponseWriter, r *http.Request) { + templ.ExecuteTemplate(w, "ascii.html", nil) } diff --git a/static/ascii_art/horse.txt b/static/ascii_art/horse.txt new file mode 100644 index 0000000..c82b8e4 --- /dev/null +++ b/static/ascii_art/horse.txt @@ -0,0 +1,29 @@ + Y8baadP""""""""Yba,_ +aaadP"' `""Yb, +`Y8( `"Yb, + `Y, `Yba, + Y, (O) `Yba, + `Y, ""Yba,________,,aaddddbbbaa,,____,aa,_ + `Y, ,aa `""""""""""'' ``""""'' "Y, + Y, d'8 "Ya `Y, + `b 8 8 `Y, Y, + Ya o ,8 8 b `b + Yb,_,dP 8 Y 8 + `"""" Y 8 8 + I, 8 8 + `b P [ + `b d' [ + d ,P [ + ,d' ,PY, ,P"YaaaaaaP"Ybaaa,,_ d' [ + d" ,P" Y, d' 8' `""db, d' 8 + d' ,P" `Y, 8 I, d'"b, 8a P + d( ( `Y, P `b ,P `Y, 8`Ya___d' + "Y, "b, `Y, ,I 8 d' `8 8 `"""' + "Y, "b, __ `8, d' ,8 ,P 8 8 + "Y, "bd88b `b 8 I' d' Y, 8 + "Y, 888b 8 8 8 ,P `b 8 + "Ya,,d888b8 P d' ,P' 8 Y, + `"""",d" ,I ,adPb__aP' Y `b + ,a8P,__aP' d888888P' ,d 8 + d8888888' 88888888 ,d888bbaaP + 88888888 88888888' diff --git a/static/ascii_art/pvv_logo.txt b/static/ascii_art/pvv_logo.txt new file mode 100644 index 0000000..e8ef6c3 --- /dev/null +++ b/static/ascii_art/pvv_logo.txt @@ -0,0 +1,45 @@ + + + + ''''''''''''''''''''''''''''''''''''' + .1!!!!!!!!!!!1?ab?!!1aba?!!!!!!!!!!!1; + ,!'''''''''=!!;+=.''.,=:!!;,'''''''',! + ,! ,!!+' .:!:' ,! + ,! :!+ .:!= ,! + ,! ';;' ,!+ ,! + ,! '??;!;;!!;;;;;;;;;;;;;+;;+!: ,! + ,! ';a=:!,,;!,,,,,,=!!!!+?!==!=!+ +! + ,! :;!'+; +: .1++;:!. ,!=!,.1: + ,! =!.!'+; :: .! +:!. ::=!.1: + ,! !='!'+; :: .!' +:!. +: ;:=! + ,!+; '!'+; :: .!' +:!. +: .!=! + ,!!= '!'+; :: .!' +:!. +: ;;! + ,1!' '!'+; :: .!' +:!. +: ,1! + ,a: '!'+; :: .!' +:!. +: '11 + ,b= '!.+;'':;'.....,1!!1:!. +: !? + ,b. '!..;!!1?!!!!!!!!111!; +: :a + ,?' '!.';!!!!!!!!!!!!!!!!;;;+ +: =? + ,! '!.=!,================,=!'+: ,! + ,! '!'+; '!'+: ,! + ,! '!'+; '!'+: ,! + ,?' '!'+; .,,' '' '''' '' '!'+: =? + ,b. '!'+; d00e,ba d!ab c? '!'+: :a + ,b= '!'+; fd10;ed g?cf fc '!'+: !? + ,a: '!'+; fd10;bg;0:?0:01 '!'+: '11 + ,1!' '!'+; f$0e,+0ff ,gfg. '!'+: ,1! + ,!!= '!'+; fb.' e@? c@b '!'+: ;;! + ,!+; '!'+; d? 1f= ;g: '!'+: .!=! + ,! !='!'+; ,. ', ',' '!'+: ;:,! + ,! =!.!=:; '!=::=!',! + ,! :;??a; '?1a;!, ,! + ,! ';baa1=++===============+a?ba+ ,! + ,! '?a!1!!!!!!!!!!!!!!!!!!!1!a; ,! + ,! ';;' ,!+ ,! + ,! :!+ .:!= ,! + ,! ,!!+' .:!:' ,! + ,!'''''''''=;?1+=.''.,=;?1;,'''''''',! + .1!!!!!!!!!!!1?bb?!!1aba11!!!!!!!!!!1; + ''''''''''''' ''''''''' ''''''''''''' + + + diff --git a/static/ascii_art/test.txt b/static/ascii_art/test.txt new file mode 100644 index 0000000..91c753f --- /dev/null +++ b/static/ascii_art/test.txt @@ -0,0 +1,12 @@ + a@@@@a + a@@@@@@@@@@@@a + a@@@@@@by@@@@@@@@a + a@@@@@S@C@E@S@W@@@@@@a + @@@@@@@@@@@@@@@@@@@@@@ + `@@@@@@`\\//'@@@@@@' + ,, || ,, S.C.E.S.W. + /(-\ || /.)m + ,---' /`-'||`-'\ `----, + /( )__)) || ((,==( )\ +_ /_//___\\ __|| ___\\ __\\ ____ + `` `` /MM\ '' '' diff --git a/static/Keffiyeh.png b/static/images/Keffiyeh.png similarity index 100% rename from static/Keffiyeh.png rename to static/images/Keffiyeh.png diff --git a/static/berserk_poster.png b/static/images/berserk_poster.png similarity index 100% rename from static/berserk_poster.png rename to static/images/berserk_poster.png diff --git a/static/detailed_flower.png b/static/images/detailed_flower.png similarity index 100% rename from static/detailed_flower.png rename to static/images/detailed_flower.png diff --git a/static/kiki_tee.png b/static/images/kiki_tee.png similarity index 100% rename from static/kiki_tee.png rename to static/images/kiki_tee.png diff --git a/static/long_stairs.png b/static/images/long_stairs.png similarity index 100% rename from static/long_stairs.png rename to static/images/long_stairs.png diff --git a/static/base.png b/static/images/pvv_logo.png similarity index 100% rename from static/base.png rename to static/images/pvv_logo.png diff --git a/static/totoro_stamp.png b/static/images/totoro_stamp.png similarity index 100% rename from static/totoro_stamp.png rename to static/images/totoro_stamp.png diff --git a/templates/ascii.html b/templates/ascii.html new file mode 100644 index 0000000..c66ca4e --- /dev/null +++ b/templates/ascii.html @@ -0,0 +1,75 @@ + + + +
+ + ++ a@@@@a + a@@@@@@@@@@@@a + a@@@@@@by@@@@@@@@a + a@@@@@S@C@E@S@W@@@@@@a + @@@@@@@@@@@@@@@@@@@@@@ + `@@@@@@`\\//'@@@@@@' + ,, || ,, S.C.E.S.W. + /(-\ || /.)m + ,---' /`-'||`-'\ `----, + /( )__)) || ((,==( )\ + _ /_//___\\ __|| ___\\ __\\ ____ + `` `` /MM\ '' '' ++ + + + + diff --git a/static/index.html b/templates/images.html similarity index 74% rename from static/index.html rename to templates/images.html index 884fc8a..8b0a559 100644 --- a/static/index.html +++ b/templates/images.html @@ -3,6 +3,7 @@ +