Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Commit e43f651

Browse files
author
Marco Pompili
committed
Added src and update to LICENSE.
1 parent 0e2dd65 commit e43f651

File tree

20 files changed

+3356
-3
lines changed

20 files changed

+3356
-3
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
*.log
22
*.pot
33
*.pyc
4-
local_settings.py
4+
5+
.project
6+
.pydevproject
7+
.settings
8+
.idea
9+
10+
dist
11+
django_instagram.egg-info

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ are permitted provided that the following conditions are met:
1111
list of conditions and the following disclaimer in the documentation and/or
1212
other materials provided with the distribution.
1313

14-
* Neither the name of the {organization} nor the names of its
14+
* Neither the name of the emarcs.org nor the names of its
1515
contributors may be used to endorse or promote products derived from
1616
this software without specific prior written permission.
1717

MANIFEST.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include LICENSE
2+
include README.rst
3+
include README.md
4+
recursive-include django_instagram/templates *
5+
recursive-include django_instagram/static *
6+
recursive-include docs *

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,52 @@
11
django-instagram
22
================
33

4-
Django instagram application based on the python-instagram API.
4+
Django Instagram application based on the python-instagram API.
5+
6+
Requirements
7+
------------
8+
- [Django 1.5](https://www.djangoproject.com/)
9+
- [Python Instagram API](https://github.com/Instagram/python-instagram)
10+
11+
12+
Installation
13+
------------
14+
Install django from your favourite package system if you can find it. Or you can use pip for installing python packages that are not listed in the package system of your distribution:
15+
- Install the python-instagram API.
16+
```
17+
pip install python-instagram
18+
```
19+
- Install the django-instagram.
20+
21+
After you cloned the repository, to install this python application you can use the pip command to install local applications like this:
22+
```
23+
pip -e install django-instagram
24+
```
25+
26+
Configuration
27+
-------------
28+
Add the application to INSTALLED_APPS:
29+
```python
30+
INSTALLED_APPS = (... 'django_instagram' ...)
31+
```
32+
33+
Then go to the administration and click on "Get Access Token" to (of course) receive your access token from Instagram. Then copy it to the configuration field and save. Remember to be logged in with the Instagram account that you want to get the access token for.
34+
35+
Usage
36+
-----
37+
After you are done with this, you can use the tags who need user access to Instagram, like:
38+
```
39+
{% instagram_recent_media %}
40+
```
41+
This tag will give you a context variable called: 'recent_media'
42+
43+
To get instagram popular media you don't need an access token instead, so you can ignore the last configuration step above.
44+
```
45+
{% instagram_popular_media %}
46+
```
47+
This tag will give you a context variable callde: 'popular_media'
48+
49+
There's also another inclusion tag that includes an example of how to parse instagram data:
50+
```
51+
{% instagram_popular_media_box %}
52+
```

README.rst

Whitespace-only changes.

django_instagram/__init__.py

Whitespace-only changes.

django_instagram/admin.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
Created on 15/dic/2013
3+
4+
@author: Marco Pompili
5+
"""
6+
7+
from django.contrib import admin
8+
from django.utils.translation import ugettext_lazy as _
9+
10+
from django.db import transaction
11+
from django.utils.decorators import method_decorator
12+
from django.views.decorators.csrf import csrf_protect
13+
14+
from .models import InstagramConfiguration
15+
from .templatetags import instagram_client
16+
17+
18+
csrf_protect_m = method_decorator(csrf_protect)
19+
20+
instagram_extra_content = {
21+
"client_id": instagram_client.DJANGO_INSTAGRAM_CLIENT_ID,
22+
"redirect_uri": instagram_client.DJANGO_INSTAGRAM_REDIRECT_URI
23+
}
24+
25+
26+
class InstagramAdmin(admin.ModelAdmin):
27+
fieldsets = (
28+
(_(u'Django Instagram Configuration'),
29+
{
30+
'fields': ('app_access_token',)
31+
}),
32+
)
33+
34+
def has_add_permission(self, request):
35+
"""
36+
Just let to add the configuration once.
37+
:param request:
38+
:return:
39+
"""
40+
return not InstagramConfiguration.objects.exists()
41+
42+
def add_view(self, request, form_url='', extra_context=None):
43+
"""
44+
Add extra parameters from the settings (client_id, redirect_uri) into the add view.
45+
:param request:
46+
:param form_url:
47+
:param extra_context:
48+
:return:
49+
"""
50+
return admin.ModelAdmin.add_view(self,
51+
request,
52+
form_url='',
53+
extra_context=instagram_extra_content)
54+
55+
@csrf_protect_m
56+
@transaction.atomic
57+
def change_view(self, request, object_id, form_url='', extra_context=None):
58+
"""
59+
Add extra parameters from the settings (client_id, redirect_uri) into the change_view.
60+
:param request:
61+
:param object_id:
62+
:param form_url:
63+
:param extra_context:
64+
:return:
65+
"""
66+
return admin.ModelAdmin.change_view(self,
67+
request,
68+
object_id,
69+
form_url=form_url,
70+
extra_context=instagram_extra_content)
71+
72+
73+
admin.site.register(InstagramConfiguration, InstagramAdmin)

django_instagram/models.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""
2+
Created on 13/mar/2014
3+
4+
@author: Marco Pompili
5+
"""
6+
7+
from django.db import models
8+
from django.utils.translation import ugettext_lazy as _
9+
10+
11+
class InstagramConfiguration(models.Model):
12+
class Meta:
13+
verbose_name = _(u"Django Instagram Configuration")
14+
verbose_name_plural = _(u"Django Instagram Configuration")
15+
16+
app_access_token = models.TextField(
17+
_(u'Access token'),
18+
help_text=_(
19+
u'Click on "Get Access Token" and you will be redirected to Instagram, then follow the instructions. Remember to log in with the user that you want to show on the web page.'))
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.django_instagram {
2+
position: relative;
3+
}
4+
5+
.django_instagram .slider {
6+
position: relative;
7+
margin: 0; padding: 0;
8+
list-style: none
9+
}
10+
11+
.django_instagram .entry {
12+
position: absolute;
13+
top:0; left: 50%;
14+
margin-left: -153px;
15+
display: none
16+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
.django_instagram_media_wall_item {
2+
width: 25%; height: auto;
3+
float: left;
4+
position: relative
5+
}
6+
7+
.django_instagram_media_wall_item img {
8+
width: 100%; height: auto;
9+
float: left
10+
}
11+
12+
.django_instagram_media_wall_item a span {
13+
position: absolute;
14+
bottom: 0; left: 0; right: 0;
15+
color: #F3F3F3; background: #222222; opacity: 0.8;
16+
z-index: 50
17+
}

0 commit comments

Comments
 (0)