Skip to content

Commit

Permalink
Added a flag to support generating commercial packages.
Browse files Browse the repository at this point in the history
  • Loading branch information
wwalc committed Aug 18, 2015
1 parent 715a650 commit b922d44
Show file tree
Hide file tree
Showing 25 changed files with 3,688 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/assets/help.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CKBuilder 2.2.0
CKBuilder 2.3.0

USAGE: java -jar ckbuilder.jar

Expand All @@ -24,6 +24,7 @@ SYNOPSIS:
--core create only the core file (ckeditor.js)
--no-zip do not create zip file
--no-tar do not create tar.gz file
--commercial builds a package with commercial license

DESCRIPTION:
Creates CKEditor build in DST folder using source files from SRC folder.
Expand Down
3 changes: 3 additions & 0 deletions src/lib/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ CKBuilder.builder = function( srcDir, dstDir ) {
}
var copied = CKBuilder.tools.fixLineEndings( sourceLocation, targetLocation );
if ( copied ) {
if ( CKBuilder.options.commercial )
CKBuilder.tools.updateCopyrights( targetLocation );

var flag = CKBuilder.tools.processDirectives( targetLocation );
if ( flag.LEAVE_UNMINIFIED )
flags[ targetLocation.getAbsolutePath() ] = flag;
Expand Down
6 changes: 5 additions & 1 deletion src/lib/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ CKBuilder.Controller = function() {
[ null, "revision", [ "NUMBER", "revision number" ], "revision number" ],
[ null, "version", [ "NUMBER", "version number" ], "version number" ],
[ null, "overwrite", false, "overwrite target folder if exists" ],
[ null, "no-ie-checks", false, "Turn off warnings about syntax errors on Internet Explorer, like trailing commas." ],
[ null, "no-ie-checks", false, "turn off warnings about syntax errors on Internet Explorer, like trailing commas" ],
[ null, "no-zip", false, "do not create zip file" ],
[ null, "no-tar", false, "do not create tar.gz file" ],
[ null, "core", false, "build only the core file (ckeditor.js)" ],
[ null, "commercial", false, "builds a package with commercial license" ],
[ null, "name", [ "NAME", "expected name" ], "the expected name of the skin/plugin, used for verification" ],
[ "d", "debug-level", [ "LEVEL", "debug level (0, 1, 2)." ], "sets the debug level" ]
];
Expand Down Expand Up @@ -200,6 +201,9 @@ CKBuilder.Controller.prototype = {
if ( line.hasOption( "core" ) )
CKBuilder.options.core = true;

if ( line.hasOption( "commercial" ) )
CKBuilder.options.commercial = true;

if ( line.hasOption( "revision" ) )
CKBuilder.options.revision = line.getOptionValue( "revision" );

Expand Down
31 changes: 31 additions & 0 deletions src/lib/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,37 @@
return true;
},

/**
* Updates copyright headers in text files.
*
* @param {java.io.File} targetFile
*/
updateCopyrights: function( targetFile ) {
var extension = CKBuilder.io.getExtension( targetFile.getName() ),
bomExtensions = { asp: 1, js: 1 };

if ( !lineEndings[ extension ] ) {
return false;
}

text = CKBuilder.io.readFile( targetFile );
if ( text.indexOf( "Copyright" ) === -1 || text.indexOf( "CKSource" ) === -1 ) {
return;
}

if ( text.indexOf( 'For licensing, see LICENSE.md or http://ckeditor.com/license' ) !== -1 ) {
text = text.replace( 'For licensing, see LICENSE.md or http://ckeditor.com/license', 'This software is covered by CKEditor Commercial License. Usage without proper license is prohibited.' );
CKBuilder.io.saveFile( targetFile, text, bomExtensions[ extension ] );
return;
}

if ( text.indexOf( 'For licensing, see LICENSE.md or [http://ckeditor.com/license](http://ckeditor.com/license)' ) !== -1 ) {
text = text.replace( 'For licensing, see LICENSE.md or [http://ckeditor.com/license](http://ckeditor.com/license)', 'This software is covered by CKEditor Commercial License. Usage without proper license is prohibited.' );
CKBuilder.io.saveFile( targetFile, text, bomExtensions[ extension ] );
return;
}
},

/**
* Returns the copyright statement found in the text
* The Copyright statement starts either with "@license" or with "Copyright".
Expand Down
11 changes: 9 additions & 2 deletions src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@
* @static
*/
copyright: function( eol ) {
var date = new Date();
return "/*" + eol + "Copyright (c) 2003-" + date.getFullYear() + ", CKSource - Frederico Knabben. All rights reserved." + eol + "For licensing, see LICENSE.md or http://ckeditor.com/license" + eol + "*/" + eol;
var copyright,
date = new Date();

if ( CKBuilder.options.commercial )
copyright = "/*" + eol + "This software is covered by CKEditor Commercial License. Usage without proper license is prohibited." + eol + "Copyright (c) 2003-" + date.getFullYear() + ", CKSource - Frederico Knabben. All rights reserved." + eol + "*/" + eol;
else
copyright = "/*" + eol + "Copyright (c) 2003-" + date.getFullYear() + ", CKSource - Frederico Knabben. All rights reserved." + eol + "For licensing, see LICENSE.md or http://ckeditor.com/license" + eol + "*/" + eol;

return copyright;
},

/**
Expand Down
63 changes: 63 additions & 0 deletions test/_assets/copyrights/_translationstatus.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license

af.js Found: 62 Missing: 4
ar.js Found: 51 Missing: 15
bg.js Found: 58 Missing: 8
bn.js Found: 40 Missing: 26
bs.js Found: 29 Missing: 37
ca.js Found: 61 Missing: 5
cs.js Found: 66 Missing: 0
cy.js Found: 66 Missing: 0
da.js Found: 66 Missing: 0
de.js Found: 66 Missing: 0
el.js Found: 59 Missing: 7
en-au.js Found: 38 Missing: 28
en-ca.js Found: 37 Missing: 29
en-gb.js Found: 61 Missing: 5
eo.js Found: 66 Missing: 0
es.js Found: 66 Missing: 0
et.js Found: 66 Missing: 0
eu.js Found: 48 Missing: 18
fa.js Found: 66 Missing: 0
fi.js Found: 66 Missing: 0
fo.js Found: 66 Missing: 0
fr-ca.js Found: 42 Missing: 24
fr.js Found: 66 Missing: 0
gl.js Found: 40 Missing: 26
gu.js Found: 66 Missing: 0
he.js Found: 66 Missing: 0
hi.js Found: 43 Missing: 23
hr.js Found: 66 Missing: 0
hu.js Found: 63 Missing: 3
is.js Found: 41 Missing: 25
it.js Found: 66 Missing: 0
ja.js Found: 62 Missing: 4
ka.js Found: 62 Missing: 4
km.js Found: 40 Missing: 26
ko.js Found: 40 Missing: 26
lt.js Found: 66 Missing: 0
lv.js Found: 40 Missing: 26
mk.js Found: 0 Missing: 66
mn.js Found: 40 Missing: 26
ms.js Found: 39 Missing: 27
nb.js Found: 66 Missing: 0
nl.js Found: 65 Missing: 1
no.js Found: 66 Missing: 0
pl.js Found: 66 Missing: 0
pt-br.js Found: 66 Missing: 0
pt.js Found: 52 Missing: 14
ro.js Found: 61 Missing: 5
ru.js Found: 66 Missing: 0
sk.js Found: 49 Missing: 17
sl.js Found: 48 Missing: 18
sr-latn.js Found: 40 Missing: 26
sr.js Found: 40 Missing: 26
sv.js Found: 62 Missing: 4
th.js Found: 40 Missing: 26
tr.js Found: 66 Missing: 0
ug.js Found: 66 Missing: 0
uk.js Found: 66 Missing: 0
vi.js Found: 66 Missing: 0
zh-cn.js Found: 66 Missing: 0
zh.js Found: 58 Missing: 8
63 changes: 63 additions & 0 deletions test/_assets/copyrights/_translationstatus.txt.correct
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
This software is covered by CKEditor Commercial License. Usage without proper license is prohibited.

af.js Found: 62 Missing: 4
ar.js Found: 51 Missing: 15
bg.js Found: 58 Missing: 8
bn.js Found: 40 Missing: 26
bs.js Found: 29 Missing: 37
ca.js Found: 61 Missing: 5
cs.js Found: 66 Missing: 0
cy.js Found: 66 Missing: 0
da.js Found: 66 Missing: 0
de.js Found: 66 Missing: 0
el.js Found: 59 Missing: 7
en-au.js Found: 38 Missing: 28
en-ca.js Found: 37 Missing: 29
en-gb.js Found: 61 Missing: 5
eo.js Found: 66 Missing: 0
es.js Found: 66 Missing: 0
et.js Found: 66 Missing: 0
eu.js Found: 48 Missing: 18
fa.js Found: 66 Missing: 0
fi.js Found: 66 Missing: 0
fo.js Found: 66 Missing: 0
fr-ca.js Found: 42 Missing: 24
fr.js Found: 66 Missing: 0
gl.js Found: 40 Missing: 26
gu.js Found: 66 Missing: 0
he.js Found: 66 Missing: 0
hi.js Found: 43 Missing: 23
hr.js Found: 66 Missing: 0
hu.js Found: 63 Missing: 3
is.js Found: 41 Missing: 25
it.js Found: 66 Missing: 0
ja.js Found: 62 Missing: 4
ka.js Found: 62 Missing: 4
km.js Found: 40 Missing: 26
ko.js Found: 40 Missing: 26
lt.js Found: 66 Missing: 0
lv.js Found: 40 Missing: 26
mk.js Found: 0 Missing: 66
mn.js Found: 40 Missing: 26
ms.js Found: 39 Missing: 27
nb.js Found: 66 Missing: 0
nl.js Found: 65 Missing: 1
no.js Found: 66 Missing: 0
pl.js Found: 66 Missing: 0
pt-br.js Found: 66 Missing: 0
pt.js Found: 52 Missing: 14
ro.js Found: 61 Missing: 5
ru.js Found: 66 Missing: 0
sk.js Found: 49 Missing: 17
sl.js Found: 48 Missing: 18
sr-latn.js Found: 40 Missing: 26
sr.js Found: 40 Missing: 26
sv.js Found: 62 Missing: 4
th.js Found: 40 Missing: 26
tr.js Found: 66 Missing: 0
ug.js Found: 66 Missing: 0
uk.js Found: 66 Missing: 0
vi.js Found: 66 Missing: 0
zh-cn.js Found: 66 Missing: 0
zh.js Found: 58 Missing: 8
10 changes: 10 additions & 0 deletions test/_assets/copyrights/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* For licensing, see LICENSE.md or http://ckeditor.com/license
*/

CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};
10 changes: 10 additions & 0 deletions test/_assets/copyrights/config.js.correct
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
* This software is covered by CKEditor Commercial License. Usage without proper license is prohibited.
*/

