Difference between revisions of "Free Software Directory:Participate/Script aid"

From Free Software Directory
Jump to: navigation, search
(Created script page.)
 
m (Script: Replace "Minified" column with "Notes".)
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
== Purpose ==
 +
 +
This script aims to help contributors on finding things that might be needed to consider during evaluation of the project/software.
 +
 +
For example, it lists all the MIME/media types of files in the current directory, so that one can find cases of files without complete and corresponding source and also find JavaScript files to look or insert GNU LibreJS syntax.
 +
 +
It also scans files for words related to DOM Level 0 event handlers, so that the contributor can also evaluate if there is need to add GNU LibreJS syntax.
 +
 +
The output is in CSV format. You can use GNU Awk to parse or query such files, before doing so, set <code>FPAT</code> to <code>([^,]*)|(\"[^\"]+\")</code> and <code>RS</code> to <code>\r\n</code>, This variable setting was based on [https://www.gnu.org/software/gawk/manual/html_node/Splitting-By-Content.html the related section in the GNU Awk User's Guide] and on Awk's Texinfo/Info page.
 +
 +
You're welcome to contribute to this script and add your name and contact information to the copyright notice of the script.
 +
 +
== Usage ==
 +
 +
Best if you take the complete corresponding source of the project being evaluated (''e.g.'': when using <code>git clone</code>, you can accomplish this using the <code>--recursive</code> option.
 +
 
<pre style="white-space: pre-wrap">
 
<pre style="white-space: pre-wrap">
 +
git clone --recursive [Some git repository.]
 +
cd [Directory created by git]
 +
[Script aid.] > [Desired text file to store output.]; printf '\a'
 +
</pre>
 +
 +
<code>printf '\a'</code> can be replaced by a command to play an audio file of your choice.
 +
 +
Now leave the script to do its work and wait for the sound clue to continue working on the evaluation.
 +
 +
== Notes ==
 +
 +
* The script is originally meant to be POSIX-compliant.
 +
* The script always takes the current working directory as basis of operation.
 +
* Be aware of false-positives.
 +
* Due to our lack of knowledge on various spoken languages, some things might not be found by the script.
 +
 +
== Script ==
 +
 +
<pre style="white-space: pre-wrap">
 +
#!/bin/sh
 +
 
# FSD Participation Aid: Helps user evaluate entries for the Free Software Directory.
 
# FSD Participation Aid: Helps user evaluate entries for the Free Software Directory.
# Copyright © 2016 Adonay "adfeno" Felipe Nogueira <adfeno@openmailbox.org> <https://libreplanet.org/wiki/User:Adfeno>
+
# Copyright (C) 2016, 2018  Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@hyperbola.info>
#
 
# Copyright (C) 1996 X Consortium
 
#
 
# Permission is hereby granted, free of charge, to any person obtaining
 
# a copy of this software and associated documentation files (the
 
# "Software"), to deal in the Software without restriction, including
 
# without limitation the rights to use, copy, modify, merge, publish,
 
# distribute, sublicense, and/or sell copies of the Software, and to
 
# permit persons to whom the Software is furnished to do so, subject to
 
# the following conditions:
 
#
 
# The above copyright notice and this permission notice shall be
 
# included in all copies or substantial portions of the Software.
 
#
 
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
# NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY
 
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
#
 
# Except as contained in this notice, the name of the X Consortium shall
 
# not be used in advertising or otherwise to promote the sale, use or
 
# other dealings in this Software without prior written authorization
 
# from the X Consortium.
 
#
 
# X Window System is a trademark of X Consortium, Inc.
 
 
 
printf '\n'
 
echo "Path tree starting from: ${PWD}"
 
printf '\n'
 
  
find "." ! \( -type d \) -exec \
+
# This program is free software: you can redistribute it and/or modify
file -i '{}' \;
+
# it under the terms of the GNU Affero General Public License as
 +
# published by the Free Software Foundation, either version 3 of the
 +
# License, or (at your option) any later version.
  
printf '\n'
+
# This program is distributed in the hope that it will be useful, but
echo "Possible licensing and copyright information found."
+
# WITHOUT ANY WARRANTY; without even the implied warranty of
printf '\n'
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 +
# Affero General Public License for more details.
  
find "." ! \( -type d \) -exec \
+
# You should have received a copy of the GNU Affero General Public
grep -in \
+
# License along with this program. If not, see
'\(©\)\|\((c)\)\|\(copyleft\)\|\(copyright\)\|\(licen\)\|\([^[:alnum:]]cc\)\|\([^[:alnum:]][al]\?gpl\)\|\([^[:alnum:]]fdl\)' \
+
# <https://www.gnu.org/licenses/>.
'{}' \; -exec printf "" -print
 
  
printf '\n'
+
# TODO Implement minification check. The "Minified" column is
echo "Possible HTML/JavaScript events found."
+
# currently for note taking of the reviewer.
printf '\n'
 
  
find "." ! \( -type d \) -exec \
+
printf 'Path,MIME,Charset,Copyright or license,Script tag or DOM Level 0,Notes\r\n'
grep -in \
+
find "." ! \( -name '.' -or \( -type d -or -type l \) \) \
'\(onabort\)\|\(onafterprint\)\|\(onautocomplete\)\|\(onautocompleteerror\)\|\(onbeforeprint\)\|\(onbeforeunload\)\|\(onblur\)\|\(oncancel\)\|\(oncanplay\)\|\(oncanplaythrough\)\|\(onchange\)\|\(onclick\)\|\(onclose\)\|\(oncontextmenu\)\|\(oncuechange\)\|\(ondblclick\)\|\(ondrag\)\|\(ondragend\)\|\(ondragenter\)\|\(ondragexit\)\|\(ondragleave\)\|\(ondragover\)\|\(ondragstart\)\|\(ondrop\)\|\(ondurationchange\)\|\(onemptied\)\|\(onended\)\|\(onerror\)\|\(onfocus\)\|\(onhashchange\)\|\(oninput\)\|\(oninvalid\)\|\(onkeydown\)\|\(onkeypress\)\|\(onkeyup\)\|\(onlanguagechange\)\|\(onload\)\|\(onloadeddata\)\|\(onloadedmetadata\)\|\(onloadstart\)\|\(onmessage\)\|\(onmousedown\)\|\(onmouseenter\)\|\(onmouseleave\)\|\(onmousemove\)\|\(onmouseout\)\|\(onmouseover\)\|\(onmouseup\)\|\(onmousewheel\)\|\(onoffline\)\|\(ononline\)\|\(onpagehide\)\|\(onpageshow\)\|\(onpause\)\|\(onplay\)\|\(onplaying\)\|\(onpopstate\)\|\(onprogress\)\|\(onratechange\)\|\(onreadystatechange\)\|\(onreset\)\|\(onresize\)\|\(onscroll\)\|\(onseeked\)\|\(onseeking\)\|\(onselect\)\|\(onshow\)\|\(onsort\)\|\(onstalled\)\|\(onstorage\)\|\(onsubmit\)\|\(onsuspend\)\|\(ontimeupdate\)\|\(ontoggle\)\|\(onunload\)\|\(onvolumechange\)\|\(onwaiting\)' \
+
    -exec sh -c 'file -hi "$0" \
'{}' \; -print
+
            | sed '\''{ s/^\.\//"/g
 +
          s/: /",/g
 +
      s/; charset=/,/g }'\'' \
 +
  | tr -d "\n"' '{}' \; \
 +
    -printf ',' \
 +
    -exec sh -c 'grep -iq \
 +
      -e "\(©\)\|\((c)\)" \
 +
      -e "\(agreement\)\|\(acord\)" \
 +
      -e "\(allow\)\|\(permi\)" \
 +
      -e "\(copyleft\)\|\(copyright\)" \
 +
      -e "\(direito\)\|\(right\)" \
 +
      -e "\(forbid\)\|\(proh?ib\)" \
 +
      -e "\(law\)\|\(lei\)" \
 +
      -e "\(liab\)\|\(respons.?b\)" \
 +
      -e "\(notice\)\|\(notifica\)" \
 +
      -e "\(trademark\)\|\(marca\)" \
 +
      -e "\(warrant\)\|\(garant\)" \
 +
      -e "[^[:alnum:]][al]\?gpl" \
 +
      -e "[^[:alnum:]]as is[^[:alnum:]]" \
 +
      -e "[^[:alnum:]]cc" \
 +
      -e "[^[:alnum:]]condi" \
 +
      -e "[^[:alnum:]]eula" \
 +
      -e "[^[:alnum:]]exclusiv" \
 +
      -e "[^[:alnum:]]fdl" \
 +
      -e "[^[:alnum:]]licen" \
 +
      -e "[^[:alnum:]]patent" \
 +
      -e "[^[:alnum:]]termo?s?[^[:alnum:]]" \
 +
      -e "[^[:alnum:]]transfer" "$0"
 +
  grep_exit_status=$?
 +
  if [ $grep_exit_status -eq 0 ]; then
 +
    printf 1
 +
  elif [ $grep_exit_status -eq 1 ]; then
 +
    printf 0
 +
  else
 +
    printf $grep_exit_status
 +
  fi' '{}' \; \
 +
    -printf ',' \
 +
    -exec sh -c 'grep -iq \
 +
                -e "[^[:alnum:]]script" \
 +
      -e "onabort" \
 +
      -e "onafterprint" \
 +
      -e "onautocomplete" \
 +
      -e "onautocompleteerror" \
 +
      -e "onbeforeprint" \
 +
      -e "onbeforeunload" \
 +
      -e "onblur" \
 +
      -e "oncancel" \
 +
      -e "oncanplay" \
 +
      -e "oncanplaythrough" \
 +
      -e "onchange" \
 +
      -e "onclick" \
 +
      -e "onclose" \
 +
      -e "oncontextmenu" \
 +
      -e "oncuechange" \
 +
      -e "ondblclick" \
 +
      -e "ondrag" \
 +
      -e "ondragend" \
 +
      -e "ondragenter" \
 +
      -e "ondragexit" \
 +
      -e "ondragleave" \
 +
      -e "ondragover" \
 +
      -e "ondragstart" \
 +
      -e "ondrop" \
 +
      -e "ondurationchange" \
 +
      -e "onemptied" \
 +
      -e "onended" \
 +
      -e "onerror" \
 +
      -e "onfocus" \
 +
      -e "onhashchange" \
 +
      -e "oninput" \
 +
      -e "oninvalid" \
 +
      -e "onkeydown" \
 +
      -e "onkeypress" \
 +
      -e "onkeyup" \
 +
      -e "onlanguagechange" \
 +
      -e "onload" \
 +
      -e "onloadeddata" \
 +
      -e "onloadedmetadata" \
 +
      -e "onloadstart" \
 +
      -e "onmessage" \
 +
      -e "onmousedown" \
 +
      -e "onmouseenter" \
 +
      -e "onmouseleave" \
 +
      -e "onmousemove" \
 +
      -e "onmouseout" \
 +
      -e "onmouseover" \
 +
      -e "onmouseup" \
 +
      -e "onmousewheel" \
 +
      -e "onoffline" \
 +
      -e "ononline" \
 +
      -e "onpagehide" \
 +
      -e "onpageshow" \
 +
      -e "onpause" \
 +
      -e "onplay" \
 +
      -e "onplaying" \
 +
      -e "onpopstate" \
 +
      -e "onprogress" \
 +
      -e "onratechange" \
 +
      -e "onreadystatechange" \
 +
      -e "onreset" \
 +
      -e "onresize" \
 +
      -e "onscroll" \
 +
      -e "onseeked" \
 +
      -e "onseeking" \
 +
      -e "onselect" \
 +
      -e "onshow" \
 +
      -e "onsort" \
 +
      -e "onstalled" \
 +
      -e "onstorage" \
 +
      -e "onsubmit" \
 +
      -e "onsuspend" \
 +
      -e "ontimeupdate" \
 +
      -e "ontoggle" \
 +
      -e "onunload" \
 +
      -e "onvolumechange" \
 +
      -e "onwaiting" "$0"
 +
  grep_exit_status=$?
 +
  if [ $grep_exit_status -eq 0 ]; then
 +
    printf 1
 +
  elif [ $grep_exit_status -eq 1 ]; then
 +
    printf 0
 +
  else
 +
    printf $grep_exit_status
 +
  fi' '{}' \; \
 +
    -printf ',' \
 +
    -printf '\r\n'
 
</pre>
 
</pre>

Revision as of 16:47, 29 December 2018

Purpose

This script aims to help contributors on finding things that might be needed to consider during evaluation of the project/software.

For example, it lists all the MIME/media types of files in the current directory, so that one can find cases of files without complete and corresponding source and also find JavaScript files to look or insert GNU LibreJS syntax.

It also scans files for words related to DOM Level 0 event handlers, so that the contributor can also evaluate if there is need to add GNU LibreJS syntax.

The output is in CSV format. You can use GNU Awk to parse or query such files, before doing so, set FPAT to ([^,]*)|(\"[^\"]+\") and RS to \r\n, This variable setting was based on the related section in the GNU Awk User's Guide and on Awk's Texinfo/Info page.

You're welcome to contribute to this script and add your name and contact information to the copyright notice of the script.

Usage

Best if you take the complete corresponding source of the project being evaluated (e.g.: when using git clone, you can accomplish this using the --recursive option.

git clone --recursive [Some git repository.]
cd [Directory created by git]
[Script aid.] > [Desired text file to store output.]; printf '\a'

printf '\a' can be replaced by a command to play an audio file of your choice.

Now leave the script to do its work and wait for the sound clue to continue working on the evaluation.

Notes

  • The script is originally meant to be POSIX-compliant.
  • The script always takes the current working directory as basis of operation.
  • Be aware of false-positives.
  • Due to our lack of knowledge on various spoken languages, some things might not be found by the script.

Script

#!/bin/sh

# FSD Participation Aid: Helps user evaluate entries for the Free Software Directory.
# Copyright (C) 2016, 2018  Adonay "adfeno" Felipe Nogueira <https://libreplanet.org/wiki/User:Adfeno> <adfeno@hyperbola.info>

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public
# License along with this program.  If not, see
# <https://www.gnu.org/licenses/>.

# TODO Implement minification check. The "Minified" column is
# currently for note taking of the reviewer.

printf 'Path,MIME,Charset,Copyright or license,Script tag or DOM Level 0,Notes\r\n'
find "." ! \( -name '.' -or \( -type d -or -type l \) \) \
     -exec sh -c 'file -hi "$0" \
     	      	  | sed '\''{ s/^\.\//"/g
		    	      s/: /",/g
			      s/; charset=/,/g }'\'' \
		  | tr -d "\n"' '{}' \; \
     -printf ',' \
     -exec sh -c 'grep -iq \
		       -e "\(©\)\|\((c)\)" \
		       -e "\(agreement\)\|\(acord\)" \
		       -e "\(allow\)\|\(permi\)" \
		       -e "\(copyleft\)\|\(copyright\)" \
		       -e "\(direito\)\|\(right\)" \
		       -e "\(forbid\)\|\(proh?ib\)" \
		       -e "\(law\)\|\(lei\)" \
		       -e "\(liab\)\|\(respons.?b\)" \
		       -e "\(notice\)\|\(notifica\)" \
		       -e "\(trademark\)\|\(marca\)" \
		       -e "\(warrant\)\|\(garant\)" \
		       -e "[^[:alnum:]][al]\?gpl" \
		       -e "[^[:alnum:]]as is[^[:alnum:]]" \
		       -e "[^[:alnum:]]cc" \
		       -e "[^[:alnum:]]condi" \
		       -e "[^[:alnum:]]eula" \
		       -e "[^[:alnum:]]exclusiv" \
		       -e "[^[:alnum:]]fdl" \
		       -e "[^[:alnum:]]licen" \
		       -e "[^[:alnum:]]patent" \
		       -e "[^[:alnum:]]termo?s?[^[:alnum:]]" \
		       -e "[^[:alnum:]]transfer" "$0"
		  grep_exit_status=$?
		  if [ $grep_exit_status -eq 0 ]; then
		     printf 1
		  elif [ $grep_exit_status -eq 1 ]; then
		     printf 0
		  else
		     printf $grep_exit_status
		  fi' '{}' \; \
     -printf ',' \
     -exec sh -c 'grep -iq \
     	      	       -e "[^[:alnum:]]script" \
		       -e "onabort" \
		       -e "onafterprint" \
		       -e "onautocomplete" \
		       -e "onautocompleteerror" \
		       -e "onbeforeprint" \
		       -e "onbeforeunload" \
		       -e "onblur" \
		       -e "oncancel" \
		       -e "oncanplay" \
		       -e "oncanplaythrough" \
		       -e "onchange" \
		       -e "onclick" \
		       -e "onclose" \
		       -e "oncontextmenu" \
		       -e "oncuechange" \
		       -e "ondblclick" \
		       -e "ondrag" \
		       -e "ondragend" \
		       -e "ondragenter" \
		       -e "ondragexit" \
		       -e "ondragleave" \
		       -e "ondragover" \
		       -e "ondragstart" \
		       -e "ondrop" \
		       -e "ondurationchange" \
		       -e "onemptied" \
		       -e "onended" \
		       -e "onerror" \
		       -e "onfocus" \
		       -e "onhashchange" \
		       -e "oninput" \
		       -e "oninvalid" \
		       -e "onkeydown" \
		       -e "onkeypress" \
		       -e "onkeyup" \
		       -e "onlanguagechange" \
		       -e "onload" \
		       -e "onloadeddata" \
		       -e "onloadedmetadata" \
		       -e "onloadstart" \
		       -e "onmessage" \
		       -e "onmousedown" \
		       -e "onmouseenter" \
		       -e "onmouseleave" \
		       -e "onmousemove" \
		       -e "onmouseout" \
		       -e "onmouseover" \
		       -e "onmouseup" \
		       -e "onmousewheel" \
		       -e "onoffline" \
		       -e "ononline" \
		       -e "onpagehide" \
		       -e "onpageshow" \
		       -e "onpause" \
		       -e "onplay" \
		       -e "onplaying" \
		       -e "onpopstate" \
		       -e "onprogress" \
		       -e "onratechange" \
		       -e "onreadystatechange" \
		       -e "onreset" \
		       -e "onresize" \
		       -e "onscroll" \
		       -e "onseeked" \
		       -e "onseeking" \
		       -e "onselect" \
		       -e "onshow" \
		       -e "onsort" \
		       -e "onstalled" \
		       -e "onstorage" \
		       -e "onsubmit" \
		       -e "onsuspend" \
		       -e "ontimeupdate" \
		       -e "ontoggle" \
		       -e "onunload" \
		       -e "onvolumechange" \
		       -e "onwaiting" "$0"
		  grep_exit_status=$?
		  if [ $grep_exit_status -eq 0 ]; then
		     printf 1
		  elif [ $grep_exit_status -eq 1 ]; then
		     printf 0
		  else
		     printf $grep_exit_status
		  fi' '{}' \; \
     -printf ',' \
     -printf '\r\n'


Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the page “GNU Free Documentation License”.

The copyright and license notices on this page only apply to the text on this page. Any software or copyright-licenses or other similar notices described in this text has its own copyright notice and license, which can usually be found in the distribution or license text itself.