Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BaseUrl vs BaseURL, DocumentId vs DocumentID etc. #959

Closed
bep opened this issue Mar 7, 2015 · 17 comments
Closed

BaseUrl vs BaseURL, DocumentId vs DocumentID etc. #959

bep opened this issue Mar 7, 2015 · 17 comments

Comments

@bep
Copy link
Member

bep commented Mar 7, 2015

The most important thing is being consequent, and that looks good - but Golint suggests using all caps for these abbreviations:

http://goreportcard.com/report/spf13/hugo

I guess the only reason to to lowercase these is in languages with automated getter/setter generation (read Java).

Fix it or let it be?

@bep bep added the discussion label Mar 7, 2015
@anthonyfok
Copy link
Member

I think it would be fun and great to fix it. 😄

But let's hear from others too. Perhaps @spf13 could chime in? 😉

@spf13
Copy link
Contributor

spf13 commented Mar 10, 2015

I would follow golint's suggestion on those. I think that the all caps as show reads best. How much would this impact users?

@bep
Copy link
Member Author

bep commented Mar 10, 2015

I would say "very little impact" on users, but I'm not totally sure.

But it's better to do it now than kick ourselves in the legs later on.

If @anthonyfok can do the work (suggest using an IDE with a rename function, like liteide) and do it in a pull request, then we can do some testing and see if we have to put in a temporary "alias or two".

@anthonyfok anthonyfok self-assigned this Mar 11, 2015
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Mar 11, 2015
First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing gohugoio#959.
@anthonyfok
Copy link
Member

Hi all,

