Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support to create and build skins | Issue #66 #65

Merged
merged 12 commits into from
Jun 18, 2020
Merged

feat: Add support to create and build skins | Issue #66 #65

merged 12 commits into from
Jun 18, 2020

Conversation

carloslancha
Copy link
Contributor

@carloslancha carloslancha commented Jun 11, 2020

This pr is, of course, WIP, but I need your feedback to see if this is the right direction (or the one we which we want to go). #66

Purpose of the PR:

Add support to create and build custom skins so we don't need to place all the custom styling in portal, plus we need to change some icons and that only can be done via custom skins.

Creating skins

CKEditor recommends to use one of their base skins to create custom skins so the idea is to be able to choose which one we want to use on the creation moment.

The creation process is pretty simple, we just select the base skin, copy it to our skins folder with the new given name and replace the old name with the new one inside all the files.

Building skins

Following CKEditor docs we need to use their ckbuilder to build the skin (the java one, there's no support for skins on the .sh, maybe we can send them a pr to add it).

For now I just added a script to build the selected skin and place the result inside the ckeditor dist folder. Probably we want to include this as part of the entire build process, but I need some conversation here so we can find the best way to proceed.

@carloslancha carloslancha changed the title Add support to build skins feat: Add support to create and build skins | Issue #66 Jun 11, 2020
Copy link
Contributor

@wincent wincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This approach seems reasonable to me. My only question:

Add support to create and build custom skins

How many of these are we planning on making?

Probably we want to include this as part of the entire build process

Yes, and I imagine, commit the resulting skin files to the repo as well?

ck.sh Outdated
@@ -85,6 +85,53 @@ case "$COMMAND" in
esac
;;

buildskin)
cd skins
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will blow up if you run it before running createskin for the first time.

Rather than mkdir -p skins below, we could just create that directly in the repo and commit it (ie. empty dir with a .gitignore in it so that Git can actually track it) — once we have a skin in here we can remove the .gitignore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gotcha

ck.sh Outdated

select skin in *
do
echo "you selected $skin"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, if I select a bogus entry, $skin will be an unset or an empty string which means that we'll ed up running:

java -jar dev/builder/ckbuilder/2.3.2/ckbuilder.jar --build-skin ../skins/ ../ckeditor/skins/

So we probably need a check for valid input before proceeding.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but here we're selecting a skin from a list, how a bogus entry could be selected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

said nothing

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can type random crap in, as you've probably discovered.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep xD

ck.sh Outdated
createskin)
read -r -p "What is the name of the new skin? " skinName

echo "Which skin do you want to use as base?"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to offer this much flexibility? Won't we be building exactly one skin from one base? If this is not something that we are going to do often, then we might be able to simplify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we don't need it, I need to keep working on not doing more than we need 😅 I'll get rid of it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To help you, you can print these out and sleep with them under your pillow:

Alternatively, you could read them. Another option is starting on wiki.c2.com and spending the next 10 hours following links. 😂

ck.sh Outdated
Comment on lines 117 to 120
mkdir -p skins

# Create folder for the new skin
mkdir skins/"$skinName"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in part what -p is for. Rather than invoking mkdir twice:

     -p      Create intermediate directories as required.  If this option is not specified,
             the full path prefix of each operand must already exist.  On the other hand,
             with this option specified, no error will be reported if a directory given as an
             operand already exists.  Intermediate directories are created with permission
             bits of rwxrwxrwx (0777) as modified by the current umask, plus write and search
             permission for the owner.

@carloslancha
Copy link
Contributor Author

@wincent pr updated

Copy link
Contributor

@wincent wincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable to me. You should probably also update the usage() function in the script, and the README also describes what the subcommands are for and how to use them, so should probably update that too.

ck.sh Outdated
do
if [[ $skin = "" ]]; then
echo "selected skin doesn't exist"
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No semis.

@carloslancha
Copy link
Contributor Author

Oooki doki

@carloslancha
Copy link
Contributor Author

@wincent anything else? :P

@julien
Copy link
Contributor

julien commented Jun 17, 2020

@carloslancha I know this is not automated yet, but I'd suggest running shellcheck on the script just to see if there are any errors - if @wincent thinks it's also a good idea

@carloslancha
Copy link
Contributor Author

carloslancha commented Jun 17, 2020

While trying to build ckeditor to test the new skin I discovered that the skins has to be placed in ckeditor-dev/skins not in ckeditor/skins to make build work. So probably having a task to build only the skin makes no sense, I'm moving it to the build task.

@jbalsas
Copy link
Contributor

jbalsas commented Jun 17, 2020

Once we have our own... I think we probably don't need any other skin, at least it shouldn't be a core feature we provide, to be able to switch skins back to default CKEditor ones.

Just saying, I have no idea if what I said simplifies this or not :D

just-sayin

@wincent
Copy link
Contributor

wincent commented Jun 17, 2020

@jbalsas

Once we have our own... I think we probably don't need any other skin, at least it shouldn't be a core feature we provide, to be able to switch skins back to default CKEditor ones.

This is what I was getting at with this comment:

Do we need to offer this much flexibility? Won't we be building exactly one skin from one base? If this is not something that we are going to do often, then we might be able to simplify it.

@carloslancha

While trying to build ckeditor to test the new skin I discovered that the skins has to be placed in ckeditor-dev/skins not in ckeditor/skins to make build work.

Integration testing for the win!

@wincent
Copy link
Contributor

wincent commented Jun 17, 2020

just-sayin

i-love-you

@carloslancha
Copy link
Contributor Author

@jbalsas @wincent do you want me to get rid of the createskin script then?

@wincent
Copy link
Contributor

wincent commented Jun 17, 2020

It's already there, so leave it. Once the skin is in there, once we can see that it's all working and we don't have to redo things, then we can look at cleaning it up.

@carloslancha
Copy link
Contributor Author

@wincent @jbalsas I've just pushed three commits creating the new skin moono-lexicon (just a copy of moono-lisa for now), setting it as the default skin and moving the skin build process to the general one.

Copy link
Contributor

@wincent wincent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two miniscule nits noted inline, but you should feel free to merge this.

README.md Outdated

1. Create a new skin running `sh ck.sh createskin`.
2. Edit the skin at `/skins/yourskin` folder.
3. Build the sking running `sh ck.sh buildskin`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sking -> skin

ck.sh Outdated
@@ -2,6 +2,8 @@

set -e

CKBUILDER_VERSION="2.3.2"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to do nothing.

@carloslancha carloslancha merged commit bb5c1bb into liferay:master Jun 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants