~adnano/kiln-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Fix post ordering by Weight, reversed Date and FilePath.

Details
Message ID
<20210518190016.27599-1-ian@ianmjones.com>
DKIM signature
missing
Download raw message
Patch: +11 -2
---
Thanks for adding reverse date ordering of posts Adnan.

However, it didn't work for me, looks like the sort isn't linear
enough. So the sorts need to be run one after the other starting
with the least important and using SortStable to keep progress.

Hope this makes sense. I'm very new to Go, so if there's a more
efficient way of doing this, please reject this patch!

Also, thanks so much for kiln, it's great stuff.

 dir.go | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/dir.go b/dir.go
index d903761..e3437b1 100644
--- a/dir.go
+++ b/dir.go
@@ -262,8 +262,17 @@ func (d *Dir) write(dstDir string, task *Task) error {
func (d *Dir) sort() {
	sort.Slice(d.Pages, func(i, j int) bool {
		pi, pj := d.Pages[i], d.Pages[j]
		return pi.Weight < pj.Weight || pi.Date.After(pj.Date) ||
			pi.FilePath < pj.FilePath
		return pi.FilePath < pj.FilePath
	})

	sort.SliceStable(d.Pages, func(i, j int) bool {
		pi, pj := d.Pages[i], d.Pages[j]
		return pi.Date.After(pj.Date)
	})

	sort.SliceStable(d.Pages, func(i, j int) bool {
		pi, pj := d.Pages[i], d.Pages[j]
		return pi.Weight < pj.Weight
	})

	for i := range d.Pages {
-- 
2.17.1
Details
Message ID
<CBGSPARH2F95.L1JTR5YS3I1U@nitro>
In-Reply-To
<20210518190016.27599-1-ian@ianmjones.com> (view parent)
DKIM signature
pass
Download raw message
Thanks!

To git@git.sr.ht:~adnano/kiln
   3667c41..820ab25  master -> master
Reply to thread Export thread (mbox)