from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from socketio import sdjango
from web.api import EventResource, SummaryFeedResource, SummaryFeedByCountryCodeResource
from tastypie.api import Api

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()
sdjango.autodiscover()

v1_api = Api(api_name='v1')
#api_test = EventResource()
v1_api.register(SummaryFeedResource())
#v1_api.register(SummaryFeedByCountryCodeResource())


urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'malwarez.views.home', name='home'),
    # url(r'^malwarez/', include('malwarez.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    # url(r'^admin/', include(admin.site.urls)),
    url(r'^$', 'web.views.index'),
    url(r'^test/$', 'web.views.test'),

    url(r'^top/(?P<type>\w+)/(?P<country>\w+)/$', 'web.views.getTopFive'),
    url(r'^top/(?P<type>\w+)/$', 'web.views.getTopFive'),

    #url(r'^detail/(?P<type>\w+)/(?P<country>\w+)/(?P<data>\w+)/$', 'web.views.getDetail'),
    url(r'^detail/(?P<type>\w+)/(?P<data>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/$', 'web.views.getDetail'),
    url(r'^detail/(?P<type>\w+)/(?P<data>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/(?P<country>\w+)/$', 'web.views.getDetail'),

    url(r'filter/malware', 'web.views.getDiversityMalware'),
    url(r'filter/ip', 'web.views.getDiversityIP')

)
urlpatterns += staticfiles_urlpatterns()
    url(r'^socket\.io', include(sdjango.urls)),
    url(r'^api/', include(v1_api.urls)),

    url(r'^summary-country/(?P<countryCode>\w+)/$', 'web.views.getSummaryByCountry'),
    # TODO: be more specific country parameter should be only 3 char long