Deleting Google Glass Timeline Items Using the Go Quick Start Project

(Note: This has been merged into the main project!)

A Google Glass user interacts with Glassware using timeline items, also known as cards. Currently the Quick Start Projects do not include a method for manually deleting these items, but the Mirror API does provide a way to do this.

I am developing Glassware using the Go (AKA golang) version of the Quick Start Project.

In the index.html file, I added a button using this block of code:

  • To this block:

              {{ range $item.Attachments }}
                {{ if HasPrefix .ContentType "image" }}
                
                {{ else }}
                Download
                {{ end }}
              {{ end }}
            
          
          {{ end }}
        

    Resulting in this comple block:

              {{ range $item.Attachments }}
                {{ if HasPrefix .ContentType "image" }}
                
                {{ else }}
                Download
                {{ end }}
              {{ end }}
            
            
  • {{ end }}

    Secondly, add this method to the main.go file:

    // deleteTimelineItem deletes a timeline item.
    func deleteTimelineItem(r *http.Request, svc *mirror.Service) string {
    itemId := r.FormValue(“itemId”)
    err := svc.Timeline.Delete(itemId).Do()
    if err != nil {
    return fmt.Sprintf(“An error occurred: %vn”, err)
    }
    return “A timeline item has been deleted.”
    }

    Lastly, add the last line to the block defining the operations variable in main.go, adding the deleteTimelineItem method:

    // Map of operations to functions.
    var operations = map[string]func(*http.Request, *mirror.Service) string{
    “insertSubscription”: insertSubscription,
    “deleteSubscription”: deleteSubscription,
    “insertItem”: insertItem,
    “insertItemWithAction”: insertItemWithAction,
    “insertItemAllUsers”: insertItemAllUsers,
    “insertContact”: insertContact,
    “deleteContact”: deleteContact,
    “deleteTimelineItem”: deleteTimelineItem,
    }

    Save the files and redeploy your project to AppEngine. Once your reload your application in the browser, a button will appear underneath each timeline item that will delete it!

    Loading Facebook Comments ...

    2 Replies to “Deleting Google Glass Timeline Items Using the Go Quick Start Project”

    %d bloggers like this: