Permalink
Browse files

many: support snap title as localized/title-cased name

  • Loading branch information...
robert-ancell authored and niemeyer committed Jun 29, 2017
1 parent 784b293 commit e77a3876d1570e68030c6f9b53a06cb5e555ea6c
Showing with 39 additions and 7 deletions.
  1. +1 −0 client/packages.go
  2. +4 −0 client/packages_test.go
  3. +2 −1 daemon/api_test.go
  4. +11 −1 daemon/snap.go
  5. +10 −0 snap/info.go
  6. +2 −0 snap/info_snap_yaml.go
  7. +2 −0 snap/info_snap_yaml_test.go
  8. +1 −0 store/store.go
  9. +6 −5 store/store_test.go
View
@@ -32,6 +32,7 @@ import (
// Snap holds the data for a snap as obtained from snapd.
type Snap struct {
ID string `json:"id"`
Title string `json:"title,omitempty"`
Summary string `json:"summary"`
Description string `json:"description"`
DownloadSize int64 `json:"download-size"`
View
@@ -106,6 +106,7 @@ func (cs *clientSuite) TestClientSnaps(c *check.C) {
"type": "sync",
"result": [{
"id": "funky-snap-id",
"title": "Title",
"summary": "salutation snap",
"description": "hello-world",
"download-size": 22212,
@@ -126,6 +127,7 @@ func (cs *clientSuite) TestClientSnaps(c *check.C) {
c.Check(err, check.IsNil)
c.Check(applications, check.DeepEquals, []*client.Snap{{
ID: "funky-snap-id",
Title: "Title",
Summary: "salutation snap",
Description: "hello-world",
DownloadSize: 22212,
@@ -171,6 +173,7 @@ func (cs *clientSuite) TestClientSnap(c *check.C) {
"type": "sync",
"result": {
"id": "funky-snap-id",
"title": "Title",
"summary": "bla bla",
"description": "WebRTC Video chat server for Snappy",
"download-size": 6930947,
@@ -200,6 +203,7 @@ func (cs *clientSuite) TestClientSnap(c *check.C) {
c.Assert(pkg, check.DeepEquals, &client.Snap{
ID: "funky-snap-id",
Summary: "bla bla",
Title: "Title",
Description: "WebRTC Video chat server for Snappy",
DownloadSize: 6930947,
Icon: "/v2/icons/chatroom.ogra/icon",
View
@@ -364,7 +364,7 @@ func (s *apiSuite) TestSnapInfoOneIntegration(c *check.C) {
// we have v0 [r5] installed
s.mkInstalledInState(c, d, "foo", "bar", "v0", snap.R(5), false, "")
// and v1 [r10] is current
s.mkInstalledInState(c, d, "foo", "bar", "v1", snap.R(10), true, "description: description\nsummary: summary\napps:\n cmd:\n command: some.cmd\n cmd2:\n command: other.cmd\n")
s.mkInstalledInState(c, d, "foo", "bar", "v1", snap.R(10), true, "title: title\ndescription: description\nsummary: summary\napps:\n cmd:\n command: some.cmd\n cmd2:\n command: other.cmd\n")
df := s.mkInstalledDesktopFile(c, "foo_cmd.desktop", "[Desktop]\nExec=foo.cmd %U")
req, err := http.NewRequest("GET", "/v2/snaps/foo", nil)
@@ -394,6 +394,7 @@ func (s *apiSuite) TestSnapInfoOneIntegration(c *check.C) {
"version": "v1",
"channel": "stable",
"tracking-channel": "beta",
"title": "title",
"summary": "summary",
"description": "description",
"developer": "bar",
View
@@ -200,7 +200,7 @@ func mapLocal(about aboutSnap) map[string]interface{} {
// TODO: expose aliases information and state?
return map[string]interface{}{
result := map[string]interface{}{
"description": localSnap.Description(),
"developer": about.publisher,
"icon": snapIcon(localSnap),
@@ -224,6 +224,12 @@ func mapLocal(about aboutSnap) map[string]interface{} {
"broken": localSnap.Broken,
"contact": localSnap.Contact,
}
if localSnap.Title() != "" {
result["title"] = localSnap.Title()
}
return result
}
func mapRemote(remoteSnap *snap.Info) map[string]interface{} {
@@ -264,6 +270,10 @@ func mapRemote(remoteSnap *snap.Info) map[string]interface{} {
"contact": remoteSnap.Contact,
}
if remoteSnap.Title() != "" {
result["title"] = remoteSnap.Title()
}
if len(screenshots) > 0 {
result["screenshots"] = screenshots
}
View
@@ -134,6 +134,7 @@ type SideInfo struct {
Revision Revision `yaml:"revision" json:"revision"`
Channel string `yaml:"channel,omitempty" json:"channel,omitempty"`
Contact string `yaml:"contact,omitempty" json:"contact,omitempty"`
EditedTitle string `yaml:"title,omitempty" json:"title,omitempty"`
EditedSummary string `yaml:"summary,omitempty" json:"summary,omitempty"`
EditedDescription string `yaml:"description,omitempty" json:"description,omitempty"`
Private bool `yaml:"private,omitempty" json:"private,omitempty"`
@@ -147,6 +148,7 @@ type Info struct {
Architectures []string
Assumes []string
OriginalTitle string
OriginalSummary string
OriginalDescription string
@@ -206,6 +208,14 @@ func (s *Info) Name() string {
return s.SuggestedName
}
// Title returns the blessed title for the snap.
func (s *Info) Title() string {
if s.EditedTitle != "" {
return s.EditedTitle
}
return s.OriginalTitle
}
// Summary returns the blessed summary for the snap.
func (s *Info) Summary() string {
if s.EditedSummary != "" {
View
@@ -37,6 +37,7 @@ type snapYaml struct {
Type Type `yaml:"type"`
Architectures []string `yaml:"architectures,omitempty"`
Assumes []string `yaml:"assumes"`
Title string `yaml:"title"`
Description string `yaml:"description"`
Summary string `yaml:"summary"`
LicenseAgreement string `yaml:"license-agreement,omitempty"`
@@ -154,6 +155,7 @@ func infoSkeletonFromSnapYaml(y snapYaml) *Info {
Type: typ,
Architectures: architectures,
Assumes: y.Assumes,
OriginalTitle: y.Title,
OriginalDescription: y.Description,
OriginalSummary: y.Summary,
LicenseAgreement: y.LicenseAgreement,
@@ -1053,6 +1053,7 @@ func (s *YamlSuite) TestUnmarshalComplexExample(c *C) {
info, err := snap.InfoFromSnapYaml([]byte(`
name: foo
version: 1.2
title: Foo
summary: foo app
type: app
epoch: 1*
@@ -1090,6 +1091,7 @@ slots:
c.Check(info.Type, Equals, snap.TypeApp)
c.Check(info.Epoch, Equals, "1*")
c.Check(info.Confinement, Equals, snap.DevModeConfinement)
c.Check(info.Title(), Equals, "Foo")
c.Check(info.Summary(), Equals, "foo app")
c.Check(info.Description(), Equals, "Foo provides useful services\n")
c.Check(info.Apps, HasLen, 2)
View
@@ -87,6 +87,7 @@ func infoFromRemote(d *snapDetails) *snap.Info {
info.RealName = d.Name
info.SnapID = d.SnapID
info.Revision = snap.R(d.Revision)
info.EditedTitle = d.Title
info.EditedSummary = d.Summary
info.EditedDescription = d.Description
info.PublisherID = d.DeveloperID
View
@@ -1569,7 +1569,7 @@ const MockDetailsJSON = `{
"snap_id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"summary": "The 'hello-world' of snaps",
"support_url": "mailto:snappy-devel@lists.ubuntu.com",
"title": "hello-world",
"title": "Hello World",
"version": "6.3",
"channel_maps_list": [
{
@@ -1648,7 +1648,7 @@ const MockDetailsJSONnoChannelMapList = `{
"snap_id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"summary": "The 'hello-world' of snaps",
"support_url": "mailto:snappy-devel@lists.ubuntu.com",
"title": "hello-world",
"title": "Hello World",
"version": "6.3"
}
`
@@ -1758,6 +1758,7 @@ func (t *remoteRepoTestSuite) TestUbuntuStoreRepositoryDetails(c *C) {
c.Check(result.Channel, Equals, "edge")
c.Check(result.Description(), Equals, "This is a simple hello world example.")
c.Check(result.Summary(), Equals, "The 'hello-world' of snaps")
c.Check(result.Title(), Equals, "Hello World")
c.Assert(result.Prices, DeepEquals, map[string]float64{"EUR": 0.99, "USD": 1.23})
c.Assert(result.Screenshots, DeepEquals, []snap.ScreenshotInfo{
{
@@ -2212,7 +2213,7 @@ const MockSearchJSON = `{
"snap_id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"summary": "Hello world example",
"support_url": "mailto:snappy-devel@lists.ubuntu.com",
"title": "hello-world",
"title": "Hello World",
"version": "6.0"
}
]
@@ -2671,7 +2672,7 @@ var MockUpdatesJSON = `
"snap_id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"summary": "Hello world example",
"support_url": "mailto:snappy-devel@lists.ubuntu.com",
"title": "hello-world",
"title": "Hello World",
"version": "6.1"
}
]
@@ -3382,7 +3383,7 @@ var MockUpdatesWithDeltasJSON = `
"snap_id": "buPKUD3TKqCOgLEjjHx5kSiCpIs5cMuQ",
"summary": "Hello world example",
"support_url": "mailto:snappy-devel@lists.ubuntu.com",
"title": "hello-world",
"title": "Hello World",
"version": "6.1",
"deltas": [{
"from_revision": 24,

0 comments on commit e77a387

Please sign in to comment.