diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index ee8fb7c..6cfce2d 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -56,7 +56,7 @@ class _LoginPageState extends State { width: 315, height: 65, decoration: const BoxDecoration( - color: Colors.transparent + color: Colors.black ), ), ), diff --git a/scripts/mail-scripts/email_body.html b/scripts/mail-scripts/email_body.html new file mode 100644 index 0000000..53d0534 --- /dev/null +++ b/scripts/mail-scripts/email_body.html @@ -0,0 +1,16 @@ + + + + + + OSDHACK '24 - AR Code + + +

Ahoy OSDHACK Participants!

+

Thank you for registering for OSDHACK '24. Below is your unique QR code for attendance:

+ AR Code +

Please make sure to bring this code with you to the event.

+

For more information and updates, visit the OSDHACK '24 website.

+

Best regards,
OSDC

+ + diff --git a/scripts/mail-scripts/emails.json b/scripts/mail-scripts/emails.json new file mode 100644 index 0000000..376a285 --- /dev/null +++ b/scripts/mail-scripts/emails.json @@ -0,0 +1,7 @@ +{ + "subscribers": [ + "shivang.sharma2062@gmail.com", + "krishkushjain@gmail.com", + "rahulkalra045@gmail.com" + ] +} \ No newline at end of file diff --git a/scripts/mail-scripts/go.mod b/scripts/mail-scripts/go.mod new file mode 100644 index 0000000..bbc90f8 --- /dev/null +++ b/scripts/mail-scripts/go.mod @@ -0,0 +1,10 @@ +module github.com/osdc/Mercurius + +go 1.15 + +require ( + github.com/yuin/goldmark v1.3.5 + github.com/yuin/goldmark-meta v1.0.0 // indirect + gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect + gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect +) diff --git a/scripts/mail-scripts/go.sum b/scripts/mail-scripts/go.sum new file mode 100644 index 0000000..8b8a9fe --- /dev/null +++ b/scripts/mail-scripts/go.sum @@ -0,0 +1,12 @@ +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5 h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark-meta v1.0.0 h1:ScsatUIT2gFS6azqzLGUjgOnELsBOxMXerM3ogdJhAM= +github.com/yuin/goldmark-meta v1.0.0/go.mod h1:zsNNOrZ4nLuyHAJeLQEZcQat8dm70SmB2kHbls092Gc= +gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk= +gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE= +gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw= +gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= +gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/scripts/mail-scripts/main.go b/scripts/mail-scripts/main.go new file mode 100644 index 0000000..1449e5f --- /dev/null +++ b/scripts/mail-scripts/main.go @@ -0,0 +1,102 @@ +package main + +import ( + "bytes" + "encoding/json" + "fmt" + "html" + "html/template" + "io/ioutil" + "log" + "os" + + "github.com/yuin/goldmark" + meta "github.com/yuin/goldmark-meta" + "github.com/yuin/goldmark/parser" + "gopkg.in/gomail.v2" +) + +type subscriberList struct { + Subscribers []string `json:"subscribers"` +} + +func main() { + markdown := goldmark.New( + goldmark.WithExtensions( + meta.Meta, + ), + ) + + jsonFile, err := os.Open("emails.json") + + if err != nil { + log.Print(err) + } + + defer jsonFile.Close() + + byteValue, _ := ioutil.ReadAll(jsonFile) + + var list subscriberList + + json.Unmarshal(byteValue, &list) + + content, _ := ioutil.ReadFile("../../content/post/example.md") + + var buf bytes.Buffer + context := parser.NewContext() + if err := markdown.Convert(content, &buf, parser.WithContext(context)); err != nil { + panic(err) + } + metaData := meta.Get(context) + title := metaData["title"] + str := fmt.Sprintf("%v", title) + + t := template.New("template.html") + t, _ = t.ParseFiles("template.html") + + var body bytes.Buffer + + if err := t.Execute(&body, struct { + Content string + Title string + }{ + Content: buf.String(), + Title: str, + }); err != nil { + log.Println(err) + } + html := html.UnescapeString(body.String()) + + send(html, list.Subscribers) +} + +func send(body string, to []string) { + from := os.Getenv("MAIL_ID") + pass := os.Getenv("MAIL_PASSWORD") + + d := gomail.NewDialer("smtp.gmail.com", 587, from, pass) + s, err := d.Dial() + if err != nil { + panic(err) + } + + bodyContent, err := ioutil.ReadFile("email_body.html") + if err != nil { + log.Fatal(err) + } + + m := gomail.NewMessage() + for _, r := range to { + fmt.Printf("Sending email to: %s\n", r) + m.SetHeader("From", from) + m.SetAddressHeader("To", r, r) + m.SetHeader("Subject", "OSDHACK '24 Attendance QR") + m.SetBody("text/html", string(bodyContent)) + + if err := gomail.Send(s, m); err != nil { + log.Printf("Could not send email to %q: %v", r, err) + } + m.Reset() + } +} diff --git a/scripts/mail-scripts/template.html b/scripts/mail-scripts/template.html new file mode 100644 index 0000000..1a3c84d --- /dev/null +++ b/scripts/mail-scripts/template.html @@ -0,0 +1,7 @@ + + + +

{{.Title}}

+

{{.Content}}

+ +