Skip to content

Commit

Permalink
Rename all badge-uri to badge-path
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasgarnier committed Apr 8, 2020
1 parent fb1b4f5 commit 9ef1b69
Show file tree
Hide file tree
Showing 7 changed files with 331 additions and 330 deletions.
8 changes: 4 additions & 4 deletions claat/parser/md/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
// Metadata constants for the YAML header
const (
MetaAuthors = "authors"
MetaBadgeURI = "badge uri"
MetaBadgePath = "badge path"
MetaSummary = "summary"
MetaID = "id"
MetaCategories = "categories"
Expand Down Expand Up @@ -365,9 +365,9 @@ func addMetadataToCodelab(m map[string]string, c *types.Codelab, opts parser.Opt
case MetaAuthors:
// Directly assign the summary to the codelab field.
c.Authors = v
case MetaBadgeURI:
// Directly assign the badge URI to the codelab field.
c.BadgeURI = v
case MetaBadgePath:
// Directly assign the badge Path to the codelab field.
c.BadgePath = v
case MetaSummary:
// Directly assign the summary to the codelab field.
c.Summary = v
Expand Down
8 changes: 4 additions & 4 deletions claat/parser/newmd/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
// Metadata constants for the YAML header
const (
MetaAuthors = "authors"
MetaBadgeURI = "badge uri"
MetaBadgePath = "badge path"
MetaSummary = "summary"
MetaID = "id"
MetaCategories = "categories"
Expand Down Expand Up @@ -362,9 +362,9 @@ func addMetadataToCodelab(m map[string]string, c *types.Codelab, opts parser.Opt
case MetaAuthors:
// Directly assign the summary to the codelab field.
c.Authors = v
case MetaBadgeURI:
// Directly assign the badge URI to the codelab field.
c.BadgeURI = v
case MetaBadgePath:
// Directly assign the badge Path to the codelab field.
c.BadgePath = v
case MetaSummary:
// Directly assign the summary to the codelab field.
c.Summary = v
Expand Down
4 changes: 2 additions & 2 deletions claat/render/template-devsite.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@
title="{{.Meta.Title}}"
environment="{{index .Env}}"
feedback-link="{{.Meta.Feedback}}"
{{if $.Meta.BadgeURI}}badge-uri="{{$.Meta.BadgeURI}}"{{end}}>
{{if $.Meta.BadgePath}}badge-path="{{$.Meta.BadgePath}}"{{end}}>
{{range $i, $e := .Steps}}{{if matchEnv .Tags $.Env}}
<google-codelab-step label="{{.Title}}" duration="{{.Duration.Minutes}}">
{{if eq $i 0}}
<google-codelab-about codelab-title="{{$.Meta.Title}}"
{{if $.Updated}}last-updated="{{$.Updated}}"{{end}}
{{if $.Meta.Authors}}authors="{{$.Meta.Authors}}"{{end}}
{{if $.Meta.BadgeURI}}badge-uri="{{$.Meta.BadgeURI}}"{{end}}>
{{if $.Meta.BadgePath}}badge-path="{{$.Meta.BadgePath}}"{{end}}>
</google-codelab-about>
{{end}}
{{.Content | renderHTML $.Env}}
Expand Down
595 changes: 298 additions & 297 deletions claat/render/tmpldata.go

Large diffs are not rendered by default.

28 changes: 14 additions & 14 deletions claat/types/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ import (

// Meta contains a single codelab metadata.
type Meta struct {
ID string `json:"id"` // ID is also part of codelab URL
Duration int `json:"duration"` // Codelab duration in minutes
Title string `json:"title"` // Codelab title
Authors string `json:"authors,omitempty"` // Arbitrary authorship text
BadgeURI string `json:"badge_uri,omitempty"` // URI of the Badge to grant on codelab completion on devsite
Summary string `json:"summary"` // Short summary
Source string `json:"source"` // Codelab source doc
Theme string `json:"theme"` // Usually first item of Categories
Status *LegacyStatus `json:"status"` // Draft, Published, Hidden, etc.
Categories []string `json:"category"` // Categories from the meta table
Tags []string `json:"tags"` // All environments supported by the codelab
Feedback string `json:"feedback,omitempty"` // Issues and bugs are sent here
GA string `json:"ga,omitempty"` // Codelab-specific GA tracking ID
Extra map[string]string `json:"extra,omitempty"` // Extra metadata specified in pass_metadata
ID string `json:"id"` // ID is also part of codelab URL
Duration int `json:"duration"` // Codelab duration in minutes
Title string `json:"title"` // Codelab title
Authors string `json:"authors,omitempty"` // Arbitrary authorship text
BadgePath string `json:"badge_path,omitempty"` // Path of the Badge to grant on codelab completion on devsite
Summary string `json:"summary"` // Short summary
Source string `json:"source"` // Codelab source doc
Theme string `json:"theme"` // Usually first item of Categories
Status *LegacyStatus `json:"status"` // Draft, Published, Hidden, etc.
Categories []string `json:"category"` // Categories from the meta table
Tags []string `json:"tags"` // All environments supported by the codelab
Feedback string `json:"feedback,omitempty"` // Issues and bugs are sent here
GA string `json:"ga,omitempty"` // Codelab-specific GA tracking ID
Extra map[string]string `json:"extra,omitempty"` // Extra metadata specified in pass_metadata

URL string `json:"url"` // Legacy ID; TODO: remove
}
Expand Down
12 changes: 6 additions & 6 deletions codelab-elements/google-codelab-about/google_codelab_about.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const LAST_UPDATED_ATTR = 'last-updated';
const AUTHORS_ATTR = 'authors';

/** @const {string} */
const BADGE_URI_ATTR = 'badge-uri';
const BADGE_PATH_ATTR = 'badge-path';

/** @const {string} */
const CODELAB_TITLE_ATTR = 'codelab-title';
Expand Down Expand Up @@ -57,7 +57,7 @@ class CodelabAbout extends HTMLElement {
this.lastUpdated_ = null;

/** @private {?string} */
this.badgeUri_ = null;
this.badgePath_ = null;
}

/**
Expand Down Expand Up @@ -103,9 +103,9 @@ class CodelabAbout extends HTMLElement {
this.codelabTitle_ = this.getAttribute(CODELAB_TITLE_ATTR);
}
break;
case BADGE_URI_ATTR:
if (this.hasAttribute(BADGE_URI_ATTR)) {
this.badgeUri_ = this.getAttribute(BADGE_URI_ATTR);
case BADGE_PATH_ATTR:
if (this.hasAttribute(BADGE_PATH_ATTR)) {
this.badgePath_ = this.getAttribute(BADGE_PATH_ATTR);
}
break;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ class CodelabAbout extends HTMLElement {
lastUpdated: CodelabAbout.formatDate_(this.lastUpdated_),
authors: this.authors_,
codelabTitle: this.codelabTitle_.split(':').join(':||').split('||'),
badgeUri: this.badgeUri_,
badgePath: this.badgePath_,
});

this.hasSetup_ = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
{@param? codelabTitle: list<string>}
{@param? lastUpdated: string}
{@param? authors: string}
{@param? badgeUri: string}
{@param? badgePath: string}

{if $codelabTitle}
<div class="codelab-title">
Expand Down Expand Up @@ -57,8 +57,8 @@
{/if}
</div>

{if $badgeUri}
<devsite-badge-to-earn badge-uri="$badgeUri"></devsite-badge-to-earn>
{if $badgePath}
<devsite-badge-to-earn badge-uri="$badgePath"></devsite-badge-to-earn>
{/if}
</div>
{/template}

0 comments on commit 9ef1b69

Please sign in to comment.