This is the first Pull Request (#969) that I came up with. This should be rather safe, as I purposely avoided the command-line flags (cobra and pflag?) as well as struct fields like BaseUrl and Url that are used in Go HTML templates, to avoid breaking compatibility with existing scripts.

Creating aliases for template functions are as simple as adding an extra entry to the FuncMap, e.g. GetJson and GetJSON both work. But what about template struct fields?

And, in addition to --baseUrl=http://example.com/', do we want to support--baseURLand--baseurl` too? Or should we make these long flag names case-insensitive? (Or not?)

Many thanks!

@anthonyfok anthonyfok removed their assignment Mar 11, 2015
@anthonyfok anthonyfok added this to the v0.14 milestone Mar 11, 2015
@spf13
Copy link
Contributor

spf13 commented Mar 11, 2015

I think all flag names should be case insensitive personally.

@anthonyfok
Copy link
Member

Great minds think alike! 😉 <grin, duck, run>

Does that mean we need to patch https://github.com/spf13/pflag?
(I took a quick grep ("upper", "lower", "sensi") and didn't find anything in the upstream https://github.com/ogier/pflag either.)

@spf13
Copy link
Contributor

spf13 commented Mar 11, 2015

Correct.

Steve Francia
spf13.com
@spf13

On Mar 11, 2015, at 2:02 PM, Anthony Fok notifications@github.com wrote:

Great minds think alike!

Does that mean we need to patch https://github.com/spf13/pflag?
(I took a quick grep ("upper", "lower", "sensi") and didn't find anything in the upstream https://github.com/ogier/pflag either.)


Reply to this email directly or view it on GitHub.

anthonyfok added a commit that referenced this issue Mar 11, 2015
First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing #959.
@bep
Copy link
Member Author

bep commented Mar 11, 2015

I have boldly merged the PR. Looked and tested OK by me.

As to the template funcs (getCsv, getCSV) I suggest add a "deprecated decorator func" that logs an error (so it shows up) that says: Fix this, this will be removed in the next version.

mohae pushed a commit to mohae/hugo that referenced this issue Mar 15, 2015
Fixes gohugoio#922

add finalize command and tests to change draft status of specified content to false and set date to Now()

undraft command

Allow hyphens in shortcode name

Fixes gohugoio#929

Keep trailing slash when baseUrl contains a sub path

Before this commit, .Site.BaseUrl ended up as:

http://mysite.com/ => http://mysite.com/
http://mysite.com/sub/ => http://mysite.com/sub

Now it becomes:

http://mysite.com/ => http://mysite.com/
http://mysite.com/sub/ => http://mysite.com/sub/

Fixed gohugoio#931

Improve error message on missing shortcode inner content

Fixes gohugoio#933

Allow the same shortcode to  be used with or without inline content

Fixes gohugoio#934

Update Readme.md with additional contribution guides

Added Gitter badge

Restructure top of Readme.md

Fixing image in readme

Using a smaller Header Image

Tidying the Readme a bit more

Update github-pages-blog.md

change `hugo serve` to `hugo server`

Add benchmark for the shortcode lexer

Apply gofmt -s

Avoid panic when pagination on 0 pages

Fixes gohugoio#948

Prevent 404.html from prettifying into 404/index.html

Restore @realchaseadams's commit 348e123
"Force `UglyUrls` option to force `404.html` file name"
which got lost after some refactoring (commit 8db3c0b).

Remove the equivalent "force `UglyUrls`" code for `sitemap.xml`
because the refactored code now calls `renderAndWriteXML()`
which uses `WriteDestFile()` which does not prettify a filename.

Fixes gohugoio#939

Fix errors reported by Go Vet

Fix some Go Lint errors

Apply some more Golint suggestions

helpers: apply some Golint rules

author: fix doc

hugolib: apply some Hugolint rules

page: make receiver name on Page methods consistent

Apply some Golint rules on Page, esp. making the method receiver names consistent:

(page *Page) ==> (p *Page)

menu: make receiver name on Page methods consistent

Apply some Golint rules on Menu, esp. making the method receiver names consistent.

hugolib: apply some more Golint rules

source: apply some Golint rules

livereload: apply some Golint rules

parser: apply some Golint rules

There is only one s.PageTarget() - so we cannot change it, even tempoararily. We have to find another solution to this.
...

Prevent 404.html from prettifying into 404/index.html

Restore @realchaseadams's commit 348e123
"Force `UglyUrls` option to force `404.html` file name"
which got lost after some refactoring (commit 8db3c0b).

Remove the equivalent "force `UglyUrls`" code for `sitemap.xml`
because the refactored code now calls `renderAndWriteXML()`
which uses `WriteDestFile()` which does not prettify a filename.

Fixes gohugoio#939 (reverted from commit c4c19ad)

Handle 404 thread safely

Replaces hack that temporarily changes a global flag.

Fixes gohugoio#955
Fixes gohugoio#939

Fix UglyUrls on Windows

Fixes gohugoio#958

Fix eq and ne tpl function issue

`eq` and `ne` template functions don't work as expected when those are
used with a raw number and a calculated value by add, sub etc. It's
caused by both numbers type differences. For example, `eq 5 (add 2 3)`
returns `false` because raw 5 is `int` while `add 2 3` returns 5 with
`int64`

This normalizes `int`, `uint` and `float` type values to `int64`,
`uint64` and `float64` before comparing them. Other type of value is
passed to comparing function without any changes.

Fix gohugoio#961

Add test cases for Ne and Eq type normalisation

See gohugoio#961

Add new min_version field to theme.toml template

Switch from fsnotify.v0 to fsnotify.v1 API (watcher)

Fixes gohugoio#357
See also gohugoio#761

Do not parse backup files with trailing '~' as templates

Fixes gohugoio#964

absurlreplacer: write replacements directly to the byte buffer

The extra step isn't needed and this makes the code simpler.

And slightly faster:

benchmark              old ns/op     new ns/op     delta
BenchmarkAbsUrl        19987         17498         -12.45%
BenchmarkXmlAbsUrl     10606         9503          -10.40%

benchmark              old allocs     new allocs     delta
BenchmarkAbsUrl        28             24             -14.29%
BenchmarkXmlAbsUrl     14             12             -14.29%

benchmark              old bytes     new bytes     delta
BenchmarkAbsUrl        3512          3297          -6.12%
BenchmarkXmlAbsUrl     2059          1963          -4.66%

parser: add some frontmatter test cases

Skip directories like node_modules from the watchlist

A local `node_modules` directory can easily contain
tens of thousands of files, easily exhausting the tiny
default max open files limit especially on OS X Yosemite,
in spite of the fact that  Hugo already had code in place
since February 2014 to try to raise the maxfiles ulimit.

Also skip `.git` and `bower_components` directories.

The file watching situation will improve when
https://github.com/go-fsnotify/fsevents become ready,
but until then, we will be thrifty.  :-)

Thanks to @chibicode for the suggestion.

See gohugoio#168 for continued discussions.

Add some basic tests for doArithmetic

We might have to take precision into account for floating point nubers ... at some point.

doArithmetic: add test for division by zero

Correct initialisms as suggested by golint

First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing gohugoio#959.

Remove trailing space from site build statistics

Update press coverage: Fix URL; new tutorial in Chinese

[Docs] Update and expand http://gohugo.io/overview/usage/

The `hugo help` output as shown in http://gohugo.io/overview/usage/
was not yet updated for v0.13. Thanks to @alebaffa for the heads up!

Also:
 - Clarify that, after using `hugo server`, the bare `hugo` command
   need to be run before deployment.
 - Add a section on running `hugo` as production web server,
   and add links to two blog posts of two Hugo users sharing
   their experience.

Partially fixes: gohugoio#852 and gohugoio#937

Add deprecated logger

Add double checking in Deprecated

To prevent possible duplicate log statements.

source: add some test cases for File

Do not ERROR-log missing /data dir

Fixes gohugoio#930

Experimental AsciiDoc support with external helpers

See gohugoio#470

 * Based on existing support for reStructuredText files

 * Handles content files with extensions `.asciidoc` and `.ad`

 * Pipes content through `asciidoctor --safe -`.
   If `asciidoctor` is not installed, then `asciidoc --safe -`.

 * To make sure `asciidoctor` or `asciidoc` is found, after adding
   a piece of AsciiDoc content, run `hugo` with the `-v` flag
   and look for this message:

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

Caveats:

 * The final "Last updated" timestamp is currently not stripped.

 * When `hugo` is run with `-v`, you may see a lot of these messages

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

   if you have lots of `*.ad`, `*.adoc` or `*.asciidoc` files.

 * Some versions of `asciidoc` may have trouble with its safe mode.
   To test if you are affected, try this:

        $ echo "Hello" | asciidoc --safe -
        asciidoc: ERROR: unsafe: ifeval invalid
        asciidoc: FAILED: ifeval invalid safe document

   If so, I recommend that you install `asciidoctor` instead.

Feedback and patches welcome!

Ideally, we should be using https://github.com/VonC/asciidocgo,
@VonC's wonderful Go implementation of Asciidoctor.  However,
there is still a bit of work needed for asciidocgo to expose
its API so that Hugo can actually use it.

Until then, hope this "experimental AsciiDoc support through external
helpers" can serve as a stopgap solution for our community. :-)

2015-01-30: Updated for the replaceShortcodeTokens() syntax change
2015-02-21: Add `.adoc` extension as suggested by @Fale

Conflicts:
	helpers/content.go

Add Seq template func

Very similar to GNU's seq.

Fixes gohugoio#552

Conflicts:
	tpl/template.go

Added image support to the sitemap.xml template

Conflicts:
	tpl/template_embedded.go

Revert "Added image support to the sitemap.xml template"

This reverts commit 3c147bd.

Fixes gohugoio#972

removed duplicate word in readme

delete finalize files
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Mar 18, 2015
Thanks to @bep's new, brilliant helpers.Deprecated() function,
the following functions or variables are transitioned to their
new names, preserving backward compatibility for v0.14
and warning the user of upcoming obsolescence in v0.15:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * .Site.Indexes → .Site.Taxonomies
 * .Site.Recent → .Site.Pages
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Also fix related initialisms in strings and comments.

Continued effort in fixing gohugoio#959.
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Mar 18, 2015
In particular:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Continued effort in fixing gohugoio#959.
anthonyfok added a commit that referenced this issue Mar 18, 2015
Thanks to @bep's new, brilliant helpers.Deprecated() function,
the following functions or variables are transitioned to their
new names, preserving backward compatibility for v0.14
and warning the user of upcoming obsolescence in v0.15:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * .Site.Indexes → .Site.Taxonomies
 * .Site.Recent → .Site.Pages
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Also fix related initialisms in strings and comments.

Continued effort in fixing #959.
anthonyfok added a commit that referenced this issue Mar 18, 2015
In particular:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Continued effort in fixing #959.
@eparis
Copy link

eparis commented Aug 15, 2015

I pay attention in spf13/pflag, but rarely in ogier, since that repo is typically dead. But we already have support for this! (Well you can already do it)

Since you are using hugo (which I believe in turn uses spf13/cobra and spf13/pflag) you can check out the "normalized name" support. It allows you to write your own custom function which in your case could translate all flags to lowercase.

https://github.com/spf13/cobra/blob/master/command.go#L158
https://github.com/spf13/pflag/blob/master/flag.go#L184

It is being used in kubernetes to turn flags_like_this into flags-like-this so we have a consistent -

@eparis
Copy link

eparis commented Aug 15, 2015

@bep
Copy link
Member Author

bep commented Aug 22, 2015

@anthonyfok ^

anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 9, 2015
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue gohugoio#959
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 9, 2015
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 9, 2015
@anthonyfok
Copy link
Member

Thanks for the heads up, @bep.

And special thanks to @eparis for writing the "normalized name" feature in Cobra, and for showing us how it is used. :-)

I have made a preliminary Pull Request #1415, adding helpers.NormalizeHugoFlagsFunc() to handle flag name changes. I initially thought of making all long flags case-insensitive with the help of strings.ToLower(), but then it would turn all long flags into lowercase, e.g. --buildDrafts, --pluralizeListTitles etc. becoming --builddrafts, --pluralizelisttitles, making them harder to read and less pretty.

So, I have decided to be more conservative with this pull request, i.e. only allowing --baseUrl in addition to the new canonical --baseURL, and disallowing other variations like --baseurl and --BASEURL. If we relax the rules too much now, it would be hard to tighten the rules again without breaking end users' scripts.

If PR#1415 needs improvement, please do not hesitate to let me know. For example, I wondered if helpers/general.go were the right place to add the helpers.NormalizeHugoFlagsFunc(), etc. etc.

Once PR #1415 or its iteration is committed, there are two more patches that I would like to commit:

  1. Complete the Url-to-URL transition in tests: anthonyfok/hugo@d7f2ec3
  2. Complete the Url-to-URL transition in docs: anthonyfok/hugo@d793ad0

What do you think?

anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 13, 2015
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue gohugoio#959
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 13, 2015
anthonyfok added a commit to anthonyfok/hugo that referenced this issue Sep 13, 2015
@anthonyfok anthonyfok modified the milestones: v0.15, v0.14 Sep 16, 2015
@anthonyfok
Copy link
Member

I think we have accomplished the goals originally set out for this issue. Let's close it! :-)

bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue gohugoio#959
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
bramp pushed a commit to bramp/hugo that referenced this issue Dec 17, 2015
anthonyfok added a commit that referenced this issue Mar 21, 2016
To be consistent with the changes made in commit 67df33f, see #959.
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
First step to use initialisms that golint suggests,
for example:

    Line 116: func GetHtmlRenderer should be GetHTMLRenderer

as see on http://goreportcard.com/report/spf13/hugo

Thanks to @bep for the idea!

Note that command-line flags (cobra and pflag)
as well as struct fields like .BaseUrl and .Url
that are used in Go HTML templates need more work
to maintain backward-compatibility, and thus
are NOT yet dealt with in this commit.

First step in fixing gohugoio#959.
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
Thanks to @bep's new, brilliant helpers.Deprecated() function,
the following functions or variables are transitioned to their
new names, preserving backward compatibility for v0.14
and warning the user of upcoming obsolescence in v0.15:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * .Site.Indexes → .Site.Taxonomies
 * .Site.Recent → .Site.Pages
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Also fix related initialisms in strings and comments.

Continued effort in fixing gohugoio#959.
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
In particular:

 * .Url → .URL (for node, menu and paginator)
 * .Site.BaseUrl → .Site.BaseURL
 * getJson → getJSON
 * getCsv → getCSV
 * safeHtml → safeHTML
 * safeCss → safeCSS
 * safeUrl → safeURL

Continued effort in fixing gohugoio#959.
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
It currently handles --baseUrl to --baseURL, and --uglyUrls to --uglyURLs.

Special thanks to Eric Paris (@eparis) for writing the
"normalized name" support in Cobra, and for showing us
how it is used in Kubernetes.

See Issue gohugoio#959
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
tychoish pushed a commit to tychoish/hugo that referenced this issue Aug 13, 2017
To be consistent with the changes made in commit 67df33f, see gohugoio#959.
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants