Skip to content

Commit

Permalink
format and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mdigger committed Jun 20, 2021
1 parent c753f29 commit 6c78a28
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 44 deletions.
26 changes: 0 additions & 26 deletions .circleci/config.yml

This file was deleted.

28 changes: 14 additions & 14 deletions metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ import (
"time"
)

// Element with optional ID.
type Element struct {
Value string `xml:",chardata"`
ID string `xml:"id,attr,omitempty"` // The ID of this element, which must be unique within the document scope.
}

// ElementLang with optional ID, xml:lang & dir.
type ElementLang struct {
Value string `xml:",chardata"`
ID string `xml:"id,attr,omitempty"` // The ID of this element, which must be unique within the document scope.
Dir string `xml:"dir,attr,omitempty"` // Specifies the base text direction of the content and attribute values of the carrying element and its descendants.
Lang string `xml:"xml:lang,attr,omitempty"` // Specifies the language used in the contents and attribute values of the carrying element and its descendants
}

// Metadata element encapsulates Publication meta information.
type Metadata struct {
DC string `xml:"xmlns:dc,attr"` // “http://purl.org/dc/elements/1.1/”
Expand All @@ -30,20 +44,6 @@ type Metadata struct {
Link []Link `xml:"link,omitempty"` // The link element is used to associate resources with a Publication, such as metadata records.
}

// Element with optional ID.
type Element struct {
ID string `xml:"id,attr,omitempty"` // The ID of this element, which must be unique within the document scope.
Value string `xml:",chardata"`
}

// ElementLang with optional ID, xml:lang & dir.
type ElementLang struct {
ID string `xml:"id,attr,omitempty"` // The ID of this element, which must be unique within the document scope.
Dir string `xml:"dir,attr,omitempty"` // Specifies the base text direction of the content and attribute values of the carrying element and its descendants.
Lang string `xml:"xml:lang,attr,omitempty"` // Specifies the language used in the contents and attribute values of the carrying element and its descendants
Value string `xml:",chardata"`
}

// AddTitle new publication title.
func (m *Metadata) AddTitle(name string) {
m.Title = append(m.Title, ElementLang{Value: name})
Expand Down
11 changes: 7 additions & 4 deletions mimetype.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
)

// MimeTypes list supported MIME types.
// MimeTypes list supported MIME types by file extension.
var MimeTypes = map[string]string{
".gif": "image/gif",
".jpg": "image/jpeg",
Expand Down Expand Up @@ -36,13 +36,16 @@ var MimeTypes = map[string]string{
}

// typeByName returns the MIME type associated with the file name.
func typeByName(filename string) (mimetype string) {
func typeByName(filename string) string {
ext := strings.ToLower(filepath.Ext(filename))
if mimetype = MimeTypes[ext]; mimetype != "" {

if mimetype, ok := MimeTypes[ext]; ok {
return mimetype
}
if mimetype = mime.TypeByExtension(ext); mimetype != "" {

if mimetype := mime.TypeByExtension(ext); mimetype != "" {
return mimetype
}

return "application/octet-stream"
}

0 comments on commit 6c78a28

Please sign in to comment.