Page 1 of 1

Using ShellCMS

Posted: Fri Apr 21, 2023 2:24 am
by amimelkyr

Hello everyone, I follow up the blog page of BarryK, and I saw that you could use shellCMS, I am currently trying to replicate the instructions in the site https://bkhome.org/shellcms/installing- ... -blog.html but even changing the EDITOR variable from "geany -i" to another editor I continue getting the same error, I've followed the instructions as the post states.

Code: Select all

./shellcms www/news post
./shellcms: line 1630: [: /media/latvia/60c94893-3a9c-40a9-96ea-4b0bfaaec9f1/ADevJournal/shellcms/geany: binary operator expected
EDITOR='geany -i' PWD='/media/latvia/60c94893-3a9c-40a9-96ea-4b0bfaaec9f1/ADevJournal/shellcms/www/news'
EDITOR variable in 'config' file is invalid, aborting
 

I am using ubuntu and not a puppy/EasyOs distro. I have also checked the bash script, and at the begining of the script I've found this, i have also installed geany

Code: Select all

# Config file. Any settings "key=value" written there will override the
# global_variables defaults. Useful to avoid editing shellcms and having to deal
# with merges in VCS
global_config="./cms_config/config"

#20211201 may need to change... 20220520 fix...
if which seamonkey >/dev/null; then
 EDITOR='mozeditor'
else
 if which bluegriffon >/dev/null;then
  EDITOR='bluegriffon'
 else
  EDITOR="geany -i"
 fi
fi

Not sure why shellCMS is trying the editors before trying the one on the config file in the ".cms_config/config". I could manually switch in the if geany -i or any other of the options in the script but not sure if that's the expected behavior.

Feel free to ask me any other questions.


Re: Using ShellCMS

Posted: Fri Apr 21, 2023 4:41 am
by Burunduk
amimelkyr wrote: Fri Apr 21, 2023 2:24 am

but even changing the EDITOR variable from "geany -i" to another editor I continue getting the same error,

It should be just geany without -i option (or use a wrapper script that includes the option).


Re: Using ShellCMS

Posted: Fri Apr 21, 2023 12:06 pm
by BarryK

I posted those instructions in 2017. Although I use shellCMS daily, it has been a very long time since I worked on the code, so memory how it works has become a bit hazy.

I usually use SeaMonkey, as the HTML editor is easy to use. I have also used BlueGriffon recently and that works. Can't recall anything about Geany. Yes, it looks like a wrapper script is required to include that "-i"

Maybe install SeaMonkey and get it working, then later experiment with other editors.


Re: Using ShellCMS

Posted: Fri Apr 21, 2023 2:07 pm
by amimelkyr

Thanks for the answer the key was here

Burunduk wrote: Fri Apr 21, 2023 4:41 am

It should be just geany without -i option (or use a wrapper script that includes the option).

In the shellcms code I've found this

Code: Select all

 if [ -x ${PWD0}/${EDITOR} ];then #ex: mozeditor
  EDITOREXE="${PWD0}/${EDITOR}"
 else
  if which $EDITOR >/dev/null ; then
   EDITOREXE="$EDITOR"
  else
   echo "EDITOR='${EDITOR}' PWD='${PWD}'"
   echo "EDITOR variable in 'config' file is invalid, aborting"
   exit 1
  fi
 fi

So as Burunduk pointed the issue with geany is that it had a switch -i that would cause problems to that part of the do_main(). I've created a somewhat fix for that, tested with vscode with code -n and geany -i and it works and now shellCMS is able to read from the codeblock, not sure why it doesn't read the config file in the cms_config folder. With geany I was able to edit the .htmlraw file save it and make a new post, which in code is creating the new instance but not saving properly, so I will stick with geany.

Code: Select all

 
 #20230421: fix  editor with switches(options) was not working properly because next validation, sanitizing the editor variable first
EDITORALL="$EDITOR"
EDITORNOOPT="${EDITORALL%% *}"
 #20230421

And I'd used the EDITORNOOPT for validations, and EDITORALL for the EDITOREXE definition.

BarryK wrote: Fri Apr 21, 2023 12:06 pm

I posted those instructions in 2017. Although I use shellCMS daily, it has been a very long time since I worked on the code, so memory how it works has become a bit hazy.

I usually use SeaMonkey, as the HTML editor is easy to use. I have also used BlueGriffon recently and that works. Can't recall anything about Geany. Yes, it looks like a wrapper script is required to include that "-i"

Maybe install SeaMonkey and get it working, then later experiment with other editors.

Well I was planning to use Helix https://helix-editor.com/ to edit the code or vscode. But I gave a try to install seamonkey and for some reason I wasn't able to do that in my current installation, so had to stick with code/geany. I will continue checking this CMS as my blog grows, and maybe if you are ok BarryK, I wanted to try to port it if possible to maybe powerShell so it could also be used in windows (I think I could figure it out as a C# dev). Long time had passed when I see your blog for the 1st time trying to setup wary in a pentium III pc back in 2014 for some "special requirement", and to be able to use your software again feels great.

Thank you both.
PD: Not sure if this is the right forum for this topic.


Re: Using ShellCMS

Posted: Sat Apr 22, 2023 12:26 pm
by BarryK
amimelkyr wrote: Fri Apr 21, 2023 2:07 pm

PD: Not sure if this is the right forum for this topic.

No problem.
The Puppy Forum is kind of constrained chaos, you can post on all sorts of topics.
Besides, the easyos.org site is built with shellCMS, so one can argue there is a relationship.


Re: Using ShellCMS

Posted: Sun Apr 23, 2023 1:20 am
by amimelkyr

Well I have edited the shellCMS bash and now in the case for some reason to have more default options for editing the post and supporting "editor with switches" syntax e.g geany -i. The last one is set to vi. Yet not sure why shellCMS on my ubuntu installation won't read the EDITOR variable from the config file, but that's a task for another day.

Options added:
Visual studio code (code -n)
Helix editor (hx)
vi
Also changed the logic so it will be easy if someone wants to add another default option and the editor executable syntax.
I understand the idea of the other editors is WYSIWYG and that the config file should be read, and maybe this is overkill but it will point the person in that case to check about the config file not being read properly.

I'm attaching it so you could take a look and tell me your thoughts.

Hope it will help someone in the future.


Re: Using ShellCMS

Posted: Sun Apr 23, 2023 5:33 am
by Burunduk
amimelkyr wrote: Sun Apr 23, 2023 1:20 am

Yet not sure why shellCMS on my ubuntu installation won't read the EDITOR variable from the config file, but that's a task for another day.

shellcms line 111:

Code: Select all

#hmmm, do not allow ./cms_config/config to override...
EDITOR0="$EDITOR"

and then line 1628 overwrites the setting loaded from the config file:

Code: Select all

 EDITOR="$EDITOR0" #20211201

Maybe ask the author why this is needed. With the latter line commented out, the editor setting from the config file is used.

By the way, it seems you've attached the original shellcms package, no diff here.


Re: Using ShellCMS

Posted: Sun Apr 23, 2023 1:37 pm
by amimelkyr

shellcms line 111:

Code: Select all

#hmmm, do not allow ./cms_config/config to override...
EDITOR0="$EDITOR"

and then line 1628 overwrites the setting loaded from the config file:

Code: Select all

 EDITOR="$EDITOR0" #20211201

Maybe ask the author why this is needed. With the latter line commented out, the editor setting from the config file is used.

By the way, it seems you've attached the original shellcms package, no diff here.

Oh, great thank you for helping me out with that, I didn't check that variable swap, overlooked it thinking that it could be being used somewhere else.

BarryK wrote: Fri Apr 21, 2023 12:06 pm

I posted those instructions in 2017. Although I use shellCMS daily, it has been a very long time since I worked on the code, so memory how it works has become a bit hazy.

I usually use SeaMonkey, as the HTML editor is easy to use. I have also used BlueGriffon recently and that works. Can't recall anything about Geany. Yes, it looks like a wrapper script is required to include that "-i"

So it could be that maybe he got some kind of issue with the syntax when you're using a editor like geany, but as he stated on the blog this is considered important:

BarryK Blog wrote:

Warning
One thing to be wary of with some of these editors. They may be "instance aware", and if an instance is already running, they will open the file in a new tab then return to the calling script immediately. You don't want that. You want the editor to return after exiting. In the case of Geany, it has to be started with "geany -i <file>" to start in a new instance. SeaMonkey composer requires "seamonkey --new-instance -edit <file>" (which is what the cms_config/mozeditor wrapper script does).

So because of that is that I tried to set EDITOR to becode -n in my case. Anyways I edited the post so it has now just the shellcms package and yes I'd uploaded the wrong file.