-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6fa4bab
Showing
22 changed files
with
1,387 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> | ||
<classpathentry kind="lib" path="/usr/lib/jvm/java-6-sun/jre/lib/plugin.jar"/> | ||
<classpathentry kind="lib" path="lib/json.jar"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
*.jar | ||
bin/* | ||
*.swp | ||
jaropt.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>fileify</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#Sun Dec 20 06:54:01 PST 2009 | ||
eclipse.preferences.version=1 | ||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled | ||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 | ||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve | ||
org.eclipse.jdt.core.compiler.compliance=1.6 | ||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate | ||
org.eclipse.jdt.core.compiler.debug.localVariable=generate | ||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate | ||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error | ||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error | ||
org.eclipse.jdt.core.compiler.source=1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Matt Colyer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2010 Matt Colyer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
= fileify | ||
Allows Javascript applications to read and write local files, through the | ||
use of a privileged applet. | ||
|
||
This code has been derived from http://gitify.com, a 100% web based git client. | ||
|
||
Some refer to this method as JAHA, in true four letter Web 2.0 fashion. | ||
http://windyroad.org/2006/08/14/reintroducing-javascript-and-hidden-applets-jaha/ | ||
|
||
= Example | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | ||
<script src="fileify.js"></script> | ||
<script> | ||
$(document).bind('fileifyready', function(){ | ||
var filename = "/tmp/test"; | ||
|
||
// Read a file | ||
var result = Fileify.read(filename); | ||
if (result["error"] == undefined){ | ||
console.log("Success: "+result["data"]); | ||
}else{ | ||
console.log("Error: "+result["error"]); | ||
} | ||
|
||
// Overwrite a file | ||
result = Fileify.write(filename, "Hello World"); | ||
if (result["error"] == undefined){ | ||
console.log("Success"); | ||
}else{ | ||
console.log("Failure: "+result["error"]); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> | ||
|
||
== How to build | ||
In order to build fileify for your own site you'll need git, Eclipse (3.5 or | ||
greater) and the Java 1.6 JDK. | ||
|
||
* git clone http://github.com/mcolyer/fileify.git | ||
* Launch eclipse | ||
* From the File menu choose "Import" and then "Existing Projects into | ||
Workspace" and select the git checkout you made in step 1. | ||
* Fix any library reference errors (I use Ubuntu to develop, so it's likely the | ||
files moved if you aren't using Ubuntu) | ||
* Next you'll need to create a keystore to sign the applet so it can run | ||
privileged. | ||
* Use the following to generate the keystore: | ||
"keytool -genkeypair -alias fileify -keypass secret -storepass secret -validity 365" | ||
Answer the questions as prompted. | ||
* You should now be able to right click the build.xml file in eclipse and build | ||
the all target. | ||
* There should now be a fileify.jar in the root of the git checkout, which you | ||
can place in the root of your application. | ||
|
||
== How to contribute | ||
* First fork the repository using github. | ||
* Create a branch for your feature or fix with an appropriate name. | ||
* Make your changes and create any relevant test cases (see tests/) and then | ||
push to github. | ||
* Create a github ticket with a link to the relevant branch that you think | ||
should be merged. Briefly describe what is going on in the ticket | ||
|
||
== Related Links | ||
* http://www.tiddlywiki.com/#TiddlySaver - An applet used by the Tiddlywiki | ||
project to save, similar but less generic. | ||
* http://www.w3.org/TR/2009/WD-FileAPI-20091117/ - W3C's proposal for a read | ||
only file API (used in FF 3.6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<project default="all" name="Create Runnable Jar for Project java-git"> | ||
<target name="all" depends="compile,create_jar"> | ||
</target> | ||
<target name="compile" description="Compilation target"> | ||
<delete dir="bin" /> | ||
<mkdir dir="bin" /> | ||
<javac target="1.5" srcdir="src" destdir="bin" classpath="lib/json.jar;lib/plugin.jar;" /> | ||
</target> | ||
|
||
<taskdef name="JarOpt" classname="org.cmc.jaroptimizer.JarOptTask" classpath="lib/jaropt.jar" /> | ||
<target name="create_jar"> | ||
<jar destfile="unstripped.jar" filesetmanifest="mergewithoutmain"> | ||
<manifest> | ||
<attribute name="Main-Class" value="com.mavient.fileify.FileService" /> | ||
<attribute name="Class-Path" value="." /> | ||
</manifest> | ||
<fileset dir="bin" /> | ||
<zipfileset excludes="META-INF/*.SF" src="lib/json.jar" /> | ||
<fileset dir="lib" excludes="*.jar" /> | ||
</jar> | ||
<JarOpt src="unstripped.jar" dst="fileify.jar" stripNonClassFiles="false"> | ||
<includePattern>name.colyer.matt.*</includePattern> | ||
</JarOpt> | ||
<signjar jar="fileify.jar" alias="fileify" storepass="secret" /> | ||
</target> | ||
</project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<html> | ||
<head> | ||
</head> | ||
<body> | ||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | ||
<script src="../js/fileify.js"></script> | ||
<script> | ||
$(document).bind('fileifyready', function(){ | ||
var filename = "/tmp/test"; | ||
|
||
// Read a file | ||
var result = Fileify.read(filename); | ||
if (result["error"] == undefined){ | ||
console.log("Success: "+result["data"]); | ||
}else{ | ||
console.log("Error: "+result["error"]); | ||
} | ||
|
||
// Overwrite a file | ||
result = Fileify.write(filename, "Hello World"); | ||
if (result["error"] == undefined){ | ||
console.log("Success"); | ||
}else{ | ||
console.log("Failure: "+result["error"]); | ||
} | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
/* | ||
* jQuery JSON Plugin | ||
* version: 2.1 (2009-08-14) | ||
* | ||
* This document is licensed as free software under the terms of the | ||
* MIT License: http://www.opensource.org/licenses/mit-license.php | ||
* | ||
* Brantley Harris wrote this plugin. It is based somewhat on the JSON.org | ||
* website's http://www.json.org/json2.js, which proclaims: | ||
* "NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.", a sentiment that | ||
* I uphold. | ||
* | ||
* It is also influenced heavily by MochiKit's serializeJSON, which is | ||
* copyrighted 2005 by Bob Ippolito. | ||
*/ | ||
|
||
(function($) { | ||
/** jQuery.toJSON( json-serializble ) | ||
Converts the given argument into a JSON respresentation. | ||
If an object has a "toJSON" function, that will be used to get the representation. | ||
Non-integer/string keys are skipped in the object, as are keys that point to a function. | ||
json-serializble: | ||
The *thing* to be converted. | ||
**/ | ||
$.toJSON = function(o) | ||
{ | ||
if (typeof(JSON) == 'object' && JSON.stringify) | ||
return JSON.stringify(o); | ||
|
||
var type = typeof(o); | ||
|
||
if (o === null) | ||
return "null"; | ||
|
||
if (type == "undefined") | ||
return undefined; | ||
|
||
if (type == "number" || type == "boolean") | ||
return o + ""; | ||
|
||
if (type == "string") | ||
return $.quoteString(o); | ||
|
||
if (type == 'object') | ||
{ | ||
if (typeof o.toJSON == "function") | ||
return $.toJSON( o.toJSON() ); | ||
|
||
if (o.constructor === Date) | ||
{ | ||
var month = o.getUTCMonth() + 1; | ||
if (month < 10) month = '0' + month; | ||
|
||
var day = o.getUTCDate(); | ||
if (day < 10) day = '0' + day; | ||
|
||
var year = o.getUTCFullYear(); | ||
|
||
var hours = o.getUTCHours(); | ||
if (hours < 10) hours = '0' + hours; | ||
|
||
var minutes = o.getUTCMinutes(); | ||
if (minutes < 10) minutes = '0' + minutes; | ||
|
||
var seconds = o.getUTCSeconds(); | ||
if (seconds < 10) seconds = '0' + seconds; | ||
|
||
var milli = o.getUTCMilliseconds(); | ||
if (milli < 100) milli = '0' + milli; | ||
if (milli < 10) milli = '0' + milli; | ||
|
||
return '"' + year + '-' + month + '-' + day + 'T' + | ||
hours + ':' + minutes + ':' + seconds + | ||
'.' + milli + 'Z"'; | ||
} | ||
|
||
if (o.constructor === Array) | ||
{ | ||
var ret = []; | ||
for (var i = 0; i < o.length; i++) | ||
ret.push( $.toJSON(o[i]) || "null" ); | ||
|
||
return "[" + ret.join(",") + "]"; | ||
} | ||
|
||
var pairs = []; | ||
for (var k in o) { | ||
var name; | ||
var type = typeof k; | ||
|
||
if (type == "number") | ||
name = '"' + k + '"'; | ||
else if (type == "string") | ||
name = $.quoteString(k); | ||
else | ||
continue; //skip non-string or number keys | ||
|
||
if (typeof o[k] == "function") | ||
continue; //skip pairs where the value is a function. | ||
|
||
var val = $.toJSON(o[k]); | ||
|
||
pairs.push(name + ":" + val); | ||
} | ||
|
||
return "{" + pairs.join(", ") + "}"; | ||
} | ||
}; | ||
|
||
/** jQuery.evalJSON(src) | ||
Evaluates a given piece of json source. | ||
**/ | ||
$.evalJSON = function(src) | ||
{ | ||
if (typeof(JSON) == 'object' && JSON.parse) | ||
return JSON.parse(src); | ||
return eval("(" + src + ")"); | ||
}; | ||
|
||
$.quoteString = function(string) | ||
{ | ||
if (string.match(_escapeable)) | ||
{ | ||
return '"' + string.replace(_escapeable, function (a) | ||
{ | ||
var c = _meta[a]; | ||
if (typeof c === 'string') return c; | ||
c = a.charCodeAt(); | ||
return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); | ||
}) + '"'; | ||
} | ||
return '"' + string + '"'; | ||
}; | ||
|
||
var _escapeable = /["\\\x00-\x1f\x7f-\x9f]/g; | ||
|
||
var _meta = { | ||
'\b': '\\b', | ||
'\t': '\\t', | ||
'\n': '\\n', | ||
'\f': '\\f', | ||
'\r': '\\r', | ||
'"' : '\\"', | ||
'\\': '\\\\' | ||
}; | ||
})(jQuery); | ||
|
||
var Fileify = { | ||
render_applet: function(){ | ||
jar_file = "fileify.jar"; | ||
s = "<!--[if !IE]> Firefox and others will use outer object -->"; | ||
s += "<object classid='java:name.colyer.matt.fileify.FileService' height='1' id='FileService' name='FileService' type='application/x-java-applet;version=1.5' width='1'>"; | ||
s += "<param name=\"archive\" value=\""+jar_file+"\" />"; | ||
s += "<param name='mayscript' value='true' />"; | ||
s += "<!--<![endif]-->"; | ||
s += "<!-- MSIE (Microsoft Internet Explorer) will use the inner object -->"; | ||
s += '<object id="GitService" classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA" codebase="http://java.sun.com/out-of-proc-plugin-url-placeholder.exe#1,6,0,16" height="1" width="1" >'; | ||
s += "<param name=\"archive\" value=\""+jar_file+"\" />"; | ||
s += "<param name='code' value='name.colyer.matt.fileify.FileService' />"; | ||
s += "<param name='mayscript' value='true' />"; | ||
s += "<div style='display:none'></div>"; | ||
s += "</object>"; | ||
s += "<!--[if !IE]> close outer object -->"; | ||
s += "</object>"; | ||
s += "<!--<![endif]-->"; | ||
document.write(s); | ||
}, | ||
|
||
loaded : function(){ | ||
Fileify.applet = Fileify._get_service(); | ||
$(document).trigger("fileifyready"); | ||
}, | ||
|
||
read : function(filename){ | ||
return $.evalJSON(Fileify.applet.runPrivileged("read", $.toJSON([filename]))); | ||
}, | ||
|
||
write : function(filename, content){ | ||
return $.evalJSON(Fileify.applet.runPrivileged("write", $.toJSON([filename, content]))); | ||
}, | ||
|
||
_get_service : function(){ | ||
// Safari allows access to both but only document.applets works. | ||
if (document.applets && document.applets['FileService']){ | ||
return document.applets['FileService']; | ||
}else{ | ||
return document.FileService; | ||
} | ||
} | ||
} | ||
|
||
var applet_loaded_min = function(){ | ||
Fileify.loaded(); | ||
} | ||
Fileify.render_applet(); |
Oops, something went wrong.