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

Support an "expiration" date #726 #2137

Closed
wants to merge 15 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@g3wanghc
Contributor

g3wanghc commented May 10, 2016

First time using goLang and first time contribution. Please be gentle. :V

@CLAassistant

This comment has been minimized.

Show comment
Hide comment
@CLAassistant

CLAassistant May 10, 2016

CLA assistant check
All committers have signed the CLA.

CLAassistant commented May 10, 2016

CLA assistant check
All committers have signed the CLA.

@bep

View changes

Show outdated Hide outdated hugolib/site_test.go Outdated
@bep

View changes

Show outdated Hide outdated commands/hugo.go Outdated
@bep

View changes

Show outdated Hide outdated docs/content/commands/hugo.md Outdated
@bep

View changes

Show outdated Hide outdated docs/content/overview/configuration.md Outdated
@bep

View changes

Show outdated Hide outdated hugolib/page.go Outdated
@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc

g3wanghc May 10, 2016

Contributor

@bep What's a good way to make make check more verbose? I'm having trouble finding my formatting errors. 😢

Contributor

g3wanghc commented May 10, 2016

@bep What's a good way to make make check more verbose? I'm having trouble finding my formatting errors. 😢

@@ -467,7 +468,8 @@ func (p *Page) LinkTitle() string {
}
func (p *Page) ShouldBuild() bool {

This comment has been minimized.

@bep

bep May 10, 2016

Member

This method has gotten complex enough to deserve a refactor.

I would pull out a function (as in not a method) with:

  • buildFuture
  • buildExpired
  • buildDrafts
  • publishDate
  • expiryDate

I.e. no dependency on Page nor Viper, then create a table driven test for that function.

@bep

bep May 10, 2016

Member

This method has gotten complex enough to deserve a refactor.

I would pull out a function (as in not a method) with:

  • buildFuture
  • buildExpired
  • buildDrafts
  • publishDate
  • expiryDate

I.e. no dependency on Page nor Viper, then create a table driven test for that function.

This comment has been minimized.

@g3wanghc

g3wanghc May 12, 2016

Contributor

@bep Is what I'm doing correct or does it need more work? 😁

@g3wanghc

g3wanghc May 12, 2016

Contributor

@bep Is what I'm doing correct or does it need more work? 😁

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep May 10, 2016

Member

As to make and gofmt, the best is to actually do gfmting your code. But remember that make uses

gofmt -s (s = simplifies)

so gofmt -s -w thefile.go

Member

bep commented May 10, 2016

As to make and gofmt, the best is to actually do gfmting your code. But remember that make uses

gofmt -s (s = simplifies)

so gofmt -s -w thefile.go

@bep

View changes

Show outdated Hide outdated hugolib/site_test.go Outdated
@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc

g3wanghc May 11, 2016

Contributor

I had to fix my commit messages hehehe. :V

Contributor

g3wanghc commented May 11, 2016

I had to fix my commit messages hehehe. :V

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep May 19, 2016

Member

As to why this hasn't been merged. This looks perfectly fine, very good, and will be merged eventually. I have announced a kind-of freeze period before the 0.16 release, but that seems to drag out.

Member

bep commented May 19, 2016

As to why this hasn't been merged. This looks perfectly fine, very good, and will be merged eventually. I have announced a kind-of freeze period before the 0.16 release, but that seems to drag out.

@moorereason

View changes

Show outdated Hide outdated hugolib/page.go Outdated
@moorereason

View changes

Show outdated Hide outdated hugolib/page.go Outdated
@moorereason

View changes

Show outdated Hide outdated hugolib/page.go Outdated
@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc
Contributor

g3wanghc commented May 19, 2016

@moorereason

View changes

Show outdated Hide outdated hugolib/page.go Outdated
@moorereason

View changes

Show outdated Hide outdated hugolib/page_test.go Outdated
@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 9, 2016

Member

This looks good. I took it for a spin, and the vital parts looks fine, but the list expired lists all of my pages -- I have only one with expiredDate.

Member

bep commented Jun 9, 2016

This looks good. I took it for a spin, and the vital parts looks fine, but the list expired lists all of my pages -- I have only one with expiredDate.

@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc

g3wanghc Jun 10, 2016

Contributor

Oops, will fix it. :P

Contributor

g3wanghc commented Jun 10, 2016

Oops, will fix it. :P

@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc

g3wanghc Jun 13, 2016

Contributor

@bep Fixed the list, and a typo.

I've noticed something weird in replacePage on site.go.

func (s *Site) replacePage(page *Page) {
    // will find existing page that matches filepath and remove it
    s.removePage(page)
    s.addPage(page)
}

If the original page wasn't built, then it wouldn't be part of site.Pages.

If you've modified an unpublishedPage, replacePage will be called but removePage wouldn't do anything since it can't find it in site.Pages. addPage will be called and futureCount is increased by 1.

If you added a future publishDate to an existing Page in site.Pages, then removePage will decrease futureCount by -1, and addPage will increate futureCount by 1, resulting in a net gain of 0.

Therefore, Site stats after replacePage is called will always be wrong.

Should we just keep track a list of Pages on Site that aren't being built?

Contributor

g3wanghc commented Jun 13, 2016

@bep Fixed the list, and a typo.

I've noticed something weird in replacePage on site.go.

func (s *Site) replacePage(page *Page) {
    // will find existing page that matches filepath and remove it
    s.removePage(page)
    s.addPage(page)
}

If the original page wasn't built, then it wouldn't be part of site.Pages.

If you've modified an unpublishedPage, replacePage will be called but removePage wouldn't do anything since it can't find it in site.Pages. addPage will be called and futureCount is increased by 1.

If you added a future publishDate to an existing Page in site.Pages, then removePage will decrease futureCount by -1, and addPage will increate futureCount by 1, resulting in a net gain of 0.

Therefore, Site stats after replacePage is called will always be wrong.

Should we just keep track a list of Pages on Site that aren't being built?

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 13, 2016

Member

@g3wanghc create a separate issue for the stats counters.

Member

bep commented Jun 13, 2016

@g3wanghc create a separate issue for the stats counters.

@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc

g3wanghc Jun 13, 2016

Contributor

@bep Done. #2211

Contributor

g3wanghc commented Jun 13, 2016

@bep Done. #2211

@bep

This comment has been minimized.

Show comment
Hide comment
@bep

bep Jun 14, 2016

Member

Merged, solid work, thanks.

Member

bep commented Jun 14, 2016

Merged, solid work, thanks.

@bep bep closed this Jun 14, 2016

@g3wanghc

This comment has been minimized.

Show comment
Hide comment
@g3wanghc

g3wanghc Jun 14, 2016

Contributor

Awesome!

Contributor

g3wanghc commented Jun 14, 2016

Awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment