Index: /quintagroup.camefrominfo/tags/0.1/README.txt
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/README.txt	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/README.txt	(revision 1267)
@@ -0,0 +1,12 @@
+Introduction
+============
+
+quintagroup.camefrominfo designed to track the visitor came from
+information. On fist page view referer information is saved to cookie and
+then it is available for reports (on form submision etc.)
+
+Authors
+======= 
+
+Vitaliy Podoba
+Volodymyr Cherepanyak
Index: /quintagroup.camefrominfo/tags/0.1/docs/HISTORY.txt
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/docs/HISTORY.txt	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/docs/HISTORY.txt	(revision 1267)
@@ -0,0 +1,8 @@
+Changelog
+=========
+
+0.1 - Unreleased
+----------------
+
+* Initial release
+
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/__init__.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/__init__.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/__init__.py	(revision 1267)
@@ -0,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__)
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/__init__.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/__init__.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/__init__.py	(revision 1267)
@@ -0,0 +1,1 @@
+#
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/__init__.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/__init__.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/__init__.py	(revision 1267)
@@ -0,0 +1,1 @@
+#
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/browser.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/browser.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/browser.py	(revision 1267)
@@ -0,0 +1,12 @@
+from Products.Five import BrowserView
+from quintagroup.camefrominfo.interfaces import ICameFromInfoUtility
+from zope.component import getUtility
+
+class CameFromInfoView(BrowserView):
+    """
+    """
+    def __call__(self):
+        """get info"""
+        service = getUtility(ICameFromInfoUtility)
+        res = service.getInfo(self.context.REQUEST)
+        return res
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/cameFromCookie.js
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/cameFromCookie.js	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/cameFromCookie.js	(revision 1267)
@@ -0,0 +1,18 @@
+function setCFCookie() {
+    var own_domain = document.domain;
+    var currRef = document.referrer;
+    var cookie_name = "cmfrm";
+    var domain = currRef.match(/:\/\/(www\.)?([^\/:]+)/);
+    domain = (domain != null && domain[2]) ? domain[2] : '';
+    if ((domain.toLowerCase() != own_domain) || (domain == '')) {
+        // set cookie with new referrer
+        createCookie(cookie_name, currRef);
+    }
+};
+
+function registerPloneFunction(func) {
+    if (window.addEventListener) window.addEventListener("load",func,false);
+    else if (window.attachEvent) window.attachEvent("onload",func);   
+};
+
+registerPloneFunction(setCFCookie);
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/configure.zcml
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/configure.zcml	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/browser/configure.zcml	(revision 1267)
@@ -0,0 +1,16 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:browser="http://namespaces.zope.org/browser"
+    i18n_domain="quintagroup.camefrominfo">
+
+  <browser:resource
+    name="cameFromCookie.js" image="cameFromCookie.js" />
+
+  <browser:page
+      for="*"
+      name="camefrominfo_view"
+      class=".browser.CameFromInfoView"
+      permission="zope.Public" 
+      />
+
+</configure>
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/camefromutility.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/camefromutility.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/camefromutility.py	(revision 1267)
@@ -0,0 +1,18 @@
+from interfaces import ICameFromInfoUtility
+from zope.interface import implements
+
+class CameFromInfoUtility(object):
+    """
+    """
+    implements(ICameFromInfoUtility)
+    
+    def __init__(self):
+        pass
+    
+    def getInfo(self, request):
+        """ get info """
+        ip = request.get('HTTP_X_FORWARDED_FOR', None) or request.getClientAddr()
+        ip = ip.split(',')[0]
+        browser = request.get('HTTP_USER_AGENT',"")
+        came_from = request.get("cmfrm","None")
+        return {'ip':ip, 'browser':browser, 'came_from':came_from}
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/configure.zcml
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/configure.zcml	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/configure.zcml	(revision 1267)
@@ -0,0 +1,12 @@
+<configure
+  xmlns="http://namespaces.zope.org/zope"
+  i18n_domain="quintagroup.camefrominfo">
+  
+  <include package=".browser" />
+  <include file="profiles.zcml" />
+  
+  <utility
+    provides=".interfaces.ICameFromInfoUtility"
+    factory=".camefromutility.CameFromInfoUtility" />
+
+</configure>
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/interfaces.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/interfaces.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/interfaces.py	(revision 1267)
@@ -0,0 +1,7 @@
+from zope.interface import Interface
+      
+class ICameFromInfoUtility(Interface):
+    """
+    """
+    def getInfo(self, request):
+        """ get info """
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles.zcml
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles.zcml	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles.zcml	(revision 1267)
@@ -0,0 +1,14 @@
+<configure
+    xmlns="http://namespaces.zope.org/zope"
+    xmlns:genericsetup="http://namespaces.zope.org/genericsetup"
+    i18n_domain="quintagroup.camefrominfo">
+
+  <genericsetup:registerProfile
+      name="default"
+      title="Quintagroup CameFromInfo"
+      directory="profiles/default"
+      description='Quintagroup came from info package.'
+      provides="Products.GenericSetup.interfaces.EXTENSION"
+      />
+
+</configure>
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/import_steps.xml
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/import_steps.xml	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/import_steps.xml	(revision 1267)
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<import-steps>
+  <import-step id="quintagroup.camefrominfo.various" version="20090717-01"
+               handler="quintagroup.camefrominfo.setuphandlers.setupVarious"
+               title="Quintagroup CameFromInfo">
+    Various import steps that are not handled by GS import/export
+    handlers.
+  </import-step>
+</import-steps>
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/jsregistry.xml
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/jsregistry.xml	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/jsregistry.xml	(revision 1267)
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<object name="portal_javascripts">
+ <javascript
+    id="++resource++cameFromCookie.js" enabled="True" expression=""
+    cookable="True" inline="True" insert-before="jquery.js" />
+</object>
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/metadata.xml
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/metadata.xml	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/metadata.xml	(revision 1267)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<metadata>
+  <version>0.1</version>
+</metadata>
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/quintagroup.camefrominfo_various.txt
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/quintagroup.camefrominfo_various.txt	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/profiles/default/quintagroup.camefrominfo_various.txt	(revision 1267)
@@ -0,0 +1,1 @@
+This file is used as a marker in setuphandlers.py.
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/setuphandlers.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/setuphandlers.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/setuphandlers.py	(revision 1267)
@@ -0,0 +1,11 @@
+def setupVarious(context):
+
+    # Ordinarily, GenericSetup handlers check for the existence of XML files.
+    # Here, we are not parsing an XML file, but we use this text file as a
+    # flag to check that we actually meant for this import step to be run.
+    # The file is found in profiles/default.
+
+    if context.readDataFile('quintagroup.camefrominfo_various.txt') is None:
+        return
+
+    # Add additional setup code here
Index: /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/tests.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/tests.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/quintagroup/camefrominfo/tests.py	(revision 1267)
@@ -0,0 +1,32 @@
+import unittest
+import os
+import sys
+import re
+
+from unittest import makeSuite, TestCase
+from zope.testing import doctestunit
+from zope.component import testing
+from Testing import ZopeTestCase as ztc
+
+from Products.Five import zcml
+from Products.Five import fiveconfigure
+from Products.PloneTestCase import PloneTestCase as ptc
+from Products.PloneTestCase.layer import PloneSite
+ptc.setupPloneSite()
+
+import quintagroup.camefrominfo
+from zope.testbrowser.browser import Browser
+
+class CameFromInfoTest(TestCase):
+
+    def setUp(self):
+        pass
+
+    def test_camefrominfo(self):
+        pass
+
+def test_suite():
+    return makeSuite(CameFromInfoTest)
+
+if __name__ == '__main__':
+    unittest.main(defaultTest='test_suite')
Index: /quintagroup.camefrominfo/tags/0.1/setup.cfg
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/setup.cfg	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/setup.cfg	(revision 1267)
@@ -0,0 +1,4 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
+
Index: /quintagroup.camefrominfo/tags/0.1/setup.py
===================================================================
--- /quintagroup.camefrominfo/tags/0.1/setup.py	(revision 1267)
+++ /quintagroup.camefrominfo/tags/0.1/setup.py	(revision 1267)
@@ -0,0 +1,33 @@
+from setuptools import setup, find_packages
+import os
+
+version = '0.1'
+
+setup(name='quintagroup.camefrominfo',
+      version=version,
+      description="Quintagroup came from info package",
+      long_description=open("README.txt").read() + "\n" +
+                       open(os.path.join("docs", "HISTORY.txt")).read(),
+      # Get more strings from http://www.python.org/pypi?%3Aaction=list_classifiers
+      classifiers=[
+        "Framework :: Plone",
+        "Programming Language :: Python",
+        "Topic :: Software Development :: Libraries :: Python Modules",
+        ],
+      keywords='quintagroup camefrom info',
+      author='Quintagroup',
+      author_email='support@quintagroup.com',
+      url='http://svn.quintagroup.com/products/quintagroup.camefrominfo',
+      license='GPL',
+      packages=find_packages(exclude=['ez_setup']),
+      namespace_packages=['quintagroup'],
+      include_package_data=True,
+      zip_safe=False,
+      install_requires=[
+          'setuptools',
+          # -*- Extra requirements: -*-
+      ],
+      entry_points="""
+      # -*- Entry points: -*-
+      """,
+      )
