-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
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
Suggestion for solution #476. #810
Conversation
Hei og takk for sist! No har ein også #748 -- men løysinga di er både enkel og fleksibel mht. format. Det blir kanskje heller eit spørsmål om "globale data" eller data som høyrer til ei side. Kan du fjerne den utkommenterte seksjonen og gjere ein "push -f" (overskrive innsjekkinga di)? To others: Sorry about the nynorsk language. |
Verden er liten. ;) Første innsjekk er overskrevet. And to the english version... |
@@ -332,9 +373,10 @@ func (s *Site) initialize() (err error) { | |||
} | |||
|
|||
staticDir := helpers.AbsPathify(viper.GetString("StaticDir") + "/") | |||
dataDir := helpers.AbsPathify(viper.GetString("StaticDir") + "/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> DataDir
This should work and is simple enough, @spf13 ? It should support sub-folders, but that's simple to add. |
Looks really good. It's pretty much exactly like how I would do it (except it needs tests ;) ) . About sub directories, where would they appear? .Site.Data[subdir][filename] seems like the obvious place to me. |
@klakegg do you have any time to spare to take a stab at adding support for subfolders? There are examples of using the Also some tests would be cool! |
I think using Filesystem is better because of less duplication (symlinks) and included caching. Files in data/ are imported before data in subfolders allowing overriding using subfolders. |
Filesystem vs Walk, I don't care. But overriding in sub-folders will get confusing pretty fast.
Any thoughts @spf13 ? |
If /data/sub1/sub2.json sets key 'mydata.mykey' to 'foo', and you have a file /data/sub1/sub2/mydata.json setting 'mykey' to 'bar'. What to you expect .Site.Data.sub1.sub2.mydata to return? Btw, now also with test. ;) |
In that case I would expect /sub2/mydata.json's value, but that isn't override as a feature -- I would even consider returning an error for these duplicates so the user can do some renaming. |
Oh, and the failing test is most likely due to Go maps' random iteration order. |
The implementation is now changed to support any amount of subfolders. The test is still unstable (not changed) and will be updated if this is the solution we want. |
There is some spring code cleaning to be done here, but:
So, @spf13 - to sum up (with my special $ syntax):
It wold need documentation and tests, but from a bird's perspective, it looks correct, right? |
@bjornerik I don't follow the special $ syntax. Does that just mean the files content after it? I think we are heading in a very good direction. I think duplication should just log an ERROR. |
the $ syntax is just there to separate the file (my.json) with the key inside the file (mkey). It's just for this discussion and not part of any API. |
Ok. I think this looks really good. We should fix the tests, merge it, and add documentation. |
@klakegg could you fix/add some tests and doc? And replace the error-return with just ERROR logging |
@klakegg bump. It isn't that busy in the government :-) If this is going into the 0.13 release it needs docs/tests -- and I'm too lazy/busy doing it myself. |
OK, I need this one, so I'll finish it. |
Replaced by #885 |
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Reads files inside data/ and makes data available in .Site.Data. May need some refactoring.