Move examples to a separate repo to minimize dependencies - #18
Open
harrisonhjones wants to merge 1 commit into
Open
Move examples to a separate repo to minimize dependencies#18harrisonhjones wants to merge 1 commit into
harrisonhjones wants to merge 1 commit into
Conversation
Owner
|
There's no need to an extra repo, just move them inside a examples folder. It's enough! |
Contributor
Author
|
Does that remove their deps from go.mod? If so I did not know that. |
Contributor
Author
|
Hey @jordic, checking in on this. Any thoughts? |
|
Hi, Making a fresh install of this library, this load these unwanted libraries : I don't understand the need of package main
import (
"log"
"net/http"
"time"
"github.com/jordic/goics"
)
const serverHost = "localhost:9000"
type Reserva struct {
UID string // Should be uuid.UUID from "github.com/google/uuid"
DateStart time.Time
DataEnd time.Time
Location string
Summary string
Description string
}
// A collection of rous
type ReservasCollection []*Reserva
func main() {
http.Handle("/", http.HandlerFunc(LimpiezaHandler))
log.Print("Server started at http://" + serverHost)
log.Fatal(http.ListenAndServe(serverHost, nil))
}
func LimpiezaHandler(w http.ResponseWriter, r *http.Request) {
log.Print("Calendar request")
// Setup headers for the calendar
w.Header().Set("Content-type", "text/calendar")
w.Header().Set("charset", "utf-8")
w.Header().Set("Content-Disposition", "inline")
w.Header().Set("filename", "calendar.ics")
// Get the Collection models
collection := GetReservas()
// Encode it.
goics.NewICalEncode(w).Encode(collection)
}
func GetReservas() ReservasCollection {
now := time.Now()
desc := `Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Proin urna felis, porta in convallis cursus, eleifend ac orci…`
return ReservasCollection{
{
UID: "d4c8a472-2c06-4c95-929e-885e3db7ee51",
DateStart: now,
DataEnd: now.Add(time.Hour),
Location: "Here",
Summary: "This is the summary",
Description: desc,
},
{
UID: "28aa46c7-f7d0-4727-bf5c-4e54b7a72bce",
DateStart: now.Add(26 * time.Hour),
DataEnd: now.Add(27 * time.Hour),
Location: "There",
Summary: "This is an other summary",
Description: desc + " Bis…",
},
}
}
// We implement ICalEmiter interface that will return a goics.Componenter.
func (rc ReservasCollection) EmitICal() goics.Componenter {
c := goics.NewComponent()
c.SetType("VCALENDAR")
c.AddProperty("CALSCAL", "GREGORIAN")
c.AddProperty("PRODID;X-RICAL-TZSOURCE=TZINFO", "-//tmpo.io")
for _, ev := range rc {
s := goics.NewComponent()
s.SetType("VEVENT")
k, v := goics.FormatDateField("DTSTART", ev.DateStart)
s.AddProperty(k, v)
k, v = goics.FormatDateField("DTEND", ev.DataEnd)
s.AddProperty(k, v)
s.AddProperty("UID", ev.UID)
s.AddProperty("DESCRIPTION", ev.Description)
s.AddProperty("SUMMARY", ev.Summary)
s.AddProperty("LOCATION", ev.Location)
c.AddComponent(s)
}
return c
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
As brought up in #16 this PR removes our examples (@jordic to move them to a new repo) to minimize the deps pulled into this project.
Testing
Pushed this change to my fork. Checked that the build succeeds in some cases: https://travis-ci.org/github/harrisonhjones/goics/builds/765948947 (build failures for 1.9 and 1.8 addressed in #17 )