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

From Free Software Directory
Jump to: navigation, search
m (Script: Fixed bug caused by comment in the middle of find command.)
(Clarified how to use GNU Awk, inverted grep logic and made it operate on files' content.)
Line 7: Line 7:
 
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.
 
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 deal with such files, see [https://www.gnu.org/software/gawk/manual/html_node/Splitting-By-Content.html the '''end''' of the related section in the GNU Awk User's Guide] for a useful pattern, and the section itself for explanations.
+
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.
 
You're welcome to contribute to this script and add your name and contact information to the copyright notice of the script.
Line 65: Line 65:
 
  | tr -d "\n"' '{}' \; \
 
  | tr -d "\n"' '{}' \; \
 
     -printf ',' \
 
     -printf ',' \
     -exec sh -c 'echo "$0" \
+
     -exec sh -c 'grep -iq \
            | grep -iq \
+
      -e "\(©\)\|\((c)\)" \
    -e "\(©\)\|\((c)\)" \
+
      -e "\(agreement\)\|\(acord\)" \
-e "\(copyleft\)\|\(copyright\)" \
+
      -e "\(allow\)\|\(permi\)" \
-e "licen" \
+
      -e "\(copyleft\)\|\(copyright\)" \
-e "[^[:alnum:]]cc" \
+
      -e "\(direito\)\|\(right\)" \
-e "[^[:alnum:]][al]\?gpl" \
+
      -e "\(forbid\)\|\(proh?ib\)" \
-e "[^[:alnum:]]fdl"
+
      -e "\(law\)\|\(lei\)" \
  printf $?' '{}' \; \
+
      -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 ',' \
 
     -printf ',' \
     -exec sh -c 'echo "$0" \
+
     -exec sh -c 'grep -iq \
            | grep -iq \
+
                -e "[^[:alnum:]]script" \
    -e "<script" \
+
      -e "onabort" \
-e "onabort" \
+
      -e "onafterprint" \
-e "onafterprint" \
+
      -e "onautocomplete" \
-e "onautocomplete" \
+
      -e "onautocompleteerror" \
-e "onautocompleteerror" \
+
      -e "onbeforeprint" \
-e "onbeforeprint" \
+
      -e "onbeforeunload" \
-e "onbeforeunload" \
+
      -e "onblur" \
-e "onblur" \
+
      -e "oncancel" \
-e "oncancel" \
+
      -e "oncanplay" \
-e "oncanplay" \
+
      -e "oncanplaythrough" \
-e "oncanplaythrough" \
+
      -e "onchange" \
-e "onchange" \
+
      -e "onclick" \
-e "onclick" \
+
      -e "onclose" \
-e "onclose" \
+
      -e "oncontextmenu" \
-e "oncontextmenu" \
+
      -e "oncuechange" \
-e "oncuechange" \
+
      -e "ondblclick" \
-e "ondblclick" \
+
      -e "ondrag" \
-e "ondrag" \
+
      -e "ondragend" \
-e "ondragend" \
+
      -e "ondragenter" \
-e "ondragenter" \
+
      -e "ondragexit" \
-e "ondragexit" \
+
      -e "ondragleave" \
-e "ondragleave" \
+
      -e "ondragover" \
-e "ondragover" \
+
      -e "ondragstart" \
-e "ondragstart" \
+
      -e "ondrop" \
-e "ondrop" \
+
      -e "ondurationchange" \
-e "ondurationchange" \
+
      -e "onemptied" \
-e "onemptied" \
+
      -e "onended" \
-e "onended" \
+
      -e "onerror" \
-e "onerror" \
+
      -e "onfocus" \
-e "onfocus" \
+
      -e "onhashchange" \
-e "onhashchange" \
+
      -e "oninput" \
-e "oninput" \
+
      -e "oninvalid" \
-e "oninvalid" \
+
      -e "onkeydown" \
-e "onkeydown" \
+
      -e "onkeypress" \
-e "onkeypress" \
+
      -e "onkeyup" \
-e "onkeyup" \
+
      -e "onlanguagechange" \
-e "onlanguagechange" \
+
      -e "onload" \
-e "onload" \
+
      -e "onloadeddata" \
-e "onloadeddata" \
+
      -e "onloadedmetadata" \
-e "onloadedmetadata" \
+
      -e "onloadstart" \
-e "onloadstart" \
+
      -e "onmessage" \
-e "onmessage" \
+
      -e "onmousedown" \
-e "onmousedown" \
+
      -e "onmouseenter" \
-e "onmouseenter" \
+
      -e "onmouseleave" \
-e "onmouseleave" \
+
      -e "onmousemove" \
-e "onmousemove" \
+
      -e "onmouseout" \
-e "onmouseout" \
+
      -e "onmouseover" \
-e "onmouseover" \
+
      -e "onmouseup" \
-e "onmouseup" \
+
      -e "onmousewheel" \
-e "onmousewheel" \
+
      -e "onoffline" \
-e "onoffline" \
+
      -e "ononline" \
-e "ononline" \
+
      -e "onpagehide" \
-e "onpagehide" \
+
      -e "onpageshow" \
-e "onpageshow" \
+
      -e "onpause" \
-e "onpause" \
+
      -e "onplay" \
-e "onplay" \
+
      -e "onplaying" \
-e "onplaying" \
+
      -e "onpopstate" \
-e "onpopstate" \
+
      -e "onprogress" \
-e "onprogress" \
+
      -e "onratechange" \
-e "onratechange" \
+
      -e "onreadystatechange" \
-e "onreadystatechange" \
+
      -e "onreset" \
-e "onreset" \
+
      -e "onresize" \
-e "onresize" \
+
      -e "onscroll" \
-e "onscroll" \
+
      -e "onseeked" \
-e "onseeked" \
+
      -e "onseeking" \
-e "onseeking" \
+
      -e "onselect" \
-e "onselect" \
+
      -e "onshow" \
-e "onshow" \
+
      -e "onsort" \
-e "onsort" \
+
      -e "onstalled" \
-e "onstalled" \
+
      -e "onstorage" \
-e "onstorage" \
+
      -e "onsubmit" \
-e "onsubmit" \
+
      -e "onsuspend" \
-e "onsuspend" \
+
      -e "ontimeupdate" \
-e "ontimeupdate" \
+
      -e "ontoggle" \
-e "ontoggle" \
+
      -e "onunload" \
-e "onunload" \
+
      -e "onvolumechange" \
-e "onvolumechange" \
+
      -e "onwaiting" "$0"
-e "onwaiting"
+
  grep_exit_status=$?
            printf $?' '{}' \; \
+
  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 ',' \
 
     -printf '\r\n'
 
     -printf '\r\n'
 
</pre>
 
</pre>

Revision as of 12:27, 9 February 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,Minified\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.