From 011a7879e6003c736b13f72283106598f0b6b796 Mon Sep 17 00:00:00 2001 From: DevJamesDev Date: Wed, 31 Jul 2013 14:59:34 +0930 Subject: [PATCH 1/5] Open files in different directories, as specified by settings --- sourcemakeup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sourcemakeup.php b/sourcemakeup.php index 1b5a910..5d5c192 100644 --- a/sourcemakeup.php +++ b/sourcemakeup.php @@ -97,7 +97,7 @@ // Load the file and create an array of all lines: - $data = file_get_contents($file); + $data = file_get_contents($dir.$file); $lines = explode("\n", $data); // Create some variables we need later: @@ -106,6 +106,7 @@ $iscomment = false; $currentblock = 0; $linenumber = 0; + $blockCommentMode = false; // Step through all lines and combine them into codeblocks. Each codeblock can have following contents: // From 7d252de55cb12e32d00688f5bca211edd2d08e81 Mon Sep 17 00:00:00 2001 From: DevJamesDev Date: Wed, 31 Jul 2013 15:08:12 +0930 Subject: [PATCH 2/5] Rudimentary support for block comments --- sourcemakeup.php | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/sourcemakeup.php b/sourcemakeup.php index 5d5c192..c71a1fc 100644 --- a/sourcemakeup.php +++ b/sourcemakeup.php @@ -47,6 +47,9 @@ $extensions = 'js,php,css'; $filter = '.min.js'; $dev = false; + + $trimCommentBlockLen = 2; + $trimInlineCommentLen = 3; // ## The Source @@ -107,6 +110,7 @@ $currentblock = 0; $linenumber = 0; $blockCommentMode = false; + $trimCommentLength = 0; // Step through all lines and combine them into codeblocks. Each codeblock can have following contents: // @@ -117,12 +121,50 @@ foreach($lines as $line){ $linenumber++; + + // Check for a comment block mode at the first character. It will + // not catch a comment trailing text. + + $startBlockMode = (substr(trim($line),-2,2) == '/*'); + + // Check for a comment block mode at the end of the line. It will + // not catch a terminating comment followed by code. + + $endBlockCommentMode = (substr(trim($line),-2,2) == '*/'); + + // If the line enters and exists a comment block mode then replace, + // replace with a regular comment. + // If the line enters with a block comment, set the mode + + if ($startBlockCommentMode){ + if ($endBlockCommentMode){ + $line = '// '.substr(trim($line),2); + } else{ + $blockCommentMode = true; + } + } + + // If the line exists a comment block mode at the end of the line, + // then set single line tags and toggle blockCommentMode off. + + if ($endBlockCommentMode) { + $line = '// '.substr(trim($line),0,-2); + $blockCommentMode = false; + } + + // Check for comment tags or comment block mode + if (substr(trim($line),0,2) == '//' || $blockCommentMode){ if (substr(trim($line),0,2) == '//'){ if (!$iscomment){ $currentblock++; } - $blocks[$currentblock]['comment'] .= "\n".substr(trim($line),3); + + $trimCommentLength = ($blockCommentMode) + ? $trimCommentBlockLen + : $trimInlineCommentLen; + + $blocks[$currentblock]['comment'] .= "\n".trim(substr(trim($line), $trimCommentLength)); $blocks[$currentblock]['code'] .= ""; $iscomment = true; if (substr(trim(substr(trim($line),3)),0,3) == '{!}'){ From 6913fc148f2cb70dae642e9984168e6d14a7f7b3 Mon Sep 17 00:00:00 2001 From: DevJamesDev Date: Wed, 31 Jul 2013 15:09:48 +0930 Subject: [PATCH 3/5] Forgot to remove old comment conditions --- sourcemakeup.php | 1 - 1 file changed, 1 deletion(-) diff --git a/sourcemakeup.php b/sourcemakeup.php index c71a1fc..4037813 100644 --- a/sourcemakeup.php +++ b/sourcemakeup.php @@ -155,7 +155,6 @@ // Check for comment tags or comment block mode if (substr(trim($line),0,2) == '//' || $blockCommentMode){ - if (substr(trim($line),0,2) == '//'){ if (!$iscomment){ $currentblock++; } From 2f0fea68db39f2a36be152a44016a8ff615f8d27 Mon Sep 17 00:00:00 2001 From: DevJamesDev Date: Wed, 31 Jul 2013 15:22:37 +0930 Subject: [PATCH 4/5] Wrong variable name bug --- sourcemakeup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sourcemakeup.php b/sourcemakeup.php index 4037813..30e0dda 100644 --- a/sourcemakeup.php +++ b/sourcemakeup.php @@ -125,7 +125,7 @@ // Check for a comment block mode at the first character. It will // not catch a comment trailing text. - $startBlockMode = (substr(trim($line),-2,2) == '/*'); + $startBlockCommentMode = (substr(trim($line),-2,2) == '/*'); // Check for a comment block mode at the end of the line. It will // not catch a terminating comment followed by code. From 82f00a738f91ac58da6987f61b1850412b7c8f64 Mon Sep 17 00:00:00 2001 From: James Date: Wed, 31 Jul 2013 17:11:00 +0930 Subject: [PATCH 5/5] Preliminary static files list --- sourcemakeup.staticfiles.php | 96 ++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 sourcemakeup.staticfiles.php diff --git a/sourcemakeup.staticfiles.php b/sourcemakeup.staticfiles.php new file mode 100644 index 0000000..5831431 --- /dev/null +++ b/sourcemakeup.staticfiles.php @@ -0,0 +1,96 @@ + + + + + + sourceMakeup - File <?php echo $file; ?> + + + + + + + + + + + + + + + + + + + + +
+ +
+
+ + + +

+

+ + + +
+ + + + + + + + + + + +
+ + + Code +
+ +
+ + + \ No newline at end of file