Comments (5)
@olliephillips - I like the idea, and agree it would probably be very helpful for quickly getting addons and integrating them into the project.
Hows this for a modified version of your proposal:
# this would run: go get -u github.com/bosssauce/fbscheduler
# and copy that package into ./addons
$ ponzu add github.com/bosssauce/fbscheduler
This way the code completion will work straight away and the addon becomes vendored upon the next build.
I'm concerned that automatically adding _ imports to some file is a fix for behavior that I'm not sure we want to encourage.. will have to get more feedback on what the downside of this could be. My worry is that without explicitly importing the addon package somewhere, we open up ourselves to having to somehow determine if the _ import should be made (and is safe to do so), or add more API & documentation so the developer knows how to trigger this auto import..
I guess its a question of how much "magic" is going on which could end up causing more hurt than good. There is already one instance of this in cmd/ponzu
here: https://github.com/ponzu-cms/ponzu/blob/master/cmd/ponzu/main.go#L19 but it's truly necessary so that the whole system knows about content types - which are fundamental. Addons could have unexpected side-effects, like you mention.
What if we added a package to the top-level of Ponzu, similar to the following, and move the content package import there replacing the _ "content" import in cmd/ponzu with _ "startup" import:
startup/run.go
// Package startup is meant to serve as a place to import packages to trigger
// their initialization, start delayed workers, etc. `startup` is imported by the
// `cmd/ponzu` main package, and is run when the server starts up
package startup
import (
_ "github.com/ponzu-cms/ponzu/content"
_ "github.com/bosssauce/fbscheduler"
)
This offers a place to put addon initialization in the event that an addon isn't tied directly to any one content type, but keeps the auto-initialization explicit (and optional), which I have a feeling will avoid potential issues in the future. Upon building, this startup package would be copied into the vendor directory just like content...
from ponzu.
Yes, add
is better than get
. Much better. I'll have a stab at that feature if you can use - and not time critical?
Re auto-magically importing addons. Some of what you suggest I will have to digest in the morning - but generally, I think the Addon UX feels a bit odd having to trigger the import in code first, just to see the Addon admin suite in the dashboard.
from ponzu.
If you'd like to work on the feature, please go for it! And feel free to loop me in whenever needed. I'm typically in the #ponzu channel on this Slack if you'd like to join and discuss:
https://invite.slack.golangbridge.org
Take note that the CLI code changes should be made to the ponzu-cms/ponzu
package itself, not a project that you create with ponzu new
- and there are some contribution docs in the README. You'll need to run $ go install ./...
from the ponzu-cms/ponzu
package or if you fork it, from your own fork (then using the -fork
flag as shown in the README) - sorry if this is all obvious, just trying to leave notes wherever possible so others might find them if they are having trouble contributing.
I would also suggest familiarizing yourself with the copyAll
func here: https://github.com/ponzu-cms/ponzu/blob/master/cmd/ponzu/options.go#L334, as well as the various places it is called.. I think you'll probably want to use that when copying a go get
package into ./addons
- the build process should already account for anything added into ./addons
, but it will be something you'll want to verify manually.
re: addon auto _ imports.. I agree that it feels odd, and maybe we simply document the Addon API in such a way that strongly suggests addon developers only run the addon.Register
func in the addon package's init
func - and nothing else (unless they know exactly how it will impact the system). I do plan on creating a generator for addons, much like content, so $ ponzu gen addon ....
is a way to standardize this a bit.
If we can do that elegantly and practically, then I would feel much better about doing the auto _ import. Also, we will need to clearly document that the auto _ import only happens when using $ ponzu add ...
so there is no expectation of it happening when someone simply copy/pastes a package into ./addons
from ponzu.
Thanks, yes I'll look at this. My pleasure.
from ponzu.
Merged #87. Thank you!
from ponzu.
Related Issues (20)
- CLI is not working HOT 14
- Zap v11 was deleted HOT 14
- go module support HOT 9
- search sort HOT 2
- Custom databases HOT 3
- ponzu 0.11.0 fails to build HOT 2
- The "must" search operator in blevesearch can't be passed into ponzu HOT 1
- NOTICE: original author & maintainer is stepping away from the project HOT 7
- how to change to Summernote
- Redis Support for ponzu
- There is three CSRF vulnerability that can add the administrator account, delete administrator account, edit configuration.
- Only latest tag saving
- Error with "go get..." HOT 6
- Current state of Ponzu HOT 1
- Is this project still maintained? HOT 3
- Suggested install method no longer works HOT 2
- Is Ponzu dead? HOT 10
- Potential goroutine leak in achive.go
- How can you develop addons more efficiently?
- How to setup development env
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ponzu.