Tl;dr
Source: https://github.com/olostan/gogaecms
Sources of web site for testing: https://github.com/olostan/test-website
Sources of web site for testing: https://github.com/olostan/test-website
Deployed app: http://gogaecms.appspot.com/
Background
Not so long ago I've starting digging into Go language and found it very attractive for server-side development. The reasons are:- It is fast ("near C performance")
- It is garbage collected
- Syntax is though little bit strange (comparable to Dart), but still quite easy to learn
- Easy to start
Also Go is supported by Google Apps Engine.
Speaking about performance, I should mention cost. If you're in "cloud", then you should think about "cost per request" - how much resources were used to serve request. So if application is faster, it should be cheaper in case if you're using real "cloud" platform, such as GAE that can automatically scale your application.
Speaking about performance, I should mention cost. If you're in "cloud", then you should think about "cost per request" - how much resources were used to serve request. So if application is faster, it should be cheaper in case if you're using real "cloud" platform, such as GAE that can automatically scale your application.
Also because Go in compiled language, instance startup is much faster then Java/Python.
The Idea
So if there is infrastructure for good scalable application, why not to create something generic that can use power of cloud platform? The idea was to create simple CMS (Content Management System), that:
- Would store its templates in DataStore. File names would be keys, so they could be easily fetched/updated
- Would store its data in DataStore (such as sections of the site, any other shared information)
- Would use memcache service for caching compiled templates
- Would use BlobStore for storing assets (images, etc)
- Would support "development" mode, where files could be fetched from local folder. In production, zip file with content is imported into datastore/blobstore.
Served Web Site structure
The "source" web site (web site, that users would see) will contain:
- Static assets (images, stylesheets)
- Templates (parsed by Go's html/template package
- Data - I've decided to make is simple, so it is just pure CSV files
Here is a test web site, that I've used when implemented this idea: https://github.com/olostan/test-website
As you can see, templates can include other templates:
Here should be another template: {{template "another.html"}}
Everything inside 'data' folder is available to template like {{range $index, $element := .}}
Implementation
Now there is very very ugly quick-and-dirty implementation I've wrote on a weekend: https://github.com/olostan/gogaecms
In case of update, ut fetch last version of test web site from GitHub, import it and serve.
Now code is totally not structured - I was focusing to make a workable proof of concept.
Deployed application you can find at: http://gogaecms.appspot.com/
Though it is really draft version, but at least it could be a starting point for implementing this idea.
ToDo
- Structure code
- Add administration panel
- To be able to upload any .zip file with web site structure
- Configure url of updating
- Generation of some random URL for updating to be able to configure github hook for updating web site
- On development server switch between file/datastore storage
- Add some simple way to modify templates/data
- Export to .zip file
- Make "development" and "production" more generic (introduce interfaces?)
No comments:
Post a Comment