Friday, November 21, 2014

Re: Obtaining content from Git

I'm not aware of any such module, but there are a few python 'git'
modules for reading/writing, etc...

As for how much trouble it would be, that all depends on how familiar
you are with git, python, Django, and the template system.

One way you might be able to achieve what you want is to create your
own template tag. (The documentation is here:
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-tags)

You could pass a few parameters to your tag--I'm not sure what you're
looking for, but maybe:

{% gitfile "myfolder/myfile.txt" "d4ea4eea799" %}

And your tag could load data from "myfolder/myfile.txt" at revision
"d4ea4eea799".

There are a few exampled in the Django code itself
(https://github.com/django/django/tree/master/django/templatetags) as
well as plenty of samples on the internet for writing your own
template tag.

-A

On Fri, Nov 21, 2014 at 2:29 PM, martin f krafft <madduck@madduck.net> wrote:
> Hello,
>
> we have a Django project with a few pages that come from Git.
> Currently, Apache rewrite rules serve those files statically (and
> they make use of the same template/CSS as Django does, so the user
> does not actually notice), and it's a massive hack and pain to keep
> up-to-date.
>
> Hence I was thinking: how much trouble would it be to have Django
> reach into Git rather than its database and obtain data there to be
> filled into template slots? Ideally, there'd be the possibility of
> running a filter (e.g. reStructuredText) between Git and the
> template rendering.
>
> I've seen http://luispedro.org/software/git-cms, but that does way
> more than just sourcing from Git. And it's not immediately obvious
> to me how it even does the Git interaction.
>
> What I envision is a storage layer (with optional caching) that
> either fetches from the filesystem (with a Git checkout, using mtime
> for cache expiration), or directly from a local Git repo (using
> either commit or blob hash for cache expiration).
>
> Does anyone know of such a module? Would it be hard to write? Where
> would one start?
>
> Thanks,
>
> --
> @martinkrafft | http://madduck.net/ | http://two.sentenc.es/
>
> mulutlitithtrhreeaadededd s siigngnatatuurere
>
> spamtraps: madduck.bogus@madduck.net
>
> --
> You received this message because you are subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20141121222930.GA15206%40fishbowl.rw.madduck.net.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEE%2BrGqxe5NGvQU6Coam0%2Bev5AjG1GdONt7cdhj9h%2BUshEHSgg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment