Skip to content

Commit

Permalink
Make "custom domain" available for everyone
Browse files Browse the repository at this point in the history
No real reason to keep it behind a plan; will switch to 100% metered
usage soon anyway.
  • Loading branch information
arp242 committed Feb 16, 2022
1 parent 19c1dac commit 8e27a7c
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 45 deletions.
3 changes: 0 additions & 3 deletions handlers/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,6 @@ func (h settings) mainSave(w http.ResponseWriter, r *http.Request) error {
site := Site(r.Context())
site.Settings = args.Settings
site.LinkDomain = args.LinkDomain
if args.Cname != "" && !site.PlanCustomDomain(r.Context()) {
return guru.New(http.StatusForbidden, T(r.Context(), "notify/need-business-plan-custom-domain|need a business plan to set custom domain"))
}

makecert := false
if args.Cname == "" {
Expand Down
3 changes: 0 additions & 3 deletions handlers/vcounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,6 @@ func (h vcounter) counter(w http.ResponseWriter, r *http.Request) error {
noBranding = r.URL.Query().Get("no_branding") != ""
style = r.URL.Query().Get("style")
)
if !site.PlanCustomDomain(r.Context()) {
noBranding = false
}

var (
rng ztime.Range
Expand Down
6 changes: 0 additions & 6 deletions site.go
Original file line number Diff line number Diff line change
Expand Up @@ -614,12 +614,6 @@ func (s Site) LinkDomainURL(withProto bool, paths ...string) string {
return strings.TrimRight(s.LinkDomain, "/") + path.Join(paths...)
}

// PlanCustomDomain reports if this site's plan allows custom domains.
func (s Site) PlanCustomDomain(ctx context.Context) bool {
account := MustGetAccount(ctx)
return account.Plan == PlanStarter || account.Plan == PlanBusiness || account.Plan == PlanBusinessPlus
}

// IDOrParent gets this site's ID or the parent ID if that's set.
func (s Site) IDOrParent() int64 {
if s.Parent != nil {
Expand Down
6 changes: 0 additions & 6 deletions tpl/_pricing.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
<li>Unlimited sites</li>
<li>100k pageviews/month</li>
<li>4.8M maximum pageviews</li>
<li>Custom domain</li>
<li class="empty">&nbsp;</li>
</ul>
{{if .Site}}</label>{{else}}</div>{{end}}

Expand All @@ -42,8 +40,6 @@
<li>Unlimited sites</li>
<li>500k pageviews/month</li>
<li>24M maximum pageviews</li>
<li>Custom domain</li>
<li class="empty">&nbsp;</li>
</ul>
{{if .Site}}</label>{{else}}</div>{{end}}

Expand All @@ -58,8 +54,6 @@
<li>Unlimited sites</li>
<li>1M pageviews/month</li>
<li>Unlimited total pageviews</li>
<li>Custom domain</li>
<li>Phone support</li>
</ul>
{{if .Site}}</label>{{else}}</div>{{end}}
{{if .Site}}</span></fieldset>{{else}}</div>{{end}}
2 changes: 0 additions & 2 deletions tpl/help/faq.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ Then update the GoatCounter settings with your custom domain. It might take a
few hours for everything to work. <code>mine.{{.Domain}}</code> will continue to
work.<br><br>

You will need a Business plan to set up a custom domain.<br><br>

<em>Note that Custom domains will not prevent adblockers from recognizing
GoatCounter; it’s only intended as a “vanity domain”.</em>
</dd>
Expand Down
41 changes: 16 additions & 25 deletions tpl/settings_main.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,39 +63,30 @@

{{if .GoatcounterCom}}
<label for="cname">{{.T "label/custom-domain|Custom domain"}}</label>
<input type="text" name="cname" id="cname" value="{{if .Site.Cname}}{{.Site.Cname}}{{end}}"
{{if not (.Site.PlanCustomDomain .Context)}}disabled{{end}}>
<input type="text" name="cname" id="cname" value="{{if .Site.Cname}}{{.Site.Cname}}{{end}}" disabled>
<span>{{.T `help/custom-domain|
Custom domain, e.g. <em>“stats.example.com”</em>.
<strong>Note:</strong> This <em>won’t</em> prevent most
adblockers from blocking GoatCounter, and is just intended
as a nice “vanity domain”.
`}}<br><br>

{{if not (.Site.PlanCustomDomain .Context)}}
{{.T `help/custom-domain-plan|
Requires Personal Plus or Business plan (you’re on the %(plan) plan; see %[%link billing]).` (map
"plan" .Site.Plan
"link" (tag "a" `href="/billing"`)
{{if .Site.CnameSetupAt}}
{{.T "help/custom-domain-verified|Domain verified and set up (note: it may take up to an hour for the certificate to work)."}}
{{else if .Site.Cname}}
{{.T `help/custom-domain-error|
%[%error Not yet verified]; set a CNAME record to <code>%(domain)</code> – %[%docs detailed instructions].
The verification runs every 2 hours.` (map
"domain" ""
"error" (tag "span" `style="color: red;"`)
"docs" (tag "a"
`href="https://www.goatcounter.com/help#custom-domain" target="_blank"`)
)}}
{{else}}
{{if .Site.CnameSetupAt}}
{{.T "help/custom-domain-verified|Domain verified and set up (note: it may take up to an hour for the certificate to work)."}}
{{else if .Site.Cname}}
{{.T `help/custom-domain-error|
%[%error Not yet verified]; set a CNAME record to <code>%(domain)</code> – %[%docs detailed instructions].
The verification runs every 2 hours.` (map
"domain" ""
"error" (tag "span" `style="color: red;"`)
"docs" (tag "a"
`href="https://www.goatcounter.com/help#custom-domain" target="_blank"`)
)}}
{{else}}
{{.T `help/custom-domain-cname|Set a CNAME record to <code>%(domain)</code> – %[%docs detailed instructions].` (map
"docs" (tag "a" `href="https://www.goatcounter.com/help#custom-domain" target="_blank"`)
"domain" (printf "%s.%s" .Site.Code .Domain))}}
{{end}}
{{end}}</span>
{{.T `help/custom-domain-cname|Set a CNAME record to <code>%(domain)</code> – %[%docs detailed instructions].` (map
"docs" (tag "a" `href="https://www.goatcounter.com/help#custom-domain" target="_blank"`)
"domain" (printf "%s.%s" .Site.Code .Domain))}}
{{end}}
</span>
{{else}}
<label for="cname">{{.T "label/goatcounter-domain|GoatCounter domain"}}</label>
<input type="text" name="cname" id="cname" value="{{if .Site.Cname}}{{.Site.Cname}}{{end}}">
Expand Down

0 comments on commit 8e27a7c

Please sign in to comment.