2018-10-25 18:06:54 +02:00
|
|
|
package initializers
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
. "Elektromarket/models"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initializePages() {
|
|
|
|
Pages = make(map[string]Page)
|
2018-10-25 19:23:49 +02:00
|
|
|
Pages["index"] = Page{Path: "/", Template: "templates/index.html", Data: map[string]interface{}{"categories": Categories}}
|
2018-10-25 18:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func initializeData() {
|
|
|
|
Categories = []Category {
|
|
|
|
{1, "Laptopy"},
|
|
|
|
{2, "Komputery"},
|
|
|
|
{3, "Smartfony"},
|
|
|
|
{4, "Smartwache"},
|
|
|
|
{5, "Monitory"},
|
|
|
|
{6, "Drukarki"},
|
|
|
|
{7, "Myszki"},
|
|
|
|
{8, "Klawiatury"},
|
|
|
|
{9, "Akcesoria"},
|
|
|
|
}
|
2018-10-25 19:23:49 +02:00
|
|
|
|
|
|
|
Products = []Product {
|
|
|
|
{
|
|
|
|
1,
|
|
|
|
GetCategoryByName("Laptopy"),
|
|
|
|
"Apple MacBook Air 128 GB",
|
|
|
|
"Procesor Intel Core i5</br>Pamięć 8 GB</br>Dysk SSD M.2 PCIe 128 GB</br>Grafika Intel HD Graphics 6000</br>Typ ekranu Błyszczący, LED</br>System macOS Sierra",
|
|
|
|
"https://cdn.x-kom.pl/i/setup/images/prod/big/product-big,apple-macbook-air-i58gb128gbhd-6000mac-os-368639,pr_2016_4_28_12_39_54_140.jpg",
|
|
|
|
11,
|
|
|
|
3999,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
2,
|
|
|
|
GetCategoryByName("Komputery"),
|
|
|
|
"Dell Inspiron 3670",
|
|
|
|
"System Microsoft Windows 10 Home PL</br>Procesor Intel Core i7-8700</br>Grafika NVIDIA GeForce GTX 1050Ti, + Intel UHD Graphics 630</br>Pamięć RAM 8 GB</br>Dysk SSD PCIe 128 GB</br>Dysk HDD SATA 7200 obr. 1000 GB</br>Miejsce na dodatkowy wewnętrzny dysk SATA Możliwość montażu dwóch dysków SATA",
|
|
|
|
"https://cdn.x-kom.pl/i/setup/images/prod/big/product-big,dell-inspiron-3670-i7-87008gb1281000win10-gtx1050ti-447395,2018/9/pr_2018_9_20_15_45_5_770_00.jpg",
|
|
|
|
123,
|
|
|
|
4299,
|
|
|
|
},
|
|
|
|
}
|
2018-10-25 18:06:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func Initialize() {
|
|
|
|
initializeData()
|
2018-10-25 19:23:49 +02:00
|
|
|
initializePages()
|
2018-10-25 18:06:54 +02:00
|
|
|
for k := range Pages {
|
|
|
|
http.HandleFunc(Pages[k].Path, Pages[k].HandlePage)
|
|
|
|
}
|
|
|
|
http.ListenAndServe(":8000", nil)
|
|
|
|
}
|