Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit 043a6e48166f1339c1850d86089904cc22802aa9 @kolyuchiy kolyuchiy committed Jul 6, 2011
@@ -0,0 +1,2 @@
+dist
+jquery-openxtag-*
@@ -0,0 +1,27 @@
+{
+ "name": "jQuery-OpenXTag",
+ "version": 1.0,
+ "author": [
+ "Nikolay Morev <kolia@denivip.ru>"
+ ],
+ "abstract": "Insert OpenX ad tags using jQuery.",
+ "license": "mit",
+ "distribution_type": "plugin",
+ "requires": {
+ "jQuery": ""
+ },
+ "provides": {
+ "jQuery.openxtag": {
+ "version": 1.0,
+ "file": "jquery.openxtag.js"
+ }
+ },
+ "keywords": [
+ "openx", "ads", "asyncronous", "invocation"
+ ],
+ "meta-spec": {
+ "version": 1.3,
+ "url": "http://module-build.sourceforge.net/META-spec-v1.3.html"
+ },
+ "generated_by": "Nikolay Morev"
+}
@@ -0,0 +1,75 @@
+
+# makefile from jquery sources
+
+SRC_DIR = src
+TEST_DIR = test
+BUILD_DIR = build
+
+PREFIX = .
+DIST_DIR = ${PREFIX}/dist
+
+JS_ENGINE ?= `which node nodejs`
+COMPILER = ${JS_ENGINE} ${BUILD_DIR}/uglify.js --unsafe
+
+BASE_FILES = ${SRC_DIR}/jquery.openxtag.js
+
+MODULES = ${BASE_FILES}
+
+JQ = ${DIST_DIR}/jquery.openxtag.js
+JQ_MIN = ${DIST_DIR}/jquery.openxtag.min.js
+
+JQ_VER = $(shell cat version.txt)
+VER = sed "s/@VERSION/${JQ_VER}/"
+TGZ = ./jquery-openxtag-${JQ_VER}
+
+DATE=$(shell git log -1 --pretty=format:%ad)
+
+all: core ${TGZ}.tar.gz
+
+core: jquery min lint
+ @@echo "Plugin build complete."
+
+${DIST_DIR}:
+ @@mkdir -p ${DIST_DIR}
+ @@cp -r README examples ${DIST_DIR}
+
+jquery: ${JQ}
+
+${JQ}: ${MODULES} | ${DIST_DIR}
+ @@echo "Building" ${JQ}
+
+ @@cat ${MODULES} | \
+ sed 's/@DATE/'"${DATE}"'/' | \
+ ${VER} > ${JQ};
+
+${TGZ}.tar.gz: ${DIST_DIR}
+ @@rm -rf ${TGZ} ${TGZ}.tar.gz ${TGZ}.zip
+ @@cp -r ${DIST_DIR} ${TGZ}
+ @@tar cfz ${TGZ}.tar.gz ${TGZ}
+ @@zip -r ${TGZ}.zip ${TGZ}
+
+lint: jquery
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Checking plugin against JSLint..."; \
+ ${JS_ENGINE} build/jslint-check.js; \
+ else \
+ echo "You must have NodeJS installed in order to test plugin against JSLint."; \
+ fi
+
+min: jquery ${JQ_MIN}
+
+${JQ_MIN}: ${JQ}
+ @@if test ! -z ${JS_ENGINE}; then \
+ echo "Minifying plugin" ${JQ_MIN}; \
+ ${COMPILER} ${JQ} > ${JQ_MIN}; \
+ else \
+ echo "You must have NodeJS installed in order to minify plugin."; \
+ fi
+
+
+clean:
+ @@echo "Removing Distribution directory:" ${DIST_DIR} ${TGZ} ${TGZ}.tar.gz
+ @@rm -rf ${DIST_DIR}
+ @@rm -rf ${TGZ} ${TGZ}.tar.gz ${TGZ}.zip
+
+.PHONY: all jquery lint min clean core
56 README
@@ -0,0 +1,56 @@
+jQuery OpenX tag plugin
+
+This plugin provides alternative jQuery-compatible way to insert OpenX ad
+invocation tags into various parts of your web page. It also features some
+additional improvements over standard OpenX tags:
+
+ * Ads are inserted asynchronously so that ad invocation code does not block
+ page loading.
+ * You can set and override invocation tag parameters in several places:
+ globally for all ads that are loaded using the plugin, in ad insertion JS
+ call, in ad placeholder class attribute with the help of jQuery Metadata
+ plugin.
+ * Callback on ad load.
+
+The plugin was successfully tested with OpenX Community Edition version
+2.8.8-rc6 (the most recent at the moment).
+
+Usage examples
+
+Init OpenX tag plugin with required parameters:
+
+$.openxtag('init', {
+ delivery: 'http://openx.local/openx-now/www/delivery',
+ deliverySSL: 'https://openx.local/openx-now/www/delivery'
+});
+
+Load ad from OpenX zone 1 into web page element with id "zone1":
+
+$('#zone1').openxtag('zone', 1);
+
+Load ads from OpenX zone 1 into all elements with "banner" class with "block"
+option that instructs OpenX to skip banners that were already loaded on current
+page. The function from third argument is called on ad load.
+
+$('.banner').openxtag('zone', 1, {
+ block: true
+}, function () {
+ console.log('loaded ad from zone ' + 1);
+});
+
+Load all ads using invocation parameters set for each placeholder element in
+their HTML code.
+
+$('.banner').openxtag('zone', function () {
+ console.log('loaded ad');
+});
+
+<div class="banner {zoneID: 1, source: 'zone1'}"></div>
+<div class="banner {zoneID: 1, source: 'zone2'}"></div>
+
+Also see sample HTML pages in examples/
+
+TODO
+add test suite
+remove callback, add event on ad load
+
@@ -0,0 +1,36 @@
+var JSLINT = require("./lib/jslint").JSLINT,
+ print = require("sys").print,
+ src = require("fs").readFileSync("dist/jquery.openxtag.js", "utf8");
+
+JSLINT(src, { evil: true, forin: true, maxerr: 100 });
+
+// All of the following are known issues that we think are 'ok'
+// (in contradiction with JSLint) more information here:
+// http://docs.jquery.com/JQuery_Core_Style_Guidelines
+var ok = {
+ "Expected an identifier and instead saw 'undefined' (a reserved word).": true,
+ "Use '===' to compare with 'null'.": true,
+ "Use '!==' to compare with 'null'.": true,
+ "Expected an assignment or function call and instead saw an expression.": true,
+ "Expected a 'break' statement before 'case'.": true,
+ "'e' is already defined.": true
+};
+
+var e = JSLINT.errors, found = 0, w;
+
+for ( var i = 0; i < e.length; i++ ) {
+ w = e[i];
+
+ if ( !ok[ w.reason ] ) {
+ found++;
+ print( "\n" + w.evidence + "\n" );
+ print( " Problem at line " + w.line + " character " + w.character + ": " + w.reason );
+ }
+}
+
+if ( found > 0 ) {
+ print( "\n" + found + " Error(s) found.\n" );
+
+} else {
+ print( "JSLint check passed.\n" );
+}
Oops, something went wrong.

0 comments on commit 043a6e4

Please sign in to comment.