Skip to content

Instantly share code, notes, and snippets.

@craigmarvelley
Last active December 12, 2016 14:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigmarvelley/9479404adbb9eae4d6a5bb6ea8058fbb to your computer and use it in GitHub Desktop.
Save craigmarvelley/9479404adbb9eae4d6a5bb6ea8058fbb to your computer and use it in GitHub Desktop.
// This file is managed at build time by a build script.
// @include Readability.js
// @include Clipper.js
// @include main.js
desc "Build phase script to compile clipper javascript into a single file"
lane :compile_clipper_js do |options|
working_directory = "#{ENV["BUILT_PRODUCTS_DIR"]}/#{ENV["WRAPPER_NAME"]}"
compilation_file_path = "#{working_directory}/compiled.js"
compiled_contents = ""
File.readlines("#{ENV["PROJECT_DIR"]}/clipper/compiled.js").each do |line|
matches = line.match(/^\/\/\s@include (.*)$/)
if (!matches)
next
end
file = "#{working_directory}/#{matches.captures.first}";
compiled_contents += "\n\n" + File.read(file);
end
File.write(compilation_file_path, compiled_contents)
puts "Wrote compiled clipper JS to #{compilation_file_path}"
end
/* global Readability, Clipper */
class ClippedArticlePreprocessor
{
run( args )
{
var clipper = new Clipper();
var article = clipper.clip( window, document );
args.completionFunction( article );
}
};
var ExtensionPreprocessingJS = new ClippedArticlePreprocessor;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment