# Path: archive_chan/settings.py
# class AppSettings:
#     app_settings = {
#         'API_WAIT': 1, # [seconds] Delay between two API calls (catalog/list of posts). This should follow the API rules.
#         'FILE_WAIT': 0, # [seconds] Delay between two file downloads (images/thumbnails). This should follow the API rules (no limit at this point).
#         'CONNECTION_TIMEOUT': 10, # [seconds] Code downloading the data will stop waiting for a response after that time.
#         'RECENT_POSTS_AGE': 48, # [hours] Used for selecting statistics when the board stores posts forever without deleting them. Read more in views.ajax_board_stats
#         'SCRAPER_THREADS_NUMBER': 4, # Number of additional program threads running at the same time. In other words that many 4chan threads will be updated at the same time.
#         'VIEW_CACHE_AGE': 60 * 5, # [seconds] max age of the dynamic pages eg. board
#         'VIEW_CACHE_AGE_STATIC': 60 * 60 * 24, # [seconds] max age of the static pages eg. stats
#         'MEDIA_URL': settings.MEDIA_URL, # You can override the URL from which the downloaded photos are served.
#     }
# 
#     @classmethod
#     def get(self, name):
#         return getattr(settings, 'ARCHIVE_CHAN_' + name, self.app_settings[name])


from django.conf.urls import patterns, url
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.cache import cache_page
from archive_chan.settings import AppSettings
import archive_chan.views.core as core
import archive_chan.views.api as api



cache = AppSettings.get('VIEW_CACHE_AGE')
cache_static = AppSettings.get('VIEW_CACHE_AGE_STATIC')

urlpatterns = patterns('',
    # Global.
    url(r'^$', cache_page(cache)(core.IndexView.as_view()), name='index'),
    url(r'^stats/$', cache_page(cache_static)(core.StatsView.as_view()), name='stats'),
    url(r'^gallery/$', cache_page(cache_static)(core.GalleryView.as_view()), name='gallery'),
    url(r'^search/$', core.SearchView.as_view(), name='search'),

    # Board.
    url(r'^board/(?P<board>[a-z]+)/$', cache_page(cache)(core.BoardView.as_view()), name='board'),
    url(r'^board/(?P<board>[a-z]+)/stats/$', cache_page(cache_static)(core.StatsView.as_view()), name='board_stats'),

# Path: archive_chan/settings.py
# class AppSettings:
#     app_settings = {
#         'API_WAIT': 1, # [seconds] Delay between two API calls (catalog/list of posts). This should follow the API rules.
#         'FILE_WAIT': 0, # [seconds] Delay between two file downloads (images/thumbnails). This should follow the API rules (no limit at this point).
#         'CONNECTION_TIMEOUT': 10, # [seconds] Code downloading the data will stop waiting for a response after that time.
#         'RECENT_POSTS_AGE': 48, # [hours] Used for selecting statistics when the board stores posts forever without deleting them. Read more in views.ajax_board_stats
#         'SCRAPER_THREADS_NUMBER': 4, # Number of additional program threads running at the same time. In other words that many 4chan threads will be updated at the same time.
#         'VIEW_CACHE_AGE': 60 * 5, # [seconds] max age of the dynamic pages eg. board
#         'VIEW_CACHE_AGE_STATIC': 60 * 60 * 24, # [seconds] max age of the static pages eg. stats
#         'MEDIA_URL': settings.MEDIA_URL, # You can override the URL from which the downloaded photos are served.
#     }
# 
#     @classmethod
#     def get(self, name):
#         return getattr(settings, 'ARCHIVE_CHAN_' + name, self.app_settings[name])


# Path: archive_chan/urls.py
from django.conf.urls import patterns, url
from django.views.decorators.csrf import ensure_csrf_cookie
from django.views.decorators.cache import cache_page
from archive_chan.settings import AppSettings
import archive_chan.views.core as core
import archive_chan.views.api as api




cache = AppSettings.get('VIEW_CACHE_AGE')
cache_static = AppSettings.get('VIEW_CACHE_AGE_STATIC')

urlpatterns = patterns('',
    # Global.
    url(r'^$', cache_page(cache)(core.IndexView.as_view()), name='index'),
    url(r'^stats/$', cache_page(cache_static)(core.StatsView.as_view()), name='stats'),
    url(r'^gallery/$', cache_page(cache_static)(core.GalleryView.as_view()), name='gallery'),
    url(r'^search/$', core.SearchView.as_view(), name='search'),

    # Board.
    url(r'^board/(?P<board>[a-z]+)/$', cache_page(cache)(core.BoardView.as_view()), name='board'),
    url(r'^board/(?P<board>[a-z]+)/stats/$', cache_page(cache_static)(core.StatsView.as_view()), name='board_stats'),

    url(r'^board/(?P<board>[a-z]+)/gallery/$', cache_page(cache_static)(core.GalleryView.as_view()), name='board_gallery'),