CKEDITOR.editorConfig = function( config ) {
// Define changes to default configuration here. For example:
// config.language = 'fr';
// config.uiColor = '#AADC6E';
};
6 changes: 6 additions & 0 deletions test/_assets/copyrights/dummy.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
*/

p {color:#222}
6 changes: 6 additions & 0 deletions test/_assets/copyrights/dummy.css.correct
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
This software is covered by CKEditor Commercial License. Usage without proper license is prohibited.
*/

p {color:#222}
69 changes: 69 additions & 0 deletions test/_assets/copyrights/pl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.md or http://ckeditor.com/license
*/

/**
* @fileOverview Defines the {@link CKEDITOR.lang} object for the
* Polish language.
*/

/**#@+
@type String
@example
*/

/**
* Contains the dictionary of language entries.
* @namespace
*/
CKEDITOR.lang['pl'] =
{
/**
* The language reading direction. Possible values are "rtl" for
* Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right
* languages (like English).
* @default 'ltr'
*/
dir : 'ltr',

/*
* Screenreader titles. Please note that screenreaders are not always capable
* of reading non-English words. So be careful while translating it.
*/
editorTitle : 'Edytor tekstu sformatowanego, %1, w celu uzyskania pomocy naciśnij ALT 0.',

// Common messages and labels.
common :
{
browseServer : 'Przeglądaj',
url : 'Adres URL',
protocol : 'Protokół',
upload : 'Wyślij',
uploadSubmit : 'Wyślij',

// Put the voice-only part of the label in the span.
unavailable : '%1<span class="cke_accessibility">, niedostępne</span>'
},

contextmenu :
{
options : 'Opcje menu kontekstowego'
},

// Special char dialog.
specialChar :
{
toolbar : 'Wstaw znak specjalny',
title : 'Wybierz znak specjalny',
options : 'Opcje znaków specjalnych'
},

docprops :
{
label : 'Właściwości dokumentu',
title : 'Właściwości dokumentu',
design : 'Projekt strony',
previewHtml : '<p>To jest <strong>przykładowy tekst</strong>. Korzystasz z programu <a href="javascript:void(0)">CKEditor</a>.</p>'
}
};
Loading

0 comments on commit b922d44

Please sign in to comment.