diff --git a/roles/0-DEPRECATED-ROLES/activity-server/tasks/main.yml b/roles/0-DEPRECATED-ROLES/activity-server/tasks/main.yml index 61d4b6baa..d2e59dc6b 100644 --- a/roles/0-DEPRECATED-ROLES/activity-server/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/activity-server/tasks/main.yml @@ -80,7 +80,7 @@ # SEE ALSO THE apache2_module SECTION IN roles/httpd/tasks/main.yml - name: enable mod_expires for debian command: a2enmod expires - when: is_debuntu | bool + when: is_debuntu - name: create the link which enables the site file: src=/etc/apache2/sites-available/xs-activity-server.conf diff --git a/roles/0-DEPRECATED-ROLES/ajenti/tasks/ajenti-wondershaper.yml b/roles/0-DEPRECATED-ROLES/ajenti/tasks/ajenti-wondershaper.yml index 76713a470..4b4d28fe1 100644 --- a/roles/0-DEPRECATED-ROLES/ajenti/tasks/ajenti-wondershaper.yml +++ b/roles/0-DEPRECATED-ROLES/ajenti/tasks/ajenti-wondershaper.yml @@ -1,3 +1,3 @@ - name: Install wondershaper ajenti plugin pip: name="{{ iiab_download_url }}"/ajenti-plugin-wondershaper-0.3.tar.gz - when: internet_available | bool + when: internet_available diff --git a/roles/0-DEPRECATED-ROLES/ajenti/tasks/main.yml b/roles/0-DEPRECATED-ROLES/ajenti/tasks/main.yml index 9dd6def11..156656b0f 100644 --- a/roles/0-DEPRECATED-ROLES/ajenti/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/ajenti/tasks/main.yml @@ -45,7 +45,7 @@ service: name=ajenti enabled=yes state=restarted - when: ajenti_enabled | bool + when: ajenti_enabled - name: Add 'ajenti' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/0-DEPRECATED-ROLES/authserver/tasks/main.yml b/roles/0-DEPRECATED-ROLES/authserver/tasks/main.yml index 6742c9d4e..614374519 100644 --- a/roles/0-DEPRECATED-ROLES/authserver/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/authserver/tasks/main.yml @@ -4,7 +4,7 @@ - name: Install xs-authserver from pypi pip: name=xs-authserver - when: internet_available | bool + when: internet_available - name: install gunicorn package: name=python-gunicorn @@ -48,7 +48,7 @@ service: name=xs-authserver state=restarted enabled=yes - when: authserver_enabled | bool + when: authserver_enabled - name: Add 'authserver' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/0-DEPRECATED-ROLES/docker/tasks/main.yml b/roles/0-DEPRECATED-ROLES/docker/tasks/main.yml index 8c890c7d8..a51f1b8bd 100644 --- a/roles/0-DEPRECATED-ROLES/docker/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/docker/tasks/main.yml @@ -4,7 +4,7 @@ with_items: - docker - python-docker-py - when: docker_install | bool + when: docker_install - name: put the systemd startup file in place template: src=docker.service @@ -31,7 +31,7 @@ service: name=docker state=started enabled=true - when: docker_enabled | bool + when: docker_enabled - name: Disable docker service: name=docker diff --git a/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/enable.yml b/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/enable.yml index 45e08a407..094312866 100644 --- a/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/enable.yml +++ b/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/enable.yml @@ -12,7 +12,7 @@ systemd: name: "{{ apache_service }}" state: restarted - when: apache_enabled | bool + when: apache_enabled # NGINX @@ -32,7 +32,7 @@ systemd: name: nginx state: restarted - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'dokuwiki' variable values to {{ iiab_ini_file }} diff --git a/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/install.yml b/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/install.yml index a640a4deb..00625eff5 100644 --- a/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/install.yml +++ b/roles/0-DEPRECATED-ROLES/dokuwiki/tasks/install.yml @@ -3,7 +3,7 @@ url: "{{ iiab_download_url }}/{{ dokuwiki_version }}.tgz" dest: "{{ downloads_dir }}/" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: Unarchive (unpack) it to /library/{{ dokuwiki_version }} unarchive: diff --git a/roles/0-DEPRECATED-ROLES/ejabberd/tasks/main.yml b/roles/0-DEPRECATED-ROLES/ejabberd/tasks/main.yml index c7631ec10..4aced1e51 100644 --- a/roles/0-DEPRECATED-ROLES/ejabberd/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/ejabberd/tasks/main.yml @@ -34,7 +34,7 @@ # src: ejabberd-iiab.init # dest: /etc/init.d/ejabberd-iiab # mode: 0755 -# when: is_debuntu | bool +# when: is_debuntu #- name: Put the startup script in place - non debian # template: @@ -71,7 +71,7 @@ #name: ejabberd-iiab state: restarted enabled: yes - when: ejabberd_enabled | bool + when: ejabberd_enabled #when: ejabberd_config.changed and ejabberd_enabled #- name: Wait for ejabberd service start diff --git a/roles/0-DEPRECATED-ROLES/homepage/tasks/main.yml b/roles/0-DEPRECATED-ROLES/homepage/tasks/main.yml index d3eccd12c..9a575746f 100644 --- a/roles/0-DEPRECATED-ROLES/homepage/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/homepage/tasks/main.yml @@ -18,4 +18,4 @@ # src: "/etc/{{ apache_conf_dir }}/iiab-homepage.conf" # path: /etc/apache2/sites-enabled/iiab-homepage.conf # state: link - # when: is_debuntu | bool + # when: is_debuntu diff --git a/roles/0-DEPRECATED-ROLES/idmgr/tasks/main.yml b/roles/0-DEPRECATED-ROLES/idmgr/tasks/main.yml index 7958b1135..241e2335a 100644 --- a/roles/0-DEPRECATED-ROLES/idmgr/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/idmgr/tasks/main.yml @@ -42,7 +42,7 @@ with_items: - idmgr - xinetd - when: xo_services_enabled | bool + when: xo_services_enabled - name: Disable idmgr service service: name={{ item }} diff --git a/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/main.yml b/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/main.yml index 5fb548488..f8522daa7 100644 --- a/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/main.yml @@ -1,3 +1,3 @@ - name: Install nodogsplash (Raspbian only) include_tasks: rpi.yml - when: is_raspbian | bool + when: is_raspbian diff --git a/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/rpi.yml b/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/rpi.yml index dd5c3785f..6cc1f6026 100644 --- a/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/rpi.yml +++ b/roles/0-DEPRECATED-ROLES/nodogsplash/tasks/rpi.yml @@ -8,7 +8,7 @@ url: "{{ iiab_download_url }}/{{ nodogsplash_arm_deb }}" dest: "{{ downloads_dir }}/{{ nodogsplash_arm_deb }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available #async: 300 #poll: 5 @@ -43,7 +43,7 @@ name: nodogsplash enabled: yes state: started - when: nodogsplash_enabled | bool + when: nodogsplash_enabled - name: Disable 'nodogsplash' systemd service, if not nodogsplash_enabled systemd: diff --git a/roles/0-DEPRECATED-ROLES/osm/tasks/main.yml b/roles/0-DEPRECATED-ROLES/osm/tasks/main.yml index 20a38fac5..f71f82e39 100644 --- a/roles/0-DEPRECATED-ROLES/osm/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/osm/tasks/main.yml @@ -7,7 +7,7 @@ - libapache2-mod-wsgi - libapache2-mod-xsendfile state: present - when: is_debuntu | bool + when: is_debuntu - name: Install 6 OSM required packages (not debuntu) package: @@ -110,7 +110,7 @@ group: root mode: 0644 backup: no - when: osm_enabled | bool + when: osm_enabled - name: Create softlink osm.conf from sites-enabled to sites-available (debuntu) file: @@ -144,7 +144,7 @@ owner: root group: root state: link - when: osm_enabled | bool + when: osm_enabled - name: Create dir /library/knowledge/modules file: @@ -165,7 +165,7 @@ - { src: 'map.html', dest: "{{ osm_path }}/static/map.html" } - { src: 'l.control.geosearch.js', dest: "{{ osm_path }}/static/lib/leaflet/geosearch/l.control.geosearch.js" } - { src: "{{ osm_path }}/static/map.html", dest: "{{ osm_path }}/static/index.html" } - when: osm_enabled | bool + when: osm_enabled - name: Restart httpd service service: diff --git a/roles/0-DEPRECATED-ROLES/owncloud/tasks/main.yml b/roles/0-DEPRECATED-ROLES/owncloud/tasks/main.yml index 8726df4ae..2ab1c4606 100644 --- a/roles/0-DEPRECATED-ROLES/owncloud/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/owncloud/tasks/main.yml @@ -4,7 +4,7 @@ - name: add a repo def for ubuntu template: dest=/etc/apt/sources.list.d/ src=owncloud.list - when: is_ubuntu | bool + when: is_ubuntu - name: See if the owncloud startup page exists stat: path={{ owncloud_prefix }}/owncloud/index.php @@ -40,7 +40,7 @@ - name: Get the owncloud software get_url: url={{ iiab_download_url }}/{{ owncloud_src_file }} dest={{ downloads_dir }}/{{ owncloud_src_file }} - when: internet_available | bool + when: internet_available async: 300 poll: 5 @@ -54,7 +54,7 @@ - name: Copy it to permanent location /opt unarchive: src={{ downloads_dir }}/{{ owncloud_src_file }} dest={{ owncloud_prefix }} - when: is_F18 | bool + when: is_F18 - name: in Centos, the following config dir is symlink to /etc/owncloud file: path=/etc/owncloud @@ -103,7 +103,7 @@ # Enable owncloud by copying template to httpd config - include_tasks: owncloud_enabled.yml - when: owncloud_enabled | bool + when: owncloud_enabled - name: Add 'owncloud' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/0-DEPRECATED-ROLES/pathagar/tasks/main.yml b/roles/0-DEPRECATED-ROLES/pathagar/tasks/main.yml index 302edb5e0..4b520910b 100644 --- a/roles/0-DEPRECATED-ROLES/pathagar/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/pathagar/tasks/main.yml @@ -29,7 +29,7 @@ - libapache2-mod-wsgi - libxml2-dev - libxslt-dev - when: is_debuntu | bool + when: is_debuntu - name: "Install Pathagar prerequisites: mod_wsgi, libxml2-devel, libxslt-devel (not debuntu)" package: @@ -78,7 +78,7 @@ - django-tagging==0.3.1 - django-sendfile==0.3.6 - lxml==3.4.4 - when: internet_available | bool + when: internet_available - name: Install Pathagar requirements in a virtualenv pip: diff --git a/roles/0-DEPRECATED-ROLES/schooltool/tasks/main.yml b/roles/0-DEPRECATED-ROLES/schooltool/tasks/main.yml index dad203f29..7d1020990 100644 --- a/roles/0-DEPRECATED-ROLES/schooltool/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/schooltool/tasks/main.yml @@ -41,13 +41,13 @@ service: name=docker state=restarted enabled=yes - when: schooltool_enabled | bool + when: schooltool_enabled - name: Enable schooltool service: name=schooltool state=started enabled=yes - when: schooltool_enabled | bool + when: schooltool_enabled - name: Disable schooltool service: name=schooltool diff --git a/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/main.yml b/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/main.yml index bb29c4298..c1cee4459 100644 --- a/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/main.yml @@ -29,7 +29,7 @@ - name: Enable sugar-stats service service: name=sugar-stats-server enabled=yes - when: sugar_stats_enabled | bool + when: sugar_stats_enabled - name: Disable sugar-stats service service: name=sugar-stats-server diff --git a/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/statistics-consolidation.yml b/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/statistics-consolidation.yml index 7ec8a9359..13a04cbfb 100644 --- a/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/statistics-consolidation.yml +++ b/roles/0-DEPRECATED-ROLES/sugar-stats/tasks/statistics-consolidation.yml @@ -4,7 +4,7 @@ - name: Install statistics-consolidation with pip pip: name=stats-consolidation version=2.1.2 - when: internet_available | bool + when: internet_available - name: Install required libraries package: name={{ item }} diff --git a/roles/0-DEPRECATED-ROLES/teamviewer/tasks/install.yml b/roles/0-DEPRECATED-ROLES/teamviewer/tasks/install.yml index 082faf382..44d674b11 100644 --- a/roles/0-DEPRECATED-ROLES/teamviewer/tasks/install.yml +++ b/roles/0-DEPRECATED-ROLES/teamviewer/tasks/install.yml @@ -20,7 +20,7 @@ url: "{{ teamviewer_url }}/{{ teamviewer_rpm_file }}" dest: "{{ yum_packages_dir }}/{{ teamviewer_rpm_file }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available # F22 has issues with yum localinstall exclude for now - name: Do the install of TeamViewer, pulling in any required dependencies diff --git a/roles/0-DEPRECATED-ROLES/teamviewer/tasks/main.yml b/roles/0-DEPRECATED-ROLES/teamviewer/tasks/main.yml index 1a6dfc9c9..5ebfa0c66 100644 --- a/roles/0-DEPRECATED-ROLES/teamviewer/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/teamviewer/tasks/main.yml @@ -6,7 +6,7 @@ - name: Install Teamviewer if intel include_tasks: install.yml - when: teamviewer_install | bool + when: teamviewer_install - name: Add 'teamviewer' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/0-DEPRECATED-ROLES/xovis/tasks/main.yml b/roles/0-DEPRECATED-ROLES/xovis/tasks/main.yml index aab3f668d..287858989 100644 --- a/roles/0-DEPRECATED-ROLES/xovis/tasks/main.yml +++ b/roles/0-DEPRECATED-ROLES/xovis/tasks/main.yml @@ -7,7 +7,7 @@ - python-pip - nodejs - npm - when: internet_available | bool + when: internet_available - name: Determine if xovis is already downloaded stat: path={{ downloadds_dir }}/xovis/xxx @@ -23,7 +23,7 @@ npm: name=kanso global=yes path={{ downloads_dir }} - when: internet_available | bool + when: internet_available - name: move the xovis repo into place shell: "cp -rp {{ downloads_dir }}/xovis {{ xovis_root }}" @@ -37,7 +37,7 @@ - name: Install the xovis python dependencies pip: requirements={{ xovis_root }}/process_stats/requirements.txt - when: internet_available | bool + when: internet_available - name: Update xovis repo with Chart Heading lineinfile: dest="{{ xovis_root }}/index.html" regexp='(.+)

(.*)

' line='\1

{{ xovis_chart_heading }}

' backrefs=yes @@ -49,17 +49,17 @@ service: name=couchdb enabled=yes state=started - when: xovis_enabled | bool + when: xovis_enabled - name: Wait for CouchDB to become ready wait_for: port=5984 delay=1 timeout=5 - when: xovis_enabled | bool + when: xovis_enabled - name: Add admin user command: curl -X PUT {{ xovis_target_host }}/_config/admins/{{ xovis_db_user }} -d "\"{{ xovis_db_password }}\"" - when: xovis_enabled | bool + when: xovis_enabled - name: Check if db exists shell: "kanso listdb | grep {{ xovis_db_name }}" @@ -79,7 +79,7 @@ -d {{ xovis_backup_dir }} --deployment {{ xovis_deployment_name }} --server http://{{ xovis_db_login }}@{{ xovis_target_host }}" - when: xovis_enabled | bool + when: xovis_enabled - name: Add 'xovis' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/0-init/tasks/hostname.yml b/roles/0-init/tasks/hostname.yml index b355aa770..b7bc0e965 100644 --- a/roles/0-init/tasks/hostname.yml +++ b/roles/0-init/tasks/hostname.yml @@ -13,7 +13,7 @@ - name: 'Turn the crank for systemd: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" (debuntu)' shell: hostnamectl set-hostname "{{ iiab_hostname }}.{{ iiab_domain }}" - when: is_debuntu | bool + when: is_debuntu - name: Install /etc/sysconfig/network from template (redhat) template: @@ -22,7 +22,7 @@ owner: root group: root mode: 0644 - when: is_redhat | bool + when: is_redhat # roles/network/tasks/hosts.yml [no longer in use] ALSO did this: - name: 'Put FQDN & hostnames in /etc/hosts: "127.0.0.1 {{ iiab_hostname }}.{{ iiab_domain }} localhost.localdomain localhost {{ iiab_hostname }} box box.lan"' diff --git a/roles/0-init/tasks/main.yml b/roles/0-init/tasks/main.yml index 34a45832d..51ea99727 100644 --- a/roles/0-init/tasks/main.yml +++ b/roles/0-init/tasks/main.yml @@ -20,7 +20,7 @@ # sections once and only once to preserve the install date and git hash. - name: Create IIAB tools and {{ iiab_ini_file }}, if first_run include_tasks: first_run.yml - when: first_run | bool + when: first_run # Copies the latest/known version of iiab-diagnostics into /usr/bin (so it can # be run even if local source tree /opt/iiab/iiab is deleted to conserve disk). @@ -94,7 +94,7 @@ - name: Set port 443 for Admin Console if adm_cons_force_ssl set_fact: gui_port: 443 - when: adm_cons_force_ssl | bool + when: adm_cons_force_ssl - name: "Set iiab_fqdn: {{ iiab_hostname }}.{{ iiab_domain }}" set_fact: @@ -108,7 +108,7 @@ - name: Set hostname if FQDN_changed include_tasks: hostname.yml - when: FQDN_changed | bool + when: FQDN_changed - name: Add 'runtime' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/0-init/tasks/validate_vars.yml b/roles/0-init/tasks/validate_vars.yml index 636f64abf..8e94ff725 100644 --- a/roles/0-init/tasks/validate_vars.yml +++ b/roles/0-init/tasks/validate_vars.yml @@ -13,8 +13,8 @@ # by various scripts, possibly bypassing 0-init? Either way, risks abound :/ # 1. "Ansible 2.8+ ADVISORY: avoid warnings by using 'when: var | bool' for -# top-level BARE vars (in case they're strings, instead of boolean)" -# https://github.com/iiab/iiab/issues/1632 +# top-level BARE vars (in case they're strings, instead of boolean)" per #1632. +# 2020-10-16: NO LONGER NEC, SEE: https://github.com/iiab/iiab/pull/2576 # 2. "How Exactly Does Ansible Parse Boolean Variables?" # https://stackoverflow.com/questions/47877464/how-exactly-does-ansible-parse-boolean-variables/47877502#47877502 @@ -32,6 +32,10 @@ # ~18 words too WILL FAIL as strings (as will any non-empty string...so beware # casting strings to boolean later on...can make the situation worse!) # https://docs.ansible.com/ansible/latest/porting_guides/porting_guide_2.8.html#bare-variables-in-conditionals +# +# 2020-07-08 - Excellent analysis & summary by Jon Spriggs: "In Ansible, +# determine the type of a value, and casting those values to other types" +# https://jon.sprig.gs/blog/post/1801 # 3. "How do i fail a task in Ansible if the variable contains a boolean value? # I want to perform input validation for Ansible playbooks" diff --git a/roles/1-prep/tasks/main.yml b/roles/1-prep/tasks/main.yml index 3a8615c10..f9012c00c 100644 --- a/roles/1-prep/tasks/main.yml +++ b/roles/1-prep/tasks/main.yml @@ -5,7 +5,7 @@ - name: dnsmasq (install now, configure LATER in 'network', after Stage 9) include_tasks: roles/network/tasks/dnsmasq.yml - #when: dnsmasq_install | bool # Flag might be used in future? + #when: dnsmasq_install # Flag might be used in future? - name: Install uuid-runtime package (debuntu) package: @@ -13,7 +13,7 @@ - uuid-runtime - sudo state: present - when: is_debuntu | bool + when: is_debuntu - name: Does /etc/iiab/uuid file exist? stat: @@ -79,17 +79,17 @@ - name: SSHD include_role: name: sshd - when: sshd_install | bool + when: sshd_install - name: IIAB-ADMIN include_role: name: iiab-admin - #when: iiab_admin_install | bool # Flag might be created in future? + #when: iiab_admin_install # Flag might be created in future? - name: OPENVPN include_role: name: openvpn - when: openvpn_install | bool + when: openvpn_install # Debian 10 "Buster" is apparently enabling AppArmor in 2019: # https://wiki.debian.org/AppArmor/Progress @@ -102,7 +102,7 @@ name: apparmor enabled: False state: stopped - when: is_ubuntu | bool + when: is_ubuntu ignore_errors: True - name: Disable SELinux on next boot (OS's other than debuntu) diff --git a/roles/2-common/tasks/iptables.yml b/roles/2-common/tasks/iptables.yml index f0b5a4560..94c1ff003 100644 --- a/roles/2-common/tasks/iptables.yml +++ b/roles/2-common/tasks/iptables.yml @@ -30,7 +30,7 @@ package: name: iptables-persistent state: present - when: is_debuntu | bool + when: is_debuntu - name: Install package iptables-services (OS's other than debuntu) package: @@ -51,4 +51,4 @@ src: iptables dest: /etc/network/if-pre-up.d/iptables mode: '0755' - when: is_debuntu | bool + when: is_debuntu diff --git a/roles/2-common/tasks/packages.yml b/roles/2-common/tasks/packages.yml index 08743aa0b..771d0f436 100644 --- a/roles/2-common/tasks/packages.yml +++ b/roles/2-common/tasks/packages.yml @@ -12,7 +12,7 @@ - xml-common - yum-utils state: present - when: is_redhat | bool + when: is_redhat - name: "Install 6 deb/apt packages: avahi-daemon, exfat-fuse, exfat-utils, inetutils-syslogd, libnss-mdns, wpasupplicant (debuntu)" package: @@ -25,7 +25,7 @@ - libnss-mdns - wpasupplicant state: present - when: is_debuntu | bool + when: is_debuntu - name: "Install 22 common packages: acpid, bridge-utils, bzip2, curl, gawk, hostapd, htop, i2c-tools, logrotate, make, mlocate, netmask, net-tools, ntfs-3g, pandoc, pastebinit, rsync, sqlite3, sudo, tar, unzip, usbutils, wget" package: diff --git a/roles/2-common/tasks/yum-historical.yml b/roles/2-common/tasks/yum-historical.yml index a91498b81..8db268c37 100644 --- a/roles/2-common/tasks/yum-historical.yml +++ b/roles/2-common/tasks/yum-historical.yml @@ -13,18 +13,18 @@ - name: get the createrepo program package: name=createrepo state=present - when: is_redhat | bool + when: is_redhat - name: Create local repo shell: createrepo {{ yum_packages_dir }} - when: is_redhat | bool + when: is_redhat - name: Install local repo file. template: dest=/etc/yum.repos.d/iiab-local.repo src=local.repo owner=root mode=0644 - when: is_redhat | bool + when: is_redhat - name: Install yum packages package: name={{ item }} @@ -36,7 +36,7 @@ - linux-firmware - syslog - xml-common - when: is_redhat | bool + when: is_redhat - name: Install yum packages for Debian package: name={{ item }} @@ -44,7 +44,7 @@ with_items: - inetutils-syslogd - wpasupplicant - when: is_debuntu | bool + when: is_debuntu - name: Install common packages package: name={{ item }} @@ -82,7 +82,7 @@ - glibc # CVE-2015-7547 - bash - iptables - when: is_redhat | bool + when: is_redhat - name: Update common packages (debian) package: name={{ item }} @@ -91,7 +91,7 @@ - libc6 - bash - iptables - when: is_debuntu | bool + when: is_debuntu # instuctions state to start with a fully updated system before starting, stop using diff --git a/roles/3-base-server/tasks/main.yml b/roles/3-base-server/tasks/main.yml index aac0cbf37..4a42df9e2 100644 --- a/roles/3-base-server/tasks/main.yml +++ b/roles/3-base-server/tasks/main.yml @@ -6,7 +6,7 @@ - name: MYSQL include_role: name: mysql - #when: mysql_install | bool + #when: mysql_install # 2020-05-21: Apache role 'httpd' is installed as nec by any of these 7 roles: # @@ -22,12 +22,12 @@ - name: NGINX include_role: name: nginx - #when: nginx_install | bool + #when: nginx_install - name: WWW_BASE (WWW_OPTIONS should be installed later) include_role: name: www_base - #when: www_base_install | bool # Flag might be created in future? + #when: www_base_install # Flag might be created in future? - name: Recording STAGE 3 HAS COMPLETED ===================== lineinfile: diff --git a/roles/4-server-options/tasks/main.yml b/roles/4-server-options/tasks/main.yml index 3739f5982..fd977cc02 100644 --- a/roles/4-server-options/tasks/main.yml +++ b/roles/4-server-options/tasks/main.yml @@ -16,25 +16,25 @@ - name: Install pylibs (IIAB's python libs) include_role: name: pylibs - #when: pylibs_install | bool # Flag might be created in future? + #when: pylibs_install # Flag might be created in future? # Also run by roles/1-prep/tasks/main.yml as required by OpenVPN. - name: SSHD include_role: name: sshd - when: sshd_install | bool + when: sshd_install - name: Install named / BIND include_tasks: roles/network/tasks/named.yml - when: named_install | bool + when: named_install - name: Install dhcpd include_tasks: roles/network/tasks/dhcpd.yml - when: dhcpd_install | bool + when: dhcpd_install - name: Install Squid (and DansGuardian if dansguardian_install) include_tasks: roles/network/tasks/squid.yml - when: squid_install | bool + when: squid_install - name: Install Bluetooth - only on Raspberry Pi include_role: @@ -44,17 +44,17 @@ - name: USB_LIB include_role: name: usb_lib - when: usb_lib_install | bool + when: usb_lib_install - name: CUPS include_role: name: cups - when: cups_install | bool + when: cups_install - name: SAMBA include_role: name: samba - when: samba_install | bool + when: samba_install # 2020-02-17: What was roles/homepage lives in roles/www_options # 2020-10-08: Softcoded iiab_home_url should work (e.g. using local_vars.yml or @@ -65,7 +65,7 @@ - name: WWW_OPTIONS (WWW_BASE should have been installed earlier) include_role: name: www_options - #when: www_options_install | bool # Flag might be created in future? + #when: www_options_install # Flag might be created in future? - name: Recording STAGE 4 HAS COMPLETED ================== lineinfile: diff --git a/roles/6-generic-apps/tasks/main.yml b/roles/6-generic-apps/tasks/main.yml index ae66208b4..7e5bc884c 100644 --- a/roles/6-generic-apps/tasks/main.yml +++ b/roles/6-generic-apps/tasks/main.yml @@ -24,47 +24,47 @@ - name: ELGG include_role: name: elgg - when: elgg_install | bool + when: elgg_install - name: GITEA include_role: name: gitea - when: gitea_install | bool + when: gitea_install - name: LOKOLE include_role: name: lokole - when: lokole_install | bool + when: lokole_install - name: MEDIAWIKI include_role: name: mediawiki - when: mediawiki_install | bool + when: mediawiki_install - name: MOSQUITTO include_role: name: mosquitto - when: mosquitto_install | bool + when: mosquitto_install - name: NODE-RED include_role: name: nodered - when: nodered_install | bool + when: nodered_install - name: NEXTCLOUD include_role: name: nextcloud - when: nextcloud_install | bool + when: nextcloud_install - name: PBX include_role: name: pbx - when: pbx_install | bool + when: pbx_install - name: WORDPRESS include_role: name: wordpress - when: wordpress_install | bool + when: wordpress_install - name: Recording STAGE 6 HAS COMPLETED ==================== lineinfile: diff --git a/roles/7-edu-apps/tasks/main.yml b/roles/7-edu-apps/tasks/main.yml index c181e7924..726b86447 100644 --- a/roles/7-edu-apps/tasks/main.yml +++ b/roles/7-edu-apps/tasks/main.yml @@ -6,27 +6,27 @@ - name: KALITE include_role: name: kalite - when: kalite_install | bool + when: kalite_install - name: KOLIBRI include_role: name: kolibri - when: kolibri_install | bool + when: kolibri_install - name: KIWIX include_role: name: kiwix - when: kiwix_install | bool + when: kiwix_install - name: MOODLE include_role: name: moodle - when: moodle_install | bool + when: moodle_install - name: OSM-VECTOR-MAPS include_role: name: osm-vector-maps - when: osm_vector_maps_install | bool + when: osm_vector_maps_install # UNMAINTAINED - name: OSM @@ -43,7 +43,7 @@ - name: SUGARIZER include_role: name: sugarizer - when: sugarizer_install | bool + when: sugarizer_install - name: Recording STAGE 7 HAS COMPLETED ======================== lineinfile: diff --git a/roles/8-mgmt-tools/tasks/main.yml b/roles/8-mgmt-tools/tasks/main.yml index c882eb632..6a9e6d6a4 100644 --- a/roles/8-mgmt-tools/tasks/main.yml +++ b/roles/8-mgmt-tools/tasks/main.yml @@ -6,32 +6,32 @@ - name: TRANSMISSION include_role: name: transmission - when: transmission_install | bool + when: transmission_install - name: AWSTATS include_role: name: awstats - when: awstats_install | bool + when: awstats_install - name: MONIT include_role: name: monit - when: monit_install | bool + when: monit_install - name: MUNIN include_role: name: munin - when: munin_install | bool + when: munin_install - name: PHPMYADMIN include_role: name: phpmyadmin - when: phpmyadmin_install | bool + when: phpmyadmin_install - name: VNSTAT include_role: name: vnstat - when: vnstat_install | bool + when: vnstat_install - name: Recording STAGE 8 HAS COMPLETED ====================== lineinfile: diff --git a/roles/9-local-addons/tasks/main.yml b/roles/9-local-addons/tasks/main.yml index a3d75b443..b65585ded 100644 --- a/roles/9-local-addons/tasks/main.yml +++ b/roles/9-local-addons/tasks/main.yml @@ -6,29 +6,29 @@ - name: INTERNETARCHIVE include_role: name: internetarchive - when: internetarchive_install | bool + when: internetarchive_install # Is porting to Python 3 complete, and if so does this belong elsewhere? - name: CAPTIVE PORTAL include_role: name: captiveportal - when: captiveportal_install | bool + when: captiveportal_install - name: MINETEST include_role: name: minetest - when: minetest_install | bool + when: minetest_install # KEEP AT THE END as this installs dependencies from Debian's 'testing' branch! - name: CALIBRE include_role: name: calibre - when: calibre_install | bool + when: calibre_install - name: CALIBRE-WEB include_role: name: calibre-web - when: calibreweb_install | bool + when: calibreweb_install - name: Recording STAGE 9 HAS COMPLETED ==================== lineinfile: diff --git a/roles/awstats/tasks/apache.yml b/roles/awstats/tasks/apache.yml index 071064f55..1a4a4c5c3 100644 --- a/roles/awstats/tasks/apache.yml +++ b/roles/awstats/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box/awstats and/or http://box/awstats/awstats.pl via Apache command: a2ensite awstats.conf - when: awstats_enabled | bool + when: awstats_enabled - name: Disable http://box/awstats and/or http://box/awstats/awstats.pl via Apache command: a2dissite awstats.conf diff --git a/roles/awstats/tasks/install.yml b/roles/awstats/tasks/install.yml index 255698cd1..23e98a4b1 100644 --- a/roles/awstats/tasks/install.yml +++ b/roles/awstats/tasks/install.yml @@ -2,7 +2,7 @@ # # - Prepare for a possible future w/o Apache by verifying/refining below... # - 5 'when: apache_installed is defined' -# - 1 'when: nginx_install | bool' +# - 1 'when: nginx_install' # - 8 core stanzas w/o such 'when:' clauses - name: 'Install 3 packages: awstats, openssl, pwauth' @@ -98,7 +98,7 @@ template: src: cgi-bin.php dest: /etc/nginx/ - when: nginx_install | bool + when: nginx_install # RECORD AWStats AS INSTALLED diff --git a/roles/awstats/tasks/main.yml b/roles/awstats/tasks/main.yml index ffe1af2a5..19f92905e 100644 --- a/roles/awstats/tasks/main.yml +++ b/roles/awstats/tasks/main.yml @@ -30,7 +30,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'awstats' variable values to {{ iiab_ini_file }} diff --git a/roles/awstats/tasks/nginx.yml b/roles/awstats/tasks/nginx.yml index 074fb4291..810348fb0 100644 --- a/roles/awstats/tasks/nginx.yml +++ b/roles/awstats/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: awstats-nginx.conf dest: "{{ nginx_conf_dir }}/" # /etc/nginx/conf.d - when: awstats_enabled | bool + when: awstats_enabled - name: Disable http://box/awstats via NGINX, by removing {{ nginx_conf_dir }}/awstats-nginx.conf file: diff --git a/roles/azuracast/tasks/install.yml b/roles/azuracast/tasks/install.yml index 73f02d099..358ce095d 100644 --- a/roles/azuracast/tasks/install.yml +++ b/roles/azuracast/tasks/install.yml @@ -25,7 +25,7 @@ dest: "{{ azuracast_host_dir }}/" timeout: "{{ download_timeout }}" mode: 0755 - when: internet_available | bool + when: internet_available - name: AzuraCast - Download AzuraCast's docker-compose.yml sample from GitHub to {{ azuracast_host_dir }} get_url: @@ -33,7 +33,7 @@ dest: "{{ azuracast_host_dir }}/docker-compose.yml" timeout: "{{ download_timeout }}" mode: 0755 - when: internet_available | bool + when: internet_available - name: AzuraCast - Make changes to docker.sh script so it runs headless lineinfile: diff --git a/roles/bluetooth/tasks/enable.yml b/roles/bluetooth/tasks/enable.yml index 93f2af88f..d249b6e61 100644 --- a/roles/bluetooth/tasks/enable.yml +++ b/roles/bluetooth/tasks/enable.yml @@ -31,7 +31,7 @@ name: bt-pan enabled: yes state: restarted - when: bluetooth_enabled | bool + when: bluetooth_enabled - name: Disable 'bt-pan' service systemd: @@ -47,7 +47,7 @@ name: bt-term enabled: yes state: restarted - when: bluetooth_term_enabled | bool + when: bluetooth_term_enabled - name: Disable 'bt-term' service systemd: diff --git a/roles/calibre-web/tasks/apache.yml b/roles/calibre-web/tasks/apache.yml index 92dae1626..83379c927 100644 --- a/roles/calibre-web/tasks/apache.yml +++ b/roles/calibre-web/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ calibreweb_url1 }}, http://box{{ calibreweb_url2 }}, http://box{{ calibreweb_url3 }} via Apache # http://box/books, http://box/libros, http://box/livres command: a2ensite calibre-web.conf - when: calibreweb_enabled | bool + when: calibreweb_enabled - name: Disable http://box{{ calibreweb_url1 }}, http://box{{ calibreweb_url2 }}, http://box{{ calibreweb_url3 }} via Apache command: a2dissite calibre-web.conf diff --git a/roles/calibre-web/tasks/install.yml b/roles/calibre-web/tasks/install.yml index dee048b87..9f58f1383 100644 --- a/roles/calibre-web/tasks/install.yml +++ b/roles/calibre-web/tasks/install.yml @@ -33,7 +33,7 @@ force: yes depth: 1 version: "{{ calibreweb_version }}" # e.g. master, 0.6.5 - when: internet_available | bool + when: internet_available ## Ansible Pip Bug: Cannot use 'chdir' with 'env' https://github.com/ansible/ansible/issues/37912 (Patch landed) #- name: Download calibre-web dependencies into vendor subdirectory. @@ -50,7 +50,7 @@ virtualenv: "{{ calibreweb_venv_path }}" # /usr/local/calibre-web-py3 virtualenv_site_packages: no virtualenv_command: python3 -m venv {{ calibreweb_venv_path }} - when: internet_available | bool + when: internet_available - name: Install /etc/systemd/system/calibre-web.service from template template: @@ -80,7 +80,7 @@ - roles/calibre-web/files/metadata.db - roles/calibre-web/files/metadata_db_prefs_backup.json when: not metadatadb.stat.exists - #when: calibreweb_provision | bool + #when: calibreweb_provision - name: Provision/Copy default admin settings to {{ calibreweb_config }}/app.db IF metadata.db did not exist copy: @@ -91,7 +91,7 @@ mode: '0644' backup: yes when: not metadatadb.stat.exists - #when: calibreweb_provision | bool + #when: calibreweb_provision # RECORD Calibre-Web AS INSTALLED diff --git a/roles/calibre-web/tasks/main.yml b/roles/calibre-web/tasks/main.yml index 76d294179..eebc0e0b5 100644 --- a/roles/calibre-web/tasks/main.yml +++ b/roles/calibre-web/tasks/main.yml @@ -30,7 +30,7 @@ daemon_reload: yes enabled: yes state: restarted - when: calibreweb_enabled | bool + when: calibreweb_enabled - name: Disable & Stop 'calibre-web' systemd service, if not calibreweb_enabled systemd: @@ -45,7 +45,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'calibre-web' variable values to {{ iiab_ini_file }} diff --git a/roles/calibre-web/tasks/nginx.yml b/roles/calibre-web/tasks/nginx.yml index 9c9a0f63e..046bc65b8 100644 --- a/roles/calibre-web/tasks/nginx.yml +++ b/roles/calibre-web/tasks/nginx.yml @@ -5,7 +5,7 @@ template: src: calibre-web-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/calibre-web-nginx.conf" # /etc/nginx/conf.d - when: calibreweb_enabled | bool + when: calibreweb_enabled - name: Disable http://box{{ calibreweb_url1 }} via NGINX, by removing {{ nginx_conf_dir }}/calibre-web-nginx.conf file: diff --git a/roles/calibre/tasks/install.yml b/roles/calibre/tasks/install.yml index 856fbfbf9..764515763 100644 --- a/roles/calibre/tasks/install.yml +++ b/roles/calibre/tasks/install.yml @@ -14,7 +14,7 @@ # #- name: Install Calibre via .debs (if Raspbian) # command: scripts/calibre-install-latest-rpi.sh # WORKED for Calibre 3.33.1 on 2018-10-23. And Calibre 3.28 on 2018-07-26 (PR #971). Likewise for Calibre 3.26.x. FAILED with Calibre 3.24+ ("calibre : Depends: python-pyqt5 (>= 5.10.1+dfsg-2) but 5.10.1+dfsg-1+rpi1 is to be installed") since June 2018. -# when: is_raspbian | bool +# when: is_raspbian # 2020-04-29: Can work *IF* you do 'apt install python2' and change top line # of /opt/iiab/downloads/calibre-installer.py from '#!/usr/bin/env python2' diff --git a/roles/calibre/tasks/main.yml b/roles/calibre/tasks/main.yml index e5c9d11c1..2c05b42de 100644 --- a/roles/calibre/tasks/main.yml +++ b/roles/calibre/tasks/main.yml @@ -44,7 +44,7 @@ name: calibre-serve enabled: yes state: restarted - when: calibre_enabled | bool + when: calibre_enabled - name: Disable & Stop 'calibre-serve' service, if not calibre_enabled systemd: @@ -59,7 +59,7 @@ # #- name: Enable/Disable/Restart NGINX if primary # include_tasks: nginx.yml -# when: nginx_enabled | bool +# when: nginx_enabled - name: Add 'calibre' variable values to {{ iiab_ini_file }} diff --git a/roles/calibre/tasks/py-installer.yml b/roles/calibre/tasks/py-installer.yml index 85dca3f3f..29f9b3265 100644 --- a/roles/calibre/tasks/py-installer.yml +++ b/roles/calibre/tasks/py-installer.yml @@ -12,7 +12,7 @@ backup: yes timeout: "{{ download_timeout }}" register: calibre_download_output - when: internet_available | bool + when: internet_available # ALWAYS DEFINED, DESPITE get_url DOCUMENTATION CLAIM... # - debug: @@ -53,4 +53,4 @@ shell: "{{ downloads_dir }}/calibre-installer.py >> /dev/null" #args: # creates: /usr/bin/calibre-uninstall - when: internet_available | bool + when: internet_available diff --git a/roles/captiveportal/tasks/enable-or-disable.yml b/roles/captiveportal/tasks/enable-or-disable.yml index 4d289fe86..c1b390a6d 100644 --- a/roles/captiveportal/tasks/enable-or-disable.yml +++ b/roles/captiveportal/tasks/enable-or-disable.yml @@ -15,7 +15,7 @@ template: src: captiveportal.ini.j2 dest: /etc/uwsgi/apps-enabled/captiveportal.ini - when: captiveportal_enabled | bool + when: captiveportal_enabled - name: Delete /etc/uwsgi/apps-enabled/captiveportal.ini (if not captiveportal_enabled) file: @@ -28,7 +28,7 @@ src: /etc/nginx/sites-available/capture.conf path: /etc/nginx/sites-enabled/capture.conf state: link - when: captiveportal_enabled | bool + when: captiveportal_enabled - name: Delete symlink /etc/nginx/sites-enabled/capture.conf to disable NGINX to location definitions for checkurls (if not captiveportal_enabled) file: @@ -38,7 +38,7 @@ - name: Run iiab-divert-to-nginx to generate diversion lists for NGINX shell: /usr/sbin/iiab-divert-to-nginx - when: captiveportal_enabled | bool + when: captiveportal_enabled - name: Delete /etc/dnsmasq.d/capture to make sure dnsmasq is not diverting (if not captiveportal_enabled) file: @@ -60,10 +60,10 @@ systemd: name: dnsmasq state: stopped - when: dnsmasq_enabled | bool + when: dnsmasq_enabled - name: Start 'dnsmasq' systemd service (if dnsmasq_enabled) systemd: name: dnsmasq state: started - when: dnsmasq_enabled | bool + when: dnsmasq_enabled diff --git a/roles/cups/tasks/enable-or-disable.yml b/roles/cups/tasks/enable-or-disable.yml index 970ec9e85..866536c97 100644 --- a/roles/cups/tasks/enable-or-disable.yml +++ b/roles/cups/tasks/enable-or-disable.yml @@ -1,6 +1,6 @@ - name: Enable http://box/cups via Apache (MIGHT NOT WORK?) command: a2ensite cups.conf - when: cups_enabled | bool + when: cups_enabled - name: Disable http://box/cups via Apache command: a2dissite cups.conf @@ -18,7 +18,7 @@ with_items: - cups - cups-browsed - when: cups_enabled | bool + when: cups_enabled #when: cups_enabled and not is_F18 # - name: Enable & Start 'cups' systemd service (Fedora 18, for XO laptops) @@ -30,7 +30,7 @@ - name: Permit headless admin of CUPS -- only works when CUPS daemon is running (if cups_enabled) shell: "cupsctl --remote-admin" - when: cups_enabled | bool + when: cups_enabled - name: Disable & Stop 'cups' & 'cups-browsed' systemd services (OS's other than Fedora 18) systemd: diff --git a/roles/elgg/tasks/apache.yml b/roles/elgg/tasks/apache.yml index d08fbd87b..d0cbd1c35 100644 --- a/roles/elgg/tasks/apache.yml +++ b/roles/elgg/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ elgg_url }} via Apache # http://box/elgg command: a2ensite elgg.conf - when: elgg_enabled | bool + when: elgg_enabled - name: Disable http://box{{ elgg_url }} via Apache # http://box/elgg command: a2dissite elgg.conf diff --git a/roles/elgg/tasks/install.yml b/roles/elgg/tasks/install.yml index f0e9f8483..8098501a6 100644 --- a/roles/elgg/tasks/install.yml +++ b/roles/elgg/tasks/install.yml @@ -34,7 +34,7 @@ url: "{{ iiab_download_url }}/elgg-{{ elgg_version }}.zip" dest: "{{ downloads_dir }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: Check for existence of /opt/elgg-{{ elgg_version }}/index.php stat: diff --git a/roles/elgg/tasks/main.yml b/roles/elgg/tasks/main.yml index 2462d2f2e..1e873879b 100644 --- a/roles/elgg/tasks/main.yml +++ b/roles/elgg/tasks/main.yml @@ -31,7 +31,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'elgg' variable values to {{ iiab_ini_file }} diff --git a/roles/elgg/tasks/nginx.yml b/roles/elgg/tasks/nginx.yml index a0213cb71..3a4a302d1 100644 --- a/roles/elgg/tasks/nginx.yml +++ b/roles/elgg/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: elgg-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/elgg-nginx.conf" # /etc/nginx/conf.d - when: elgg_enabled | bool + when: elgg_enabled - name: Disable http://box{{ elgg_url }} via NGINX, by removing {{ nginx_conf_dir }}/elgg-nginx.conf # http://box/elgg file: diff --git a/roles/elgg/tasks/setup.yml b/roles/elgg/tasks/setup.yml index f28086fd5..5d50139fa 100644 --- a/roles/elgg/tasks/setup.yml +++ b/roles/elgg/tasks/setup.yml @@ -28,7 +28,7 @@ name: "{{ dbname }}" state: import target: /tmp/elggdb.sql - when: create_elgg_database.changed | bool + when: create_elgg_database.changed - name: Remove database dump /tmp/elggdb.sql file: diff --git a/roles/gitea/tasks/apache.yml b/roles/gitea/tasks/apache.yml index e61effc08..2d9989371 100644 --- a/roles/gitea/tasks/apache.yml +++ b/roles/gitea/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ gitea_url }} via Apache # http://box/gitea command: a2ensite gitea.conf - when: gitea_enabled | bool + when: gitea_enabled - name: Disable http://box{{ gitea_url }} via Apache # http://box/gitea command: a2dissite gitea.conf diff --git a/roles/gitea/tasks/install.yml b/roles/gitea/tasks/install.yml index 1981222f2..4f28e1d6e 100644 --- a/roles/gitea/tasks/install.yml +++ b/roles/gitea/tasks/install.yml @@ -48,13 +48,13 @@ url: "{{ gitea_download_url }}" dest: "{{ gitea_install_path }}" mode: '0775' - when: internet_available | bool + when: internet_available - name: Download Gitea GPG signature get_url: url: "{{ gitea_integrity_url }}" dest: "{{ gitea_checksum_path }}" - when: internet_available | bool + when: internet_available - name: Verify Gitea binary with GPG signature shell: | diff --git a/roles/gitea/tasks/main.yml b/roles/gitea/tasks/main.yml index e62580de6..c40297a23 100644 --- a/roles/gitea/tasks/main.yml +++ b/roles/gitea/tasks/main.yml @@ -30,7 +30,7 @@ daemon_reload: yes enabled: yes state: restarted - when: gitea_enabled | bool + when: gitea_enabled - name: Disable & Stop 'gitea' systemd service, if not gitea_enabled systemd: @@ -45,7 +45,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'gitea' to list of services at {{ iiab_ini_file }} diff --git a/roles/gitea/tasks/nginx.yml b/roles/gitea/tasks/nginx.yml index e0a16c567..2014a0d03 100644 --- a/roles/gitea/tasks/nginx.yml +++ b/roles/gitea/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: gitea-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/gitea-nginx.conf" # /etc/nginx/conf.d - when: gitea_enabled | bool + when: gitea_enabled - name: Disable http://box{{ gitea_url }} via NGINX, by removing {{ nginx_conf_dir }}/gitea-nginx.conf file: diff --git a/roles/httpd/tasks/homepage.yml b/roles/httpd/tasks/homepage.yml index e1c610d5f..64b91cc2d 100644 --- a/roles/httpd/tasks/homepage.yml +++ b/roles/httpd/tasks/homepage.yml @@ -10,7 +10,7 @@ - name: "IN CASE NGINX IS DISABLED: Enable IIAB pages via Apache (e.g. on port 80) by running 'a2ensite iiab-homepage.conf'" command: a2ensite iiab-homepage.conf - #when: apache_enabled | bool + #when: apache_enabled # - name: Disable IIAB pages via Apache (e.g. on port 80) by running 'a2dissite iiab-homepage.conf', if not apache_enabled" # command: a2dissite iiab-homepage.conf diff --git a/roles/httpd/tasks/install.yml b/roles/httpd/tasks/install.yml index ddb4a48ce..d0ccbb079 100644 --- a/roles/httpd/tasks/install.yml +++ b/roles/httpd/tasks/install.yml @@ -8,8 +8,8 @@ # - "php{{ php_version }}" # - "php{{ php_version }}-curl" state: present - when: is_debuntu | bool -# when: is_debian | bool + when: is_debuntu +# when: is_debian # - name: 'Install 2 packages: apache2, php (ubuntu)' # package: @@ -19,7 +19,7 @@ # - "{{ apache_service }}" # apache2 on Debuntu # - php # state: present -# when: is_ubuntu | bool +# when: is_ubuntu # 2019-05-30: It's interesting that http://box.lan/admin and everything seems # to work even without php{{ php_version }}-sqlite3 as confirmed on Ubuntu @@ -49,7 +49,7 @@ - php - php-curl state: present - when: is_redhat | bool + when: is_redhat # Remove symlinks for mpm_event, replace with mpm_prefork - name: Remove both mpm_event symlinks from /etc/apache2/mods-enabled (debuntu) @@ -59,7 +59,7 @@ with_items: - mpm_event.conf - mpm_event.load - when: is_debuntu | bool + when: is_debuntu - name: Create both mpm_prefork symlinks from /etc/apache2/mods-enabled to /etc/apache2/mods-available (debuntu) file: @@ -69,7 +69,7 @@ with_items: - mpm_prefork.conf - mpm_prefork.load - when: is_debuntu | bool + when: is_debuntu - name: 'Enable 5 Apache modules, as with "a2enmod" command: headers, proxy, proxy_html, proxy_http, rewrite (for http://box/kiwix, http://box/kolibri, http://box/nodered, etc--if debuntu)' apache2_module: @@ -80,7 +80,7 @@ - proxy_html - proxy_http - rewrite - when: is_debuntu | bool + when: is_debuntu - name: Remove 000-default.conf from /etc/apache2 and /etc/apache2/sites-enabled (debuntu) file: @@ -89,7 +89,7 @@ with_items: - /etc/apache2/000-default.conf # Not nec on Raspbian. Is this really still needed elsewhere? - /etc/apache2/sites-enabled/000-default.conf - when: is_debuntu | bool + when: is_debuntu - name: Create Apache's pid dir /var/run/{{ apache_user }} file: @@ -128,7 +128,7 @@ - name: "IN CASE NGINX IS DISABLED: Enable IIAB pages via Apache (e.g. on port 80) by running 'a2ensite 010-iiab.conf'" command: a2ensite 010-iiab.conf - #when: apache_enabled | bool + #when: apache_enabled # - name: Disable IIAB pages via Apache (e.g. on port 80) by running 'a2dissite 010-iiab.conf', if not apache_enabled" # command: a2dissite 010-iiab.conf diff --git a/roles/httpd/tasks/main.yml b/roles/httpd/tasks/main.yml index 01f43ba38..9ac3dee47 100644 --- a/roles/httpd/tasks/main.yml +++ b/roles/httpd/tasks/main.yml @@ -36,7 +36,7 @@ name: "{{ apache_service }}" enabled: yes state: started # No need to restart, as many IIAB apps do that later - when: apache_enabled | bool + when: apache_enabled - name: Disable & Stop {{ apache_service }} systemd service, if not apache_enabled systemd: diff --git a/roles/internetarchive/tasks/apache.yml b/roles/internetarchive/tasks/apache.yml index fdaae8853..200708b33 100644 --- a/roles/internetarchive/tasks/apache.yml +++ b/roles/internetarchive/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable internetarchive.conf via Apache (for short URL http://box/archive eventually?) if internetarchive_enabled command: a2ensite internetarchive.conf - when: internetarchive_enabled | bool + when: internetarchive_enabled - name: Disable internetarchive.conf via Apache, if not internetarchive_enabled command: a2dissite internetarchive.conf diff --git a/roles/internetarchive/tasks/install.yml b/roles/internetarchive/tasks/install.yml index 180118367..8cfcfc272 100644 --- a/roles/internetarchive/tasks/install.yml +++ b/roles/internetarchive/tasks/install.yml @@ -46,7 +46,7 @@ args: chdir: "{{ internetarchive_dir }}" creates: "{{ internetarchive_dir }}/node_modules/@internetarchive/dweb-mirror/internetarchive" - when: internet_available | bool + when: internet_available - name: mkdir {{ content_base }}/archiveorg file: diff --git a/roles/internetarchive/tasks/main.yml b/roles/internetarchive/tasks/main.yml index 06988fc2a..9bd1c6ae2 100644 --- a/roles/internetarchive/tasks/main.yml +++ b/roles/internetarchive/tasks/main.yml @@ -59,7 +59,7 @@ daemon_reload: yes enabled: yes state: restarted - when: internetarchive_enabled | bool + when: internetarchive_enabled - name: Disable & Stop 'internetarchive' systemd service, if not internetarchive_enabled systemd: @@ -74,7 +74,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'internetarchive' variable values to {{ iiab_ini_file }} diff --git a/roles/internetarchive/tasks/nginx.yml b/roles/internetarchive/tasks/nginx.yml index f443d502c..0469e58c4 100644 --- a/roles/internetarchive/tasks/nginx.yml +++ b/roles/internetarchive/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: internetarchive-nginx.conf.j2 # TO DO: roles/internetarchive/templates/internetarchive-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/internetarchive-nginx.conf" # /etc/nginx/conf.d - when: internetarchive_enabled | bool + when: internetarchive_enabled - name: Disable http://box/archive via NGINX, by removing {{ nginx_conf_dir }}/internetarchive-nginx.conf file: diff --git a/roles/kalite/tasks/install.yml b/roles/kalite/tasks/install.yml index 473761d68..6960f73fd 100644 --- a/roles/kalite/tasks/install.yml +++ b/roles/kalite/tasks/install.yml @@ -3,13 +3,13 @@ url: "{{ kalite_requirements }}" dest: "{{ pip_packages_dir }}/kalite.txt" # /opt/iiab/pip-packages/kalite.txt timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available # 2020-01-19: https://github.com/piwheels/packages/issues/74 says the following is not longer needed... #- name: Run 'mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139' as "TEMPORARY" workaround (2020-01-17) for piwheels.org's setuptools Python 2/3 brokenness on RPi (https://github.com/iiab/iiab/issues/2139) # command: mv /etc/pip.conf /etc/pip.conf.see-iiab-issue-2139 # ignore_errors: yes -# when: is_raspbian | bool +# when: is_raspbian - name: Install python2, if Raspbian/Debian > 10 or Ubuntu > 19 package: @@ -41,7 +41,7 @@ virtualenv_command: /usr/bin/virtualenv virtualenv_python: python2.7 extra_args: "--no-cache-dir" - when: internet_available | bool + when: internet_available - name: "Install from templates: venv wrapper /usr/bin/kalite, systemd unit file kalite-serve.service" template: diff --git a/roles/kalite/tasks/main.yml b/roles/kalite/tasks/main.yml index 18f46dc65..7335cafbe 100644 --- a/roles/kalite/tasks/main.yml +++ b/roles/kalite/tasks/main.yml @@ -30,7 +30,7 @@ name: kalite-serve enabled: yes state: restarted - when: kalite_enabled | bool + when: kalite_enabled - name: Disable & Stop 'kalite-serve' service, if not kalite_enabled systemd: diff --git a/roles/kiwix/files/test_zim/Notes.txt b/roles/kiwix/files/test_zim/Notes.txt index 29ec89f74..8408b80b4 100644 --- a/roles/kiwix/files/test_zim/Notes.txt +++ b/roles/kiwix/files/test_zim/Notes.txt @@ -1,8 +1,8 @@ -Make zim with - -./zimwriterfs --welcome=index.html --favicon=favicon.png --language=eng --title=test --description=test --creator=XSCE --publisher=XSCE /root/devel/test_zim test.zim - -Create library.xml with - -/opt/schoolserver/kiwix/bin/kiwix-manage /library/zims/library.xml add /library/zims/content/test.zim - +Make zim with + +./zimwriterfs --welcome=index.html --favicon=favicon.png --language=eng --title=test --description=test --creator=XSCE --publisher=XSCE /root/devel/test_zim test.zim + +Create library.xml with + +/opt/schoolserver/kiwix/bin/kiwix-manage /library/zims/library.xml add /library/zims/content/test.zim + diff --git a/roles/kiwix/tasks/apache.yml b/roles/kiwix/tasks/apache.yml index 8e01dd6e9..f82b35d22 100644 --- a/roles/kiwix/tasks/apache.yml +++ b/roles/kiwix/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ kiwix_url }} via Apache # http://box/kiwix command: a2ensite kiwix.conf - when: kiwix_enabled | bool + when: kiwix_enabled - name: Disable http://box{{ kiwix_url }} via Apache # http://box/kiwix command: a2dissite kiwix.conf diff --git a/roles/kiwix/tasks/enable-or-disable.yml b/roles/kiwix/tasks/enable-or-disable.yml index c64b6e911..f74c7cc6c 100644 --- a/roles/kiwix/tasks/enable-or-disable.yml +++ b/roles/kiwix/tasks/enable-or-disable.yml @@ -4,7 +4,7 @@ daemon_reload: yes enabled: yes state: restarted - when: kiwix_enabled | bool + when: kiwix_enabled - name: Disable & Stop 'kiwix-serve' systemd service systemd: @@ -42,4 +42,4 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled diff --git a/roles/kiwix/tasks/install.yml b/roles/kiwix/tasks/install.yml index acc981a31..d0c645842 100644 --- a/roles/kiwix/tasks/install.yml +++ b/roles/kiwix/tasks/install.yml @@ -37,7 +37,7 @@ url: "{{ iiab_download_url }}/{{ kiwix_src_file }}" # http://download.iiab.io/packages dest: "{{ downloads_dir }}/{{ kiwix_src_file }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: Create dir {{ iiab_zim_path }} and subdirs {content, index} for Kiwix ZIM files file: @@ -95,7 +95,7 @@ # - proxy_html # - proxy_http # - rewrite -# when: is_debuntu | bool +# when: is_debuntu # 4. INSTALL iiab-make-kiwix-lib*, kiwix-serve.service, kiwix.conf for Apache diff --git a/roles/kiwix/tasks/kiwix-apk.yml b/roles/kiwix/tasks/kiwix-apk.yml index 1a9e61d11..15bd04352 100644 --- a/roles/kiwix/tasks/kiwix-apk.yml +++ b/roles/kiwix/tasks/kiwix-apk.yml @@ -1,18 +1,18 @@ -# Install kiwix android app apk for downloading -- name: Create {{ doc_root }}{{ kiwix_apk_url }} directory - file: - path: "{{ doc_root }}{{ kiwix_apk_url }}" - state: directory - -- name: Download kiwix.apk to {{ doc_root }}{{ kiwix_apk_url }} - get_url: - url: "{{ kiwix_apk_src }}" # https://download.kiwix.org/release/kiwix-android/kiwix.apk - dest: "{{ doc_root }}{{ kiwix_apk_url }}" - timeout: "{{ download_timeout }}" - when: internet_available | bool - -- name: Symlink {{ doc_root }}{{ kiwix_apk_url }}/zims -> {{ iiab_zim_path }}/content - file: - src: "{{ iiab_zim_path }}/content" # /library/zims/content - path: "{{ doc_root }}{{ kiwix_apk_url }}/zims" # /library/www/html/softare/kiwix/zims - state: link +# Install kiwix android app apk for downloading +- name: Create {{ doc_root }}{{ kiwix_apk_url }} directory + file: + path: "{{ doc_root }}{{ kiwix_apk_url }}" + state: directory + +- name: Download kiwix.apk to {{ doc_root }}{{ kiwix_apk_url }} + get_url: + url: "{{ kiwix_apk_src }}" # https://download.kiwix.org/release/kiwix-android/kiwix.apk + dest: "{{ doc_root }}{{ kiwix_apk_url }}" + timeout: "{{ download_timeout }}" + when: internet_available + +- name: Symlink {{ doc_root }}{{ kiwix_apk_url }}/zims -> {{ iiab_zim_path }}/content + file: + src: "{{ iiab_zim_path }}/content" # /library/zims/content + path: "{{ doc_root }}{{ kiwix_apk_url }}/zims" # /library/www/html/softare/kiwix/zims + state: link diff --git a/roles/kiwix/tasks/nginx.yml b/roles/kiwix/tasks/nginx.yml index 74be639aa..0fd9c674a 100644 --- a/roles/kiwix/tasks/nginx.yml +++ b/roles/kiwix/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: kiwix-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/kiwix-nginx.conf" # /etc/nginx/conf.d - when: kiwix_enabled | bool + when: kiwix_enabled - name: Disable http://box{{ kiwix_url }} via NGINX, by removing {{ nginx_conf_dir }}/kiwix-nginx.conf # http://box/kiwix file: diff --git a/roles/kiwix/templates/iiab-make-kiwix-lib b/roles/kiwix/templates/iiab-make-kiwix-lib index f36857064..083b87116 100644 --- a/roles/kiwix/templates/iiab-make-kiwix-lib +++ b/roles/kiwix/templates/iiab-make-kiwix-lib @@ -1,33 +1,33 @@ -#!/bin/bash - -LOCK_PATH=/run/lock/kiwix -mkdir -p $LOCK_PATH - -WAITLOCK="$LOCK_PATH/make-kiwix-lib-wait.LCK"; -RUNLOCK="$LOCK_PATH/kiwix-lib-access.LCK"; -KIWIXLIB={{ kiwix_library_xml }} - -exec 200>$WAITLOCK; -exec 201>$RUNLOCK; - -if flock -n -e 200; then : - echo 'Waiting to run iiab-make-kiwix-lib.py' - # wait for up to 5 min - flock -x -w 300 201 - flock -u 200 # unlock queue - echo "Now running iiab-make-kiwix-lib.py" - # write to {{ kiwix_library_xml }}.tmp to minimize kiwix down - # zim map could be out of sync for a few seconds - # using new version that does deltas - cp $KIWIXLIB $KIWIXLIB.tmp - /usr/bin/iiab-make-kiwix-lib.py - {{ systemctl_program }} stop kiwix-serve - rm $KIWIXLIB - mv $KIWIXLIB.tmp $KIWIXLIB - {{ systemctl_program }} start kiwix-serve -else - echo "Can't get wait lock for iiab-make-kiwix-lib.py"; - exit 1; -fi -echo 'Finished making Kiwix library.xml' -exit 0 +#!/bin/bash + +LOCK_PATH=/run/lock/kiwix +mkdir -p $LOCK_PATH + +WAITLOCK="$LOCK_PATH/make-kiwix-lib-wait.LCK"; +RUNLOCK="$LOCK_PATH/kiwix-lib-access.LCK"; +KIWIXLIB={{ kiwix_library_xml }} + +exec 200>$WAITLOCK; +exec 201>$RUNLOCK; + +if flock -n -e 200; then : + echo 'Waiting to run iiab-make-kiwix-lib.py' + # wait for up to 5 min + flock -x -w 300 201 + flock -u 200 # unlock queue + echo "Now running iiab-make-kiwix-lib.py" + # write to {{ kiwix_library_xml }}.tmp to minimize kiwix down + # zim map could be out of sync for a few seconds + # using new version that does deltas + cp $KIWIXLIB $KIWIXLIB.tmp + /usr/bin/iiab-make-kiwix-lib.py + {{ systemctl_program }} stop kiwix-serve + rm $KIWIXLIB + mv $KIWIXLIB.tmp $KIWIXLIB + {{ systemctl_program }} start kiwix-serve +else + echo "Can't get wait lock for iiab-make-kiwix-lib.py"; + exit 1; +fi +echo 'Finished making Kiwix library.xml' +exit 0 diff --git a/roles/kolibri/tasks/apache.yml b/roles/kolibri/tasks/apache.yml index d2a2056af..8ca861288 100644 --- a/roles/kolibri/tasks/apache.yml +++ b/roles/kolibri/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ kolibri_url }} via Apache # http://box/kolibri command: a2ensite kolibri.conf - when: kolibri_enabled | bool + when: kolibri_enabled - name: Disable http://box{{ kolibri_url }} via Apache # http://box/kolibri command: a2dissite kolibri.conf diff --git a/roles/kolibri/tasks/install.yml b/roles/kolibri/tasks/install.yml index 182647b3d..f4c8ed30e 100644 --- a/roles/kolibri/tasks/install.yml +++ b/roles/kolibri/tasks/install.yml @@ -37,7 +37,7 @@ environment: KOLIBRI_HOME: "{{ kolibri_home }}" # these don't do a thing for now but KOLIBRI_USER: "{{ kolibri_user }}" # both can't hurt & Might Help Later - when: internet_available | bool + when: internet_available - name: 'Install from template: /etc/systemd/system/kolibri.service' template: @@ -64,7 +64,7 @@ # ignore_errors: yes # become: yes # become_user: "{{ kolibri_user }}" -# when: kolibri_provision | bool +# when: kolibri_provision # 2020-01-05: Deprecated per https://github.com/iiab/iiab/issues/2103 #- name: Set Kolibri default language ({{ kolibri_language }}) @@ -72,7 +72,7 @@ # ignore_errors: yes # become: yes # become_user: "{{ kolibri_user }}" -# when: kolibri_provision | bool +# when: kolibri_provision - name: 'Provision Kolibri, while setting: facility name, admin acnt / password, preset type, and language' shell: > @@ -84,7 +84,7 @@ ignore_errors: yes become: yes become_user: "{{ kolibri_user }}" - when: kolibri_provision | bool + when: kolibri_provision - name: chown -R {{ kolibri_user }}:{{ apache_user }} {{ kolibri_home }} for good measure? file: @@ -92,7 +92,7 @@ owner: "{{ kolibri_user }}" # kolibri group: "{{ apache_user }}" # www-data (on Debian/Ubuntu/Raspbian) recurse: yes - when: kolibri_provision | bool + when: kolibri_provision # 2019-10-07: Moved to roles/httpd/tasks/main.yml diff --git a/roles/kolibri/tasks/main.yml b/roles/kolibri/tasks/main.yml index 6c88a06e7..999adbd40 100644 --- a/roles/kolibri/tasks/main.yml +++ b/roles/kolibri/tasks/main.yml @@ -35,7 +35,7 @@ daemon_reload: yes enabled: yes state: started - when: kolibri_enabled | bool + when: kolibri_enabled - name: Disable & Stop 'kolibri' systemd service, if not kolibri_enabled systemd: @@ -50,7 +50,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'kolibri' variable values to {{ iiab_ini_file }} # /etc/iiab/iiab.ini diff --git a/roles/kolibri/tasks/nginx.yml b/roles/kolibri/tasks/nginx.yml index 51bc4742f..379339b68 100644 --- a/roles/kolibri/tasks/nginx.yml +++ b/roles/kolibri/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: kolibri-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/kolibri-nginx.conf" # /etc/nginx/conf.d - when: kolibri_enabled | bool + when: kolibri_enabled - name: Disable http://box{{ kolibri_url }} via NGINX, by removing {{ nginx_conf_dir }}/kolibri-nginx.conf # http://box/kolibri file: diff --git a/roles/lokole/tasks/apache.yml b/roles/lokole/tasks/apache.yml index bcfc50676..e5a3bf46b 100644 --- a/roles/lokole/tasks/apache.yml +++ b/roles/lokole/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ lokole_url }} via Apache # http://box/lokole command: a2ensite lokole.conf - when: lokole_enabled | bool + when: lokole_enabled - name: Disable http://box{{ lokole_url }} via Apache # http://box/lokole command: a2dissite lokole.conf diff --git a/roles/lokole/tasks/install.yml b/roles/lokole/tasks/install.yml index 247224f4f..01fb9a716 100644 --- a/roles/lokole/tasks/install.yml +++ b/roles/lokole/tasks/install.yml @@ -37,7 +37,7 @@ virtualenv_command: python3 -m venv "{{ lokole_venv }}" extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/ when: - - internet_available | bool + - internet_available - lokole_commit is defined # For development purposes -- To install a given pip version of Lokole, add @@ -51,7 +51,7 @@ virtualenv_command: python3 -m venv "{{ lokole_venv }}" extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/ when: - - internet_available | bool + - internet_available - lokole_version is defined - name: "DEFAULT: pip install opwen_email_client (Lokole, latest available version) from PyPI to {{ lokole_venv }}, if above vars both UNdefined" @@ -61,7 +61,7 @@ virtualenv_command: python3 -m venv "{{ lokole_venv }}" extra_args: --no-cache-dir # To avoid caching issues e.g. soon after new releases hit https://pypi.org/project/opwen-email-client/ when: - - internet_available | bool + - internet_available - lokole_commit is undefined and lokole_version is undefined - name: Compile translations @@ -99,7 +99,7 @@ src: lokole.conf.j2 dest: "/etc/{{ apache_conf_dir }}/lokole.conf" mode: 0644 - when: apache_install | bool + when: apache_install - name: Install unit files {lokole.service, celery.service, celerybeat.service, lokole_restarter.service} into /etc/systemd/system, from template template: diff --git a/roles/lokole/tasks/main.yml b/roles/lokole/tasks/main.yml index 103848e6d..aaccc44e5 100644 --- a/roles/lokole/tasks/main.yml +++ b/roles/lokole/tasks/main.yml @@ -27,14 +27,14 @@ - name: Do a 'systemctl daemon-reload' if lokole_enabled systemd: daemon_reload: yes - when: lokole_enabled | bool + when: lokole_enabled - name: Enable & Restart {lokole, celery, celerybeat, lokole_restarter} systemd services, if lokole_enabled systemd: name: "{{ item }}" enabled: yes state: restarted - when: lokole_enabled | bool + when: lokole_enabled with_items: - lokole - celery @@ -60,7 +60,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'lokole' variable values to {{ iiab_ini_file }} diff --git a/roles/lokole/tasks/nginx.yml b/roles/lokole/tasks/nginx.yml index 954192577..9ba756bf8 100644 --- a/roles/lokole/tasks/nginx.yml +++ b/roles/lokole/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: lokole-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/lokole-nginx.conf" # /etc/nginx/conf.d - when: lokole_enabled | bool + when: lokole_enabled - name: Disable http://box{{ lokole_url }} via NGINX, by removing {{ nginx_conf_dir }}/lokole-nginx.conf # http://box/lokole file: diff --git a/roles/mediawiki/tasks/apache.yml b/roles/mediawiki/tasks/apache.yml index d7669f548..9ca953343 100644 --- a/roles/mediawiki/tasks/apache.yml +++ b/roles/mediawiki/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ mediawiki_url }} via Apache # http://box/wiki command: a2ensite mediawiki.conf - when: mediawiki_enabled | bool + when: mediawiki_enabled - name: Disable http://box{{ mediawiki_url }} via Apache # http://box/wiki command: a2dissite mediawiki.conf diff --git a/roles/mediawiki/tasks/install.yml b/roles/mediawiki/tasks/install.yml index 561aaccd8..085567fbf 100644 --- a/roles/mediawiki/tasks/install.yml +++ b/roles/mediawiki/tasks/install.yml @@ -12,7 +12,7 @@ timeout: "{{ download_timeout }}" #force: yes #backup: yes - when: internet_available | bool + when: internet_available - name: Unarchive (unpack) it to permanent location {{ mediawiki_abs_path }} ({{ apache_user }}:{{ apache_user }}, u+rw,g+r,o+r) unarchive: diff --git a/roles/mediawiki/tasks/main.yml b/roles/mediawiki/tasks/main.yml index 10d15f273..f7b494da9 100644 --- a/roles/mediawiki/tasks/main.yml +++ b/roles/mediawiki/tasks/main.yml @@ -30,7 +30,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'mediawiki' variable values to {{ iiab_ini_file }} diff --git a/roles/mediawiki/tasks/nginx.yml b/roles/mediawiki/tasks/nginx.yml index 5c4caee08..85c4e1429 100644 --- a/roles/mediawiki/tasks/nginx.yml +++ b/roles/mediawiki/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: mediawiki-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/mediawiki-nginx.conf" # /etc/nginx.conf.d - when: mediawiki_enabled | bool + when: mediawiki_enabled - name: Disable http://box{{ mediawiki_url }} & http://box{{ mediawiki_url2 }} via NGINX, by removing {{ nginx_conf_dir }}/mediawiki-nginx.conf # http://box/wiki & http://box/mediawiki file: diff --git a/roles/minetest/tasks/calc_vars.yml b/roles/minetest/tasks/calc_vars.yml index a10f00d69..4a6dc7b23 100644 --- a/roles/minetest/tasks/calc_vars.yml +++ b/roles/minetest/tasks/calc_vars.yml @@ -7,7 +7,7 @@ # only works if server run as root minetest_runas_user: root minetest_runas_group: root - when: is_raspbian | bool + when: is_raspbian # For other installs - name: Set some facts for other platforms diff --git a/roles/minetest/tasks/enable.yml b/roles/minetest/tasks/enable.yml index c69e1ac79..a83166b76 100644 --- a/roles/minetest/tasks/enable.yml +++ b/roles/minetest/tasks/enable.yml @@ -5,7 +5,7 @@ name: minetest-server enabled: yes state: restarted - when: minetest_enabled | bool + when: minetest_enabled - name: Disable & Stop 'minetest-server' service systemd: diff --git a/roles/minetest/tasks/minetest_install.yml b/roles/minetest/tasks/minetest_install.yml index c2685b059..354907526 100644 --- a/roles/minetest/tasks/minetest_install.yml +++ b/roles/minetest/tasks/minetest_install.yml @@ -24,7 +24,7 @@ line: "{{ item.line }}" with_items: - { regexp: '^mg_name = ', line: 'mg_name = flat' } - when: minetest_flat_world | bool + when: minetest_flat_world - name: Create /library/games/minetest/worlds/world file: diff --git a/roles/minetest/tasks/rpi_minetest_install.yml b/roles/minetest/tasks/rpi_minetest_install.yml index 16f86308b..fdd59e247 100644 --- a/roles/minetest/tasks/rpi_minetest_install.yml +++ b/roles/minetest/tasks/rpi_minetest_install.yml @@ -49,4 +49,4 @@ with_items: - { src: 'minetest.conf.j2', dest: '/etc/minetest/minetest.conf' } - { src: 'minetest-server.service.j2', dest: '/etc/systemd/system/minetest-server.service' } - when: minetest_install | bool + when: minetest_install diff --git a/roles/mongodb/tasks/install.yml b/roles/mongodb/tasks/install.yml index eb40db071..fe6a65df1 100644 --- a/roles/mongodb/tasks/install.yml +++ b/roles/mongodb/tasks/install.yml @@ -92,7 +92,7 @@ repo: deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/4.4 multiverse state: present filename: mongodb-org - when: is_linuxmint | bool + when: is_linuxmint - name: Use mongodb-org's Ubuntu repo for all non-Mint Ubuntu - 64bit only apt_repository: diff --git a/roles/monit/tasks/enable-or-disable.yml b/roles/monit/tasks/enable-or-disable.yml index c5996710a..5cedf80dd 100644 --- a/roles/monit/tasks/enable-or-disable.yml +++ b/roles/monit/tasks/enable-or-disable.yml @@ -11,7 +11,7 @@ name: monit enabled: yes state: restarted - when: monit_enabled | bool + when: monit_enabled - name: Disable & Stop 'monit' service, if not monit_enabled systemd: diff --git a/roles/moodle/tasks/apache.yml b/roles/moodle/tasks/apache.yml index 1c9076179..b0a59d6df 100644 --- a/roles/moodle/tasks/apache.yml +++ b/roles/moodle/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box/moodle via Apache command: a2ensite 022-moodle.conf - when: moodle_enabled | bool + when: moodle_enabled - name: Disable http://box/moodle via Apache command: a2dissite 022-moodle.conf diff --git a/roles/moodle/tasks/install.yml b/roles/moodle/tasks/install.yml index e421c2e21..f28594d10 100644 --- a/roles/moodle/tasks/install.yml +++ b/roles/moodle/tasks/install.yml @@ -36,7 +36,7 @@ - php{{ php_version }}-mbstring # 2020-06-15: Now required by Moodle 3.9+ - php{{ php_version }}-cli # 2020-06-15: In the past this included (above) mbstring? However this is not true on Ubuntu Server 20.04 LTS. state: present - when: is_debuntu | bool + when: is_debuntu # - name: "Install package: php{{ php_version }}-zip (Ubuntu or Debian 9+)" # package: @@ -46,7 +46,7 @@ # - name: "Install package: php-pclzip (debian-8)" # package: # name: php-pclzip -# when: is_debian_8 | bool +# when: is_debian_8 - name: Does {{ moodle_base }}/config-dist.php exist? (indicating Moodle is/was installed) stat: @@ -135,7 +135,7 @@ name: postgresql-iiab state: restarted #enabled: yes - #when: moodle_enabled | bool + #when: moodle_enabled - name: (Re)Start '{{ apache_service }}' systemd service systemd: diff --git a/roles/moodle/tasks/main.yml b/roles/moodle/tasks/main.yml index 4312f9ddd..3189b590c 100644 --- a/roles/moodle/tasks/main.yml +++ b/roles/moodle/tasks/main.yml @@ -30,7 +30,7 @@ # deamon_reload: yes # state: started # enabled: yes -# when: moodle_enabled | bool +# when: moodle_enabled # # # if the only service using the backend db disable if not running # - name: Disable 'postgresql-iiab' systemd service, if 'not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)' @@ -44,7 +44,7 @@ set_fact: postgresql_install: True postgresql_enabled: True - when: moodle_enabled | bool + when: moodle_enabled - name: "Set 'postgresql_enabled: False' if 'not moodle_enabled and not (pathagar_enabled is defined and pathagar_enabled)'" set_fact: @@ -63,7 +63,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'moodle' variable values to {{ iiab_ini_file }} diff --git a/roles/moodle/tasks/nginx.yml b/roles/moodle/tasks/nginx.yml index 4537e44cd..65a8eef08 100644 --- a/roles/moodle/tasks/nginx.yml +++ b/roles/moodle/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: moodle-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/moodle-nginx.conf" # /etc/nginx/conf.d - when: moodle_enabled | bool + when: moodle_enabled - name: Disable http://box/moodle via NGINX, by removing {{ nginx_conf_dir }}/moodle-nginx.conf file: diff --git a/roles/mosquitto/tasks/enable-or-disable.yml b/roles/mosquitto/tasks/enable-or-disable.yml index 7aacfffbb..7978fbfc4 100644 --- a/roles/mosquitto/tasks/enable-or-disable.yml +++ b/roles/mosquitto/tasks/enable-or-disable.yml @@ -4,7 +4,7 @@ name: mosquitto enabled: yes state: restarted - when: mosquitto_enabled | bool + when: mosquitto_enabled - name: Disable & Stop 'mosquitto' systemd service, if not mosquitto_enabled systemd: diff --git a/roles/munin/tasks/apache.yml b/roles/munin/tasks/apache.yml index 150f74ad3..7556b94a1 100644 --- a/roles/munin/tasks/apache.yml +++ b/roles/munin/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box/munin via Apache command: a2ensite munin24.conf - when: munin_enabled | bool + when: munin_enabled - name: Disable http://box/munin via Apache command: a2dissite munin24.conf diff --git a/roles/munin/tasks/install.yml b/roles/munin/tasks/install.yml index bcf6b05fe..4eae4a387 100644 --- a/roles/munin/tasks/install.yml +++ b/roles/munin/tasks/install.yml @@ -7,7 +7,7 @@ - libcgi-fast-perl - libapache2-mod-fcgid state: present - when: is_debuntu | bool + when: is_debuntu - name: "Install 2 packages: munin, munin-node (OS's other than debuntu)" package: @@ -46,7 +46,7 @@ - /usr/share/munin/plugins/mysql_queries - /usr/share/munin/plugins/mysql_slowqueries - /usr/share/munin/plugins/mysql_threads - when: mysql_enabled | bool + when: mysql_enabled # RECORD Munin AS INSTALLED diff --git a/roles/munin/tasks/main.yml b/roles/munin/tasks/main.yml index 8af6a95aa..29447f1b3 100644 --- a/roles/munin/tasks/main.yml +++ b/roles/munin/tasks/main.yml @@ -30,7 +30,7 @@ daemon_reload: yes enabled: yes state: started - when: munin_enabled | bool + when: munin_enabled - name: Disable & Stop 'munin-node' systemd service systemd: @@ -45,7 +45,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'munin' variable values to {{ iiab_ini_file }} diff --git a/roles/munin/tasks/nginx.yml b/roles/munin/tasks/nginx.yml index 455e154b8..cd1094451 100644 --- a/roles/munin/tasks/nginx.yml +++ b/roles/munin/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: munin24-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/munin24-nginx.conf" # /etc/nginx/conf.d - when: munin_enabled | bool + when: munin_enabled - name: Disable http://box/munin via NGINX, by installing {{ nginx_conf_dir }}/munin24-nginx.conf file: diff --git a/roles/mysql/tasks/install.yml b/roles/mysql/tasks/install.yml index 3ab4f370e..5b4d3bc34 100644 --- a/roles/mysql/tasks/install.yml +++ b/roles/mysql/tasks/install.yml @@ -11,7 +11,7 @@ - mariadb-server - mariadb-client state: present - when: is_debuntu | bool + when: is_debuntu # 2020-07-11: # 10 PHP package installs moved to roles/www_base/tasks/main.yml diff --git a/roles/mysql/tasks/main.yml b/roles/mysql/tasks/main.yml index c0d24368a..196be1c67 100644 --- a/roles/mysql/tasks/main.yml +++ b/roles/mysql/tasks/main.yml @@ -37,7 +37,7 @@ daemon_reload: yes state: started enabled: yes - when: mysql_enabled | bool + when: mysql_enabled # We had to start MySQL in order to configure it, now turn if off if not enabled - name: Disable & Stop MySQL ({{ mysql_service }}) systemd service, if not mysql_enabled diff --git a/roles/network/tasks/avahi.yml b/roles/network/tasks/avahi.yml index b0fde81fe..15a62de8e 100644 --- a/roles/network/tasks/avahi.yml +++ b/roles/network/tasks/avahi.yml @@ -3,7 +3,7 @@ name: avahi createhome: no shell: /bin/false - when: is_debuntu | bool + when: is_debuntu - name: Install avahi announce config file /etc/avahi/services/schoolserver.service template: @@ -37,7 +37,7 @@ copy: src: /usr/share/doc/avahi-daemon/examples/ssh.service dest: /etc/avahi/services/ - when: is_debuntu | bool + when: is_debuntu - name: Set ssh port for avahi lineinfile: diff --git a/roles/network/tasks/dansguardian.yml b/roles/network/tasks/dansguardian.yml index 619644bcf..5384ab528 100644 --- a/roles/network/tasks/dansguardian.yml +++ b/roles/network/tasks/dansguardian.yml @@ -19,7 +19,7 @@ owner: dansguardian group: dansguardian mode: '0640' - when: is_debuntu | bool + when: is_debuntu - name: Install /etc/dansguardian/dansguardian.conf from template (CentOS) template: diff --git a/roles/network/tasks/detected_network.yml b/roles/network/tasks/detected_network.yml index d87db5ca6..fec38c805 100644 --- a/roles/network/tasks/detected_network.yml +++ b/roles/network/tasks/detected_network.yml @@ -53,7 +53,7 @@ - name: Check /etc/network/interfaces for gateway shell: grep {{ device_gw }} /etc/network/interfaces | wc -l - when: is_debuntu | bool + when: is_debuntu register: wan_file - name: Setting wan_in_interfaces diff --git a/roles/network/tasks/dhcpd.yml b/roles/network/tasks/dhcpd.yml index 5a066eba2..c306205cf 100644 --- a/roles/network/tasks/dhcpd.yml +++ b/roles/network/tasks/dhcpd.yml @@ -2,7 +2,7 @@ package: name: isc-dhcp-server state: present - when: is_debuntu | bool + when: is_debuntu - name: Install dhcp package (not debuntu) package: @@ -14,14 +14,14 @@ user: name: dhcpd createhome: no - when: is_debuntu | bool + when: is_debuntu - name: Disable stock dhcp_service (debuntu) service: name: "{{ dhcp_service }}" enabled: no state: stopped - when: is_debuntu | bool + when: is_debuntu - name: Disable stock dhcp_service ipv6 (ubuntu-18 and higher) service: @@ -29,7 +29,7 @@ enabled: no state: stopped when: is_ubuntu and not is_ubuntu_16 - #when: is_ubuntu_18 | bool + #when: is_ubuntu_18 - name: Install systemd unit file to /etc/systemd/system/dhcpd.service template: @@ -43,7 +43,7 @@ command: touch /var/lib/dhcpd/dhcpd.leases args: creates: /var/lib/dhcpd/dhcpd.leases - when: is_redhat | bool + when: is_redhat - name: Set dhcpd.leases permissions/ownership (redhat) file: @@ -52,7 +52,7 @@ group: dhcpd mode: '0644' # state: file - when: is_redhat | bool + when: is_redhat - name: "Add 'dhcpd_installed: True' to {{ iiab_state_file }}" lineinfile: diff --git a/roles/network/tasks/down-debian.yml b/roles/network/tasks/down-debian.yml index a0e9008e0..6e91ae5b9 100644 --- a/roles/network/tasks/down-debian.yml +++ b/roles/network/tasks/down-debian.yml @@ -16,7 +16,7 @@ systemd: name: dhcpd state: stopped - when: dhcpd_install | bool + when: dhcpd_install - name: dhcpd_server may be affected - stopping dnsmasq systemd: diff --git a/roles/network/tasks/fedora/ifcfg_mods.yml b/roles/network/tasks/fedora/ifcfg_mods.yml index 140d5b8f4..0ad22488e 100644 --- a/roles/network/tasks/fedora/ifcfg_mods.yml +++ b/roles/network/tasks/fedora/ifcfg_mods.yml @@ -36,13 +36,13 @@ service: name: dhcpd state: stopped - when: dhcpd_install | bool + when: dhcpd_install - name: dhcpd_server may be affected - stopping dnsmasq service: name: dnsmasq state: stopped - when: dnsmasq_install | bool + when: dnsmasq_install - name: Stop the LAN/Bridge deleting iiab-LAN shell: nmcli con delete id iiab-LAN diff --git a/roles/network/tasks/fedora/redetect.yml b/roles/network/tasks/fedora/redetect.yml index dd01ada0d..47cf687d3 100644 --- a/roles/network/tasks/fedora/redetect.yml +++ b/roles/network/tasks/fedora/redetect.yml @@ -57,7 +57,7 @@ shell: nmcli conn up id iiab-WAN register: dhcp_WAN ignore_errors: yes - when: has_WAN | bool + when: has_WAN - name: BAD ifcfg-WAN debug: @@ -117,7 +117,7 @@ register: ifcfg_dhcp_device ignore_errors: True changed_when: False - when: dhcp_good | bool + when: dhcp_good - name: Setting has ifcfg gw based on device if found set_fact: diff --git a/roles/network/tasks/main.yml b/roles/network/tasks/main.yml index fdcb2944d..17164c417 100644 --- a/roles/network/tasks/main.yml +++ b/roles/network/tasks/main.yml @@ -56,7 +56,7 @@ #### Start network layout #- name: Redhat networking # include_tasks: ifcfg_mods.yml -# when: is_redhat | bool +# when: is_redhat - name: NetworkManager in use include_tasks: NM-debian.yml diff --git a/roles/network/tasks/named.yml b/roles/network/tasks/named.yml index 2111f15aa..9183242f9 100644 --- a/roles/network/tasks/named.yml +++ b/roles/network/tasks/named.yml @@ -4,7 +4,7 @@ - bind9 - bind9utils state: present - when: is_debuntu | bool + when: is_debuntu - name: "Install named packages: bind, bind-utils (OS's other than debuntu)" package: @@ -75,7 +75,7 @@ template: src: roles/network/templates/named/dns-jail.conf dest: "/etc/{{ apache_conf_dir }}/" - when: dns_jail_enabled | bool + when: dns_jail_enabled - name: "Add 'named_installed: True' to {{ iiab_state_file }}" lineinfile: @@ -85,7 +85,7 @@ - name: Enable dns-jail.conf via Apache command: a2ensite dns-jail.conf - when: dns_jail_enabled | bool + when: dns_jail_enabled - name: Disable dns-jail.conf via Apache command: a2dissite: dns-jail.conf diff --git a/roles/network/tasks/netplan.yml b/roles/network/tasks/netplan.yml index 0eb96166b..2ce2d5109 100644 --- a/roles/network/tasks/netplan.yml +++ b/roles/network/tasks/netplan.yml @@ -21,19 +21,19 @@ enabled: yes with_items: - systemd-networkd-wait-online - when: systemd_networkd_active | bool + when: systemd_networkd_active - name: Unmask and enable the systemd-networkd service for br0 systemd: name: systemd-networkd enabled: yes masked: no - when: network_manager_active | bool and iiab_lan_iface == "br0" + when: network_manager_active and iiab_lan_iface == "br0" - name: Ensure systemd-networkd gets enabled for br0 set_fact: systemd_networkd_active: True - when: network_manager_active | bool and iiab_lan_iface == "br0" + when: network_manager_active and iiab_lan_iface == "br0" # ICO will always set gui_static_wan_ip away from the default of 'unset' while # gui_static_wan turns dhcp on/off through wan_ip in computed_network and diff --git a/roles/network/tasks/restart.yml b/roles/network/tasks/restart.yml index f896923f1..35d475e0d 100644 --- a/roles/network/tasks/restart.yml +++ b/roles/network/tasks/restart.yml @@ -46,7 +46,7 @@ systemd: name: wondershaper state: restarted - when: wondershaper_enabled | bool + when: wondershaper_enabled - name: Restart Avahi service (avahi-daemon) systemd: diff --git a/roles/network/tasks/squid.yml b/roles/network/tasks/squid.yml index 8bde37ba7..398718648 100644 --- a/roles/network/tasks/squid.yml +++ b/roles/network/tasks/squid.yml @@ -7,7 +7,7 @@ - name: "Bigger hammer for Ubuntu, run: /etc/init.d/squid stop" command: /etc/init.d/squid stop - when: is_ubuntu | bool + when: is_ubuntu - name: Stop Squid service: @@ -78,7 +78,7 @@ state: directory - include_tasks: roles/network/tasks/dansguardian.yml - when: dansguardian_install | bool + when: dansguardian_install - name: "Add 'squid_installed: True' to {{ iiab_state_file }}" lineinfile: diff --git a/roles/nextcloud/tasks/F18.yml b/roles/nextcloud/tasks/F18.yml index 3b1dbe51d..5e76d45c4 100644 --- a/roles/nextcloud/tasks/F18.yml +++ b/roles/nextcloud/tasks/F18.yml @@ -9,7 +9,7 @@ url: "{{ nextcloud_dl_url }}/{{ nextcloud_orig_src_file }}" dest: "{{ downloads_dir }}/{{ nextcloud_src_file }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: Copy it to permanent location /opt unarchive: diff --git a/roles/nextcloud/tasks/apache.yml b/roles/nextcloud/tasks/apache.yml index 5a1945a78..788e1c2ac 100644 --- a/roles/nextcloud/tasks/apache.yml +++ b/roles/nextcloud/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ nextcloud_url }} via Apache # http://box/nextcloud command: a2ensite nextcloud.conf - when: nextcloud_enabled | bool + when: nextcloud_enabled - name: Disable http://box{{ nextcloud_url }} via Apache # http://box/nextcloud command: a2dissite nextcloud.conf diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index b8091cae4..b3461b9fe 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -30,7 +30,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'nextcloud' variable values to {{ iiab_ini_file }} diff --git a/roles/nextcloud/tasks/nginx.yml b/roles/nextcloud/tasks/nginx.yml index e2e7db20f..47a8868ed 100644 --- a/roles/nextcloud/tasks/nginx.yml +++ b/roles/nextcloud/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: nextcloud-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/nextcloud-nginx.conf" # /etc/nginx/conf.d - when: nextcloud_enabled | bool + when: nextcloud_enabled - name: Disable http://box{{ nextcloud_url }} via NGINX, by removing {{ nginx_conf_dir }}/nextcloud-nginx.conf # http://box/nextcloud file: diff --git a/roles/nginx/tasks/enable-or-disable.yml b/roles/nginx/tasks/enable-or-disable.yml index d23bb6419..510203110 100644 --- a/roles/nginx/tasks/enable-or-disable.yml +++ b/roles/nginx/tasks/enable-or-disable.yml @@ -9,7 +9,7 @@ template: src: ports.conf.j2 dest: "/etc/{{ apache_service }}/ports.conf" - when: nginx_enabled | bool + when: nginx_enabled - name: Install /etc/{{ apache_service }}/ports.conf from template 2 of 2 (stock-apache-ports.conf) if not nginx_enabled, to disable Apache port {{ apache_port }} localhost only template: @@ -32,7 +32,7 @@ daemon_reload: yes enabled: yes state: restarted - when: nginx_enabled | bool + when: nginx_enabled - name: Disable & Stop 'nginx' systemd service, if not nginx_enabled systemd: diff --git a/roles/nginx/tasks/install.yml b/roles/nginx/tasks/install.yml index cf6ed066e..1410d3277 100644 --- a/roles/nginx/tasks/install.yml +++ b/roles/nginx/tasks/install.yml @@ -46,7 +46,7 @@ systemd: name: "php{{ php_version }}-fpm" state: restarted - #when: nginx_enabled | bool + #when: nginx_enabled # RECORD NGINX AS INSTALLED diff --git a/roles/nginx/templates/mime.types.j2 b/roles/nginx/templates/mime.types.j2 index ce5c12a66..fdde53388 100644 --- a/roles/nginx/templates/mime.types.j2 +++ b/roles/nginx/templates/mime.types.j2 @@ -1,90 +1,90 @@ -types { - text/html html htm shtml; - text/css css; - text/xml xml; - image/gif gif; - image/jpeg jpeg jpg; - application/javascript js; - application/atom+xml atom; - application/rss+xml rss; - - text/mathml mml; - text/plain txt; - text/vnd.sun.j2me.app-descriptor jad; - text/vnd.wap.wml wml; - text/x-component htc; - - image/png png; - image/tiff tif tiff; - image/vnd.wap.wbmp wbmp; - image/x-icon ico; - image/x-jng jng; - image/x-ms-bmp bmp; - image/svg+xml svg svgz; - image/webp webp; - - application/font-woff woff; - application/java-archive jar war ear; - application/json json; - application/mac-binhex40 hqx; - application/msword doc; - application/pdf pdf; - application/postscript ps eps ai; - application/rtf rtf; - application/vnd.apple.mpegurl m3u8; - application/vnd.ms-excel xls; - application/vnd.ms-fontobject eot; - application/vnd.ms-powerpoint ppt; - application/vnd.wap.wmlc wmlc; - application/vnd.google-earth.kml+xml kml; - application/vnd.google-earth.kmz kmz; - application/x-7z-compressed 7z; - application/x-cocoa cco; - application/x-java-archive-diff jardiff; - application/x-java-jnlp-file jnlp; - application/x-makeself run; - application/x-perl pl pm; - application/x-pilot prc pdb; - application/x-rar-compressed rar; - application/x-redhat-package-manager rpm; - application/x-sea sea; - application/x-shockwave-flash swf; - application/x-stuffit sit; - application/x-tcl tcl tk; - application/x-x509-ca-cert der pem crt; - application/x-xpinstall xpi; - application/xhtml+xml xhtml; - application/xspf+xml xspf; - application/zip zip; - application/vnd.android.package-archive apk; - - application/octet-stream bin exe dll; - application/octet-stream deb; - application/octet-stream dmg; - application/octet-stream iso img; - application/octet-stream msi msp msm; - application/octet-stream zim; - - application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; - application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; - - audio/midi mid midi kar; - audio/mpeg mp3; - audio/ogg ogg; - audio/x-m4a m4a; - audio/x-realaudio ra; - - video/3gpp 3gpp 3gp; - video/mp2t ts; - video/mp4 mp4; - video/mpeg mpeg mpg; - video/quicktime mov; - video/webm webm; - video/x-flv flv; - video/x-m4v m4v; - video/x-mng mng; - video/x-ms-asf asx asf; - video/x-ms-wmv wmv; - video/x-msvideo avi; -} +types { + text/html html htm shtml; + text/css css; + text/xml xml; + image/gif gif; + image/jpeg jpeg jpg; + application/javascript js; + application/atom+xml atom; + application/rss+xml rss; + + text/mathml mml; + text/plain txt; + text/vnd.sun.j2me.app-descriptor jad; + text/vnd.wap.wml wml; + text/x-component htc; + + image/png png; + image/tiff tif tiff; + image/vnd.wap.wbmp wbmp; + image/x-icon ico; + image/x-jng jng; + image/x-ms-bmp bmp; + image/svg+xml svg svgz; + image/webp webp; + + application/font-woff woff; + application/java-archive jar war ear; + application/json json; + application/mac-binhex40 hqx; + application/msword doc; + application/pdf pdf; + application/postscript ps eps ai; + application/rtf rtf; + application/vnd.apple.mpegurl m3u8; + application/vnd.ms-excel xls; + application/vnd.ms-fontobject eot; + application/vnd.ms-powerpoint ppt; + application/vnd.wap.wmlc wmlc; + application/vnd.google-earth.kml+xml kml; + application/vnd.google-earth.kmz kmz; + application/x-7z-compressed 7z; + application/x-cocoa cco; + application/x-java-archive-diff jardiff; + application/x-java-jnlp-file jnlp; + application/x-makeself run; + application/x-perl pl pm; + application/x-pilot prc pdb; + application/x-rar-compressed rar; + application/x-redhat-package-manager rpm; + application/x-sea sea; + application/x-shockwave-flash swf; + application/x-stuffit sit; + application/x-tcl tcl tk; + application/x-x509-ca-cert der pem crt; + application/x-xpinstall xpi; + application/xhtml+xml xhtml; + application/xspf+xml xspf; + application/zip zip; + application/vnd.android.package-archive apk; + + application/octet-stream bin exe dll; + application/octet-stream deb; + application/octet-stream dmg; + application/octet-stream iso img; + application/octet-stream msi msp msm; + application/octet-stream zim; + + application/vnd.openxmlformats-officedocument.wordprocessingml.document docx; + application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx; + application/vnd.openxmlformats-officedocument.presentationml.presentation pptx; + + audio/midi mid midi kar; + audio/mpeg mp3; + audio/ogg ogg; + audio/x-m4a m4a; + audio/x-realaudio ra; + + video/3gpp 3gpp 3gp; + video/mp2t ts; + video/mp4 mp4; + video/mpeg mpeg mpg; + video/quicktime mov; + video/webm webm; + video/x-flv flv; + video/x-m4v m4v; + video/x-mng mng; + video/x-ms-asf asx asf; + video/x-ms-wmv wmv; + video/x-msvideo avi; +} diff --git a/roles/nodered/tasks/apache.yml b/roles/nodered/tasks/apache.yml index db2484a3b..c51671a0a 100644 --- a/roles/nodered/tasks/apache.yml +++ b/roles/nodered/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box/nodered via Apache command: a2ensite nodered.conf - when: nodered_enabled | bool + when: nodered_enabled - name: Disable http://box/nodered via Apache command: a2dissite nodered.conf diff --git a/roles/nodered/tasks/install.yml b/roles/nodered/tasks/install.yml index 8ea03a52b..4a7473f63 100644 --- a/roles/nodered/tasks/install.yml +++ b/roles/nodered/tasks/install.yml @@ -45,7 +45,7 @@ package: name: nodered state: absent - when: nodered_install | bool + when: nodered_install # 2012-02-13: the 6 RPi stanzas below recreate Raspbian Desktop's Node-RED # environment, inspired by: diff --git a/roles/nodered/tasks/main.yml b/roles/nodered/tasks/main.yml index 543489291..1edf2f34b 100644 --- a/roles/nodered/tasks/main.yml +++ b/roles/nodered/tasks/main.yml @@ -30,7 +30,7 @@ daemon_reload: yes enabled: yes state: restarted - when: nodered_enabled | bool + when: nodered_enabled - name: Disable & Stop 'nodered' systemd service, if not nodered_enabled systemd: @@ -46,7 +46,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'nodered' variable values to {{ iiab_ini_file }} diff --git a/roles/nodered/tasks/nginx.yml b/roles/nodered/tasks/nginx.yml index 168b43c1d..e7affdab7 100644 --- a/roles/nodered/tasks/nginx.yml +++ b/roles/nodered/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: nodered-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/nodered-nginx.conf" # /etc/nginx/conf.d - when: nodered_enabled | bool + when: nodered_enabled - name: Disable http://box/nodered via NGINX, by removing {{ nginx_conf_dir }}/nodered-nginx.conf file: diff --git a/roles/openvpn/tasks/enable-or-disable.yml b/roles/openvpn/tasks/enable-or-disable.yml index 9d6a48a3e..78e717e05 100644 --- a/roles/openvpn/tasks/enable-or-disable.yml +++ b/roles/openvpn/tasks/enable-or-disable.yml @@ -41,7 +41,7 @@ daemon_reload: yes enabled: yes state: restarted # 2018-09-02: Should we be concerned that "systemctl status openvpn" often shows "active (exited)" ? If so we might consider "state: started" or "state: reloaded" instead? - when: openvpn_enabled | bool + when: openvpn_enabled - name: Enable hourly cron job for OpenVPN (starts CHILD service openvpn@xscenet, typically for CentOS only?) lineinfile: diff --git a/roles/osm-vector-maps/tasks/main.yml b/roles/osm-vector-maps/tasks/main.yml index e10a47df3..39f1ff7b2 100644 --- a/roles/osm-vector-maps/tasks/main.yml +++ b/roles/osm-vector-maps/tasks/main.yml @@ -18,7 +18,7 @@ - name: Enable/Disable/Reload NGINX for OSM, if nginx_enabled include_tasks: nginx.yml - #when: nginx_enabled | bool # NGINX is mandatory starting with IIAB 7.2 + #when: nginx_enabled # NGINX is mandatory starting with IIAB 7.2 - name: Add 'osm-vector-maps' variable values to {{ iiab_ini_file }} diff --git a/roles/osm-vector-maps/tasks/nginx.yml b/roles/osm-vector-maps/tasks/nginx.yml index b764220d6..15c281db8 100644 --- a/roles/osm-vector-maps/tasks/nginx.yml +++ b/roles/osm-vector-maps/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: osm-vector-maps-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/osm-vector-maps-nginx.conf" # /etc/nginx/conf.d - when: osm_vector_maps_enabled | bool + when: osm_vector_maps_enabled - name: Disable http://box/maps & http://box/osm-vector-maps via NGINX, by removing {{ nginx_conf_dir }}/osm-vector-maps-nginx.conf file: diff --git a/roles/pbx/tasks/asterisk.yml b/roles/pbx/tasks/asterisk.yml index d2e6c763e..032a2f9bf 100644 --- a/roles/pbx/tasks/asterisk.yml +++ b/roles/pbx/tasks/asterisk.yml @@ -6,7 +6,7 @@ url: "{{ asterisk_url }}/{{ asterisk_src_file }}" dest: "{{ downloads_dir }}/{{ asterisk_src_file }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: Asterisk - Check for /opt/iiab/downloads/{{ asterisk_src_file }} stat: diff --git a/roles/pbx/tasks/chan_dongle.yml b/roles/pbx/tasks/chan_dongle.yml index 20696e8c4..5cef9861f 100644 --- a/roles/pbx/tasks/chan_dongle.yml +++ b/roles/pbx/tasks/chan_dongle.yml @@ -3,7 +3,7 @@ url: "{{ chan_dongle_url }}/{{ chan_dongle_src_file }}" dest: "{{ downloads_dir }}/{{ chan_dongle_src_file }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: chan_dongle - Check for /opt/iiab/downloads/{{ chan_dongle_src_file }} stat: diff --git a/roles/pbx/tasks/freepbx.yml b/roles/pbx/tasks/freepbx.yml index bab813434..b46b8c845 100644 --- a/roles/pbx/tasks/freepbx.yml +++ b/roles/pbx/tasks/freepbx.yml @@ -6,7 +6,7 @@ url: "{{ freepbx_url }}/{{ freepbx_src_file }}" dest: "{{ downloads_dir }}/{{ freepbx_src_file }}" timeout: "{{ download_timeout }}" - when: internet_available | bool + when: internet_available - name: FreePBX - Check for {{ downloads_dir }}/{{ freepbx_src_file }} stat: diff --git a/roles/pbx/tasks/freepbx_enable.yml b/roles/pbx/tasks/freepbx_enable.yml index 0473353c9..2f3f1976b 100644 --- a/roles/pbx/tasks/freepbx_enable.yml +++ b/roles/pbx/tasks/freepbx_enable.yml @@ -4,7 +4,7 @@ name: freepbx enabled: yes state: restarted - when: pbx_enabled | bool + when: pbx_enabled - name: FreePBX - Disable & Stop 'freepbx' systemd service (if not pbx_enabled) systemd: @@ -16,7 +16,7 @@ - name: FreePBX - Enable http://box:{{ pbx_http_port }} via Apache, if pbx_enabled # http://box:83 command: a2ensite freepbx.conf - when: pbx_enabled | bool + when: pbx_enabled - name: FreePBX - Disable http://box:{{ pbx_http_port }} via Apache, if not pbx_enabled # http://box:83 command: a2dissite freepbx.conf diff --git a/roles/pbx/tasks/main.yml b/roles/pbx/tasks/main.yml index edec5ab14..fc7d29442 100644 --- a/roles/pbx/tasks/main.yml +++ b/roles/pbx/tasks/main.yml @@ -29,7 +29,7 @@ - name: Asterisk - Install chan_dongle include: chan_dongle.yml - when: asterisk_chan_dongle | bool + when: asterisk_chan_dongle - name: Add 'pbx' variable values to {{ iiab_ini_file }} ini_file: diff --git a/roles/phpmyadmin/tasks/enable-or-disable.yml b/roles/phpmyadmin/tasks/enable-or-disable.yml index 79c47a8de..31faa2de3 100644 --- a/roles/phpmyadmin/tasks/enable-or-disable.yml +++ b/roles/phpmyadmin/tasks/enable-or-disable.yml @@ -1,6 +1,6 @@ - name: Enable phpMyAdmin via Apache, if phpmyadmin_enabled command: a2ensite phpmyadmin.conf - when: phpmyadmin_enabled | bool + when: phpmyadmin_enabled #when: apache_installed is defined and phpmyadmin_enabled - name: Disable phpMyAdmin via Apache, if not phpmyadmin_enabled diff --git a/roles/phpmyadmin/tasks/install.yml b/roles/phpmyadmin/tasks/install.yml index a80fb2fdd..5c2bbc567 100644 --- a/roles/phpmyadmin/tasks/install.yml +++ b/roles/phpmyadmin/tasks/install.yml @@ -13,7 +13,7 @@ url: "{{ phpmyadmin_dl_url }}" # e.g. https://files.phpmyadmin.net/phpMyAdmin/5.0.4/phpMyAdmin-5.0.4-all-languages.zip dest: "{{ downloads_dir }}" # /opt/iiab/downloads timeout: "{{ download_timeout }}" # 200 - when: internet_available | bool + when: internet_available - name: Does {{ downloads_dir }}/{{ phpmyadmin_name_zip }} exist? stat: diff --git a/roles/postgresql/tasks/install.yml b/roles/postgresql/tasks/install.yml index 535bb1794..7b6c46aca 100644 --- a/roles/postgresql/tasks/install.yml +++ b/roles/postgresql/tasks/install.yml @@ -7,7 +7,7 @@ package: name: postgresql-client state: present - when: is_debuntu | bool + when: is_debuntu - name: Install 'postgresql-server' package (OS's other than debuntu) package: @@ -35,11 +35,11 @@ lineinfile: dest: /etc/locale.gen line: "{{ postgresql_locale }} UTF-8" - when: is_debuntu | bool + when: is_debuntu - name: Generate locales (debuntu) command: /usr/sbin/locale-gen - when: is_debuntu | bool + when: is_debuntu - name: Initialize the PostgreSQL db, creating /library/pgsql-iiab/pg_hba.conf (debuntu) #command: su - postgres -c "/usr/lib/postgresql/{{ postgresql_version }}/bin/initdb -E 'UTF-8' --locale={{ postgresql_locale }} -D /library/pgsql-iiab" @@ -48,7 +48,7 @@ creates: /library/pgsql-iiab/pg_hba.conf become: yes become_user: postgres - when: is_debuntu | bool + when: is_debuntu - name: Initialize the PostgreSQL db, creating /library/pgsql-iiab/pg_hba.conf (OS's other than debuntu) #command: su - postgres -c "/usr/bin/initdb -E 'UTF-8' --lc-collate={{ postgresql_locale }} --lc-ctype={{ postgresql_locale }} -D /library/pgsql-iiab" diff --git a/roles/postgresql/tasks/main.yml b/roles/postgresql/tasks/main.yml index ef342c464..2ab61433e 100644 --- a/roles/postgresql/tasks/main.yml +++ b/roles/postgresql/tasks/main.yml @@ -37,7 +37,7 @@ daemon_reload: yes enabled: yes state: started - when: postgresql_enabled | bool + when: postgresql_enabled - name: Disable & Stop 'postgresql-iiab' systemd service, if not postgresql_enabled systemd: diff --git a/roles/samba/tasks/enable-or-disable.yml b/roles/samba/tasks/enable-or-disable.yml index a586ff7de..e6406606a 100644 --- a/roles/samba/tasks/enable-or-disable.yml +++ b/roles/samba/tasks/enable-or-disable.yml @@ -7,7 +7,7 @@ name: "{{ item }}" state: started enabled: yes - when: samba_enabled | bool + when: samba_enabled with_items: - "{{ smb_service }}" - "{{ nmb_service }}" diff --git a/roles/sshd/tasks/enable-or-disable.yml b/roles/sshd/tasks/enable-or-disable.yml index 36a870b3d..5b2d69b2e 100644 --- a/roles/sshd/tasks/enable-or-disable.yml +++ b/roles/sshd/tasks/enable-or-disable.yml @@ -4,7 +4,7 @@ name: "{{ sshd_service }}" enabled: yes state: restarted - when: sshd_enabled | bool + when: sshd_enabled - name: Disable & Stop ssh daemon ({{ sshd_service }}) if not sshd_enabled systemd: diff --git a/roles/sshd/tasks/install.yml b/roles/sshd/tasks/install.yml index 5a77242ed..0be48232d 100644 --- a/roles/sshd/tasks/install.yml +++ b/roles/sshd/tasks/install.yml @@ -20,7 +20,7 @@ regexp: '^PermitRootLogin' line: 'PermitRootLogin without-password' state: present - #when: sshd_enabled | bool + #when: sshd_enabled - name: mkdir /root/.ssh file: @@ -29,7 +29,7 @@ owner: root group: root mode: '0700' - #when: sshd_enabled | bool + #when: sshd_enabled - name: Install dummy root keys as placeholder copy: @@ -39,7 +39,7 @@ group: root mode: '0600' force: no - #when: sshd_enabled | bool + #when: sshd_enabled # RECORD sshd AS INSTALLED diff --git a/roles/sugarizer/tasks/install.yml b/roles/sugarizer/tasks/install.yml index 6a10b494a..024fc87e9 100644 --- a/roles/sugarizer/tasks/install.yml +++ b/roles/sugarizer/tasks/install.yml @@ -35,7 +35,7 @@ version: "{{ sugarizer_git_version }}" force: yes depth: 1 - when: internet_available | bool + when: internet_available - name: Symlink /opt/iiab/sugarizer -> /opt/iiab/{{ sugarizer_dir_version }} file: @@ -68,7 +68,7 @@ version: "{{ sugarizer_server_git_version }}" force: yes depth: 1 - when: internet_available | bool + when: internet_available - name: Symlink /opt/iiab/sugarizer-server -> /opt/iiab/{{ sugarizer_server_dir_version }} file: @@ -132,7 +132,7 @@ args: chdir: "{{ iiab_base }}/sugarizer-server" #creates: "{{ iiab_base }}/sugarizer-server/node_modules" # OLD WAY 2 - when: internet_available | bool # "npm install" generally requires Internet access + when: internet_available # "npm install" generally requires Internet access # when: internet_available and git_sug_server_output.changed # OLD WAY 3 # when: internet_available and not is_F18 and not node_modules_exists # OLD WAY 1 @@ -143,7 +143,7 @@ command: npm install --allow-root --unsafe-perm=true path-prefix-proxy args: chdir: "{{ iiab_base }}/sugarizer-server" - when: internet_available | bool + when: internet_available # 5. CONFIG FILES diff --git a/roles/sugarizer/tasks/main.yml b/roles/sugarizer/tasks/main.yml index 733aff167..5046f5e3b 100644 --- a/roles/sugarizer/tasks/main.yml +++ b/roles/sugarizer/tasks/main.yml @@ -32,7 +32,7 @@ - name: "Set 'mongodb_enabled: True' when sugarizer_enabled" set_fact: mongodb_enabled: True - when: sugarizer_enabled | bool + when: sugarizer_enabled - name: MONGODB - run 'mongodb' role (attempt to install MongoDB) include_role: diff --git a/roles/sugarizer/tasks/main2.yml b/roles/sugarizer/tasks/main2.yml index 123031c30..c1b65c78e 100644 --- a/roles/sugarizer/tasks/main2.yml +++ b/roles/sugarizer/tasks/main2.yml @@ -2,7 +2,7 @@ include_tasks: install.yml when: sugarizer_installed is undefined -- block: # 2 STANZAS BELOW, CONDITIONED ON 'when: sugarizer_enabled | bool' +- block: # 2 STANZAS BELOW, CONDITIONED ON 'when: sugarizer_enabled' # LIKELY UNNEC: THIS SAME CODE IS IN main.yml (LINES 32-35, ALREADY RUN) # sugarizer.service line 'Requires=mongodb.service' auto-starts MongoDB (but record that in var too) @@ -17,7 +17,7 @@ enabled: yes state: restarted - when: sugarizer_enabled | bool # CONDITION FOR 2-STANZA block: ABOVE + when: sugarizer_enabled # CONDITION FOR 2-STANZA block: ABOVE # Stops 'sugarizer' but not 'mongodb' - name: Disable & Stop 'sugarizer' systemd service, if not sugarizer_enabled @@ -33,7 +33,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'sugarizer' variable values to {{ iiab_ini_file }} diff --git a/roles/sugarizer/tasks/nginx.yml b/roles/sugarizer/tasks/nginx.yml index 6bd937537..3257972d0 100644 --- a/roles/sugarizer/tasks/nginx.yml +++ b/roles/sugarizer/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: sugarizer-nginx.conf dest: "{{ nginx_conf_dir }}/sugarizer-nginx.conf" # /etc/nginx/conf.d - when: sugarizer_enabled | bool + when: sugarizer_enabled - name: Disable http://box/sugarizer via NGINX, by removing {{ nginx_conf_dir }}/sugarizer-nginx.conf file: diff --git a/roles/transmission/tasks/enable-or-disable.yml b/roles/transmission/tasks/enable-or-disable.yml index 11cb4a496..a5ec5b3b6 100644 --- a/roles/transmission/tasks/enable-or-disable.yml +++ b/roles/transmission/tasks/enable-or-disable.yml @@ -4,7 +4,7 @@ name: transmission-daemon enabled: yes state: restarted - when: transmission_enabled | bool + when: transmission_enabled - name: Add PAUSED KA Lite torrent(s) to transmission-daemon's queue shell: > diff --git a/roles/usb_lib/tasks/apache.yml b/roles/usb_lib/tasks/apache.yml index d847184f8..7d74fa2f2 100644 --- a/roles/usb_lib/tasks/apache.yml +++ b/roles/usb_lib/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box/usb via Apache command: a2ensite content_dir.conf - when: usb_lib_enabled | bool + when: usb_lib_enabled - name: Disable http://box/usb via Apache command: a2dissite content_dir.conf diff --git a/roles/usb_lib/tasks/main.yml b/roles/usb_lib/tasks/main.yml index 6567de348..6c9011a7e 100644 --- a/roles/usb_lib/tasks/main.yml +++ b/roles/usb_lib/tasks/main.yml @@ -36,7 +36,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Put variable in iiab.env that enables display of content at root of USB diff --git a/roles/usb_lib/tasks/nginx.yml b/roles/usb_lib/tasks/nginx.yml index c9152b68b..7e572142a 100644 --- a/roles/usb_lib/tasks/nginx.yml +++ b/roles/usb_lib/tasks/nginx.yml @@ -5,7 +5,7 @@ owner: root group: root mode: '0751' - when: usb_lib_enabled | bool + when: usb_lib_enabled - name: Install /etc/usbmount/umount.d/70-usb-library from template, if usb_lib_enabled template: @@ -14,7 +14,7 @@ owner: root group: root mode: '0751' - when: usb_lib_enabled | bool + when: usb_lib_enabled - name: Remove /etc/usbmount/mount.d/70-usb-library if not usb_lib_enabled file: diff --git a/roles/vnstat/tasks/enable-or-disable.yml b/roles/vnstat/tasks/enable-or-disable.yml index ae9c413f4..2a3bf1ed6 100644 --- a/roles/vnstat/tasks/enable-or-disable.yml +++ b/roles/vnstat/tasks/enable-or-disable.yml @@ -4,7 +4,7 @@ name: vnstat enabled: yes state: restarted - when: vnstat_enabled | bool + when: vnstat_enabled - name: Disable & Stop 'vnstat' systemd service, if not vnstat_enabled systemd: diff --git a/roles/wordpress/tasks/apache.yml b/roles/wordpress/tasks/apache.yml index 9fe8d4025..306363bd3 100644 --- a/roles/wordpress/tasks/apache.yml +++ b/roles/wordpress/tasks/apache.yml @@ -1,6 +1,6 @@ - name: Enable http://box{{ wp_url }} via Apache # http://box/wordpress command: a2ensite wordpress.conf - when: wordpress_enabled | bool + when: wordpress_enabled - name: Disable http://box{{ wp_url }} via Apache # http://box/wordpress command: a2dissite wordpress.conf diff --git a/roles/wordpress/tasks/install.yml b/roles/wordpress/tasks/install.yml index 6fdd06fda..cc8a613d3 100644 --- a/roles/wordpress/tasks/install.yml +++ b/roles/wordpress/tasks/install.yml @@ -17,7 +17,7 @@ dest: "{{ downloads_dir }}" timeout: "{{ download_timeout }}" register: wp_download_output - when: internet_available | bool + when: internet_available - name: Symlink {{ downloads_dir }}/wordpress.tar.gz -> {{ wp_download_output.dest }} file: @@ -69,7 +69,7 @@ - name: Run /tmp/get-iiab-wp-salts to download 8 random salts/keys, creating a new {{ wp_abs_path }}/wp-keys.php (or if nec, copy from known/prior {{ wp_abs_path }}/wp-keys.php.BAK) # /library/wordpress command: /tmp/get-iiab-wp-salts - #when: internet_available | bool # Better to run it every time, installing from wp-keys.php.BAK if download fails + #when: internet_available # Better to run it every time, installing from wp-keys.php.BAK if download fails # Don't Bother: /tmp file are deleted on reboot! #- name: Remove script /tmp/get-iiab-wp-salts diff --git a/roles/wordpress/tasks/main.yml b/roles/wordpress/tasks/main.yml index 07853ec12..7e4bc8a72 100644 --- a/roles/wordpress/tasks/main.yml +++ b/roles/wordpress/tasks/main.yml @@ -36,7 +36,7 @@ - name: Enable/Disable/Restart NGINX if primary include_tasks: nginx.yml - when: nginx_enabled | bool + when: nginx_enabled - name: Add 'wordpress' variable values to {{ iiab_ini_file }} diff --git a/roles/wordpress/tasks/nginx.yml b/roles/wordpress/tasks/nginx.yml index 67be63850..c55d1223e 100644 --- a/roles/wordpress/tasks/nginx.yml +++ b/roles/wordpress/tasks/nginx.yml @@ -2,7 +2,7 @@ template: src: wordpress-nginx.conf.j2 dest: "{{ nginx_conf_dir }}/wordpress-nginx.conf" # /etc/nginx/conf.d - when: wordpress_enabled | bool + when: wordpress_enabled - name: Disable http://box{{ wp_url }} via NGINX, by removing {{ nginx_conf_dir }}/wordpress-nginx.conf # http://box/wordpress file: diff --git a/roles/www_base/files/html/js/Markdown.Converter.js b/roles/www_base/files/html/js/Markdown.Converter.js index 91d522899..cb7a134ab 100644 --- a/roles/www_base/files/html/js/Markdown.Converter.js +++ b/roles/www_base/files/html/js/Markdown.Converter.js @@ -1,1627 +1,1627 @@ -"use strict"; -var Markdown; - -if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module - Markdown = exports; -else - Markdown = {}; - -// The following text is included for historical reasons, but should -// be taken with a pinch of salt; it's not all true anymore. - -// -// Wherever possible, Showdown is a straight, line-by-line port -// of the Perl version of Markdown. -// -// This is not a normal parser design; it's basically just a -// series of string substitutions. It's hard to read and -// maintain this way, but keeping Showdown close to the original -// design makes it easier to port new features. -// -// More importantly, Showdown behaves like markdown.pl in most -// edge cases. So web applications can do client-side preview -// in Javascript, and then build identical HTML on the server. -// -// This port needs the new RegExp functionality of ECMA 262, -// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers -// should do fine. Even with the new regular expression features, -// We do a lot of work to emulate Perl's regex functionality. -// The tricky changes in this file mostly have the "attacklab:" -// label. Major or self-explanatory changes don't. -// -// Smart diff tools like Araxis Merge will be able to match up -// this file with markdown.pl in a useful way. A little tweaking -// helps: in a copy of markdown.pl, replace "#" with "//" and -// replace "$text" with "text". Be sure to ignore whitespace -// and line endings. -// - - -// -// Usage: -// -// var text = "Markdown *rocks*."; -// -// var converter = new Markdown.Converter(); -// var html = converter.makeHtml(text); -// -// alert(html); -// -// Note: move the sample code to the bottom of this -// file before uncommenting it. -// - -(function () { - - function identity(x) { return x; } - function returnFalse(x) { return false; } - - function HookCollection() { } - - HookCollection.prototype = { - - chain: function (hookname, func) { - var original = this[hookname]; - if (!original) - throw new Error("unknown hook " + hookname); - - if (original === identity) - this[hookname] = func; - else - this[hookname] = function (text) { - var args = Array.prototype.slice.call(arguments, 0); - args[0] = original.apply(null, args); - return func.apply(null, args); - }; - }, - set: function (hookname, func) { - if (!this[hookname]) - throw new Error("unknown hook " + hookname); - this[hookname] = func; - }, - addNoop: function (hookname) { - this[hookname] = identity; - }, - addFalse: function (hookname) { - this[hookname] = returnFalse; - } - }; - - Markdown.HookCollection = HookCollection; - - // g_urls and g_titles allow arbitrary user-entered strings as keys. This - // caused an exception (and hence stopped the rendering) when the user entered - // e.g. [push] or [__proto__]. Adding a prefix to the actual key prevents this - // (since no builtin property starts with "s_"). See - // http://meta.stackexchange.com/questions/64655/strange-wmd-bug - // (granted, switching from Array() to Object() alone would have left only __proto__ - // to be a problem) - function SaveHash() { } - SaveHash.prototype = { - set: function (key, value) { - this["s_" + key] = value; - }, - get: function (key) { - return this["s_" + key]; - } - }; - - Markdown.Converter = function (OPTIONS) { - var pluginHooks = this.hooks = new HookCollection(); - - // given a URL that was encountered by itself (without markup), should return the link text that's to be given to this link - pluginHooks.addNoop("plainLinkText"); - - // called with the orignal text as given to makeHtml. The result of this plugin hook is the actual markdown source that will be cooked - pluginHooks.addNoop("preConversion"); - - // called with the text once all normalizations have been completed (tabs to spaces, line endings, etc.), but before any conversions have - pluginHooks.addNoop("postNormalization"); - - // Called with the text before / after creating block elements like code blocks and lists. Note that this is called recursively - // with inner content, e.g. it's called with the full text, and then only with the content of a blockquote. The inner - // call will receive outdented text. - pluginHooks.addNoop("preBlockGamut"); - pluginHooks.addNoop("postBlockGamut"); - - // called with the text of a single block element before / after the span-level conversions (bold, code spans, etc.) have been made - pluginHooks.addNoop("preSpanGamut"); - pluginHooks.addNoop("postSpanGamut"); - - // called with the final cooked HTML code. The result of this plugin hook is the actual output of makeHtml - pluginHooks.addNoop("postConversion"); - - // - // Private state of the converter instance: - // - - // Global hashes, used by various utility routines - var g_urls; - var g_titles; - var g_html_blocks; - - // Used to track when we're inside an ordered or unordered list - // (see _ProcessListItems() for details): - var g_list_level; - - OPTIONS = OPTIONS || {}; - var asciify = identity, deasciify = identity; - if (OPTIONS.nonAsciiLetters) { - - /* In JavaScript regular expressions, \w only denotes [a-zA-Z0-9_]. - * That's why there's inconsistent handling e.g. with intra-word bolding - * of Japanese words. That's why we do the following if OPTIONS.nonAsciiLetters - * is true: - * - * Before doing bold and italics, we find every instance - * of a unicode word character in the Markdown source that is not - * matched by \w, and the letter "Q". We take the character's code point - * and encode it in base 51, using the "digits" - * - * A, B, ..., P, R, ..., Y, Z, a, b, ..., y, z - * - * delimiting it with "Q" on both sides. For example, the source - * - * > In Chinese, the smurfs are called 藍精靈, meaning "blue spirits". - * - * turns into - * - * > In Chinese, the smurfs are called QNIhQQMOIQQOuUQ, meaning "blue spirits". - * - * Since everything that is a letter in Unicode is now a letter (or - * several letters) in ASCII, \w and \b should always do the right thing. - * - * After the bold/italic conversion, we decode again; since "Q" was encoded - * alongside all non-ascii characters (as "QBfQ"), and the conversion - * will not generate "Q", the only instances of that letter should be our - * encoded characters. And since the conversion will not break words, the - * "Q...Q" should all still be in one piece. - * - * We're using "Q" as the delimiter because it's probably one of the - * rarest characters, and also because I can't think of any special behavior - * that would ever be triggered by this letter (to use a silly example, if we - * delimited with "H" on the left and "P" on the right, then "Ψ" would be - * encoded as "HTTP", which may cause special behavior). The latter would not - * actually be a huge issue for bold/italic, but may be if we later use it - * in other places as well. - * */ - (function () { - var lettersThatJavaScriptDoesNotKnowAndQ = /[Q\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376-\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0523\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u064a\u0660-\u0669\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07c0-\u07ea\u07f4-\u07f5\u07fa\u0904-\u0939\u093d\u0950\u0958-\u0961\u0966-\u096f\u0971-\u0972\u097b-\u097f\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09e6-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a66-\u0a6f\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0ae6-\u0aef\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0be6-\u0bef\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58-\u0c59\u0c60-\u0c61\u0c66-\u0c6f\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3d\u0d60-\u0d61\u0d66-\u0d6f\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0ed0-\u0ed9\u0edc-\u0edd\u0f00\u0f20-\u0f29\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f-\u1049\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070\u1075-\u1081\u108e\u1090-\u1099\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u17e0-\u17e9\u1810-\u1819\u1820-\u1877\u1880-\u18a8\u18aa\u1900-\u191c\u1946-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u19d0-\u19d9\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b50-\u1b59\u1b83-\u1ba0\u1bae-\u1bb9\u1c00-\u1c23\u1c40-\u1c49\u1c4d-\u1c7d\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u203f-\u2040\u2054\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183-\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2c6f\u2c71-\u2c7d\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fc3\ua000-\ua48c\ua500-\ua60c\ua610-\ua62b\ua640-\ua65f\ua662-\ua66e\ua67f-\ua697\ua717-\ua71f\ua722-\ua788\ua78b-\ua78c\ua7fb-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8d0-\ua8d9\ua900-\ua925\ua930-\ua946\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa50-\uaa59\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe33-\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]/g; - var cp_Q = "Q".charCodeAt(0); - var cp_A = "A".charCodeAt(0); - var cp_Z = "Z".charCodeAt(0); - var dist_Za = "a".charCodeAt(0) - cp_Z - 1; - - asciify = function(text) { - return text.replace(lettersThatJavaScriptDoesNotKnowAndQ, function (m) { - var c = m.charCodeAt(0); - var s = ""; - var v; - while (c > 0) { - v = (c % 51) + cp_A; - if (v >= cp_Q) - v++; - if (v > cp_Z) - v += dist_Za; - s = String.fromCharCode(v) + s; - c = c / 51 | 0; - } - return "Q" + s + "Q"; - }) - }; - - deasciify = function(text) { - return text.replace(/Q([A-PR-Za-z]{1,3})Q/g, function (m, s) { - var c = 0; - var v; - for (var i = 0; i < s.length; i++) { - v = s.charCodeAt(i); - if (v > cp_Z) - v -= dist_Za; - if (v > cp_Q) - v--; - v -= cp_A; - c = (c * 51) + v; - } - return String.fromCharCode(c); - }) - } - })(); - } - - var _DoItalicsAndBold = OPTIONS.asteriskIntraWordEmphasis ? _DoItalicsAndBold_AllowIntrawordWithAsterisk : _DoItalicsAndBoldStrict; - - this.makeHtml = function (text) { - - // - // Main function. The order in which other subs are called here is - // essential. Link and image substitutions need to happen before - // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the - // and tags get encoded. - // - - // This will only happen if makeHtml on the same converter instance is called from a plugin hook. - // Don't do that. - if (g_urls) - throw new Error("Recursive call to converter.makeHtml"); - - // Create the private state objects. - g_urls = new SaveHash(); - g_titles = new SaveHash(); - g_html_blocks = []; - g_list_level = 0; - - text = pluginHooks.preConversion(text); - - // attacklab: Replace ~ with ~T - // This lets us use tilde as an escape char to avoid md5 hashes - // The choice of character is arbitray; anything that isn't - // magic in Markdown will work. - text = text.replace(/~/g, "~T"); - - // attacklab: Replace $ with ~D - // RegExp interprets $ as a special character - // when it's in a replacement string - text = text.replace(/\$/g, "~D"); - - // Standardize line endings - text = text.replace(/\r\n/g, "\n"); // DOS to Unix - text = text.replace(/\r/g, "\n"); // Mac to Unix - - // Make sure text begins and ends with a couple of newlines: - text = "\n\n" + text + "\n\n"; - - // Convert all tabs to spaces. - text = _Detab(text); - - // Strip any lines consisting only of spaces and tabs. - // This makes subsequent regexen easier to write, because we can - // match consecutive blank lines with /\n+/ instead of something - // contorted like /[ \t]*\n+/ . - text = text.replace(/^[ \t]+$/mg, ""); - - text = pluginHooks.postNormalization(text); - - // Turn block-level HTML blocks into hash entries - text = _HashHTMLBlocks(text); - - // Strip link definitions, store in hashes. - text = _StripLinkDefinitions(text); - - text = _RunBlockGamut(text); - - text = _UnescapeSpecialChars(text); - - // attacklab: Restore dollar signs - text = text.replace(/~D/g, "$$"); - - // attacklab: Restore tildes - text = text.replace(/~T/g, "~"); - - text = pluginHooks.postConversion(text); - - g_html_blocks = g_titles = g_urls = null; - - return text; - }; - - function _StripLinkDefinitions(text) { - // - // Strips link definitions from text, stores the URLs and titles in - // hash references. - // - - // Link defs are in the form: ^[id]: url "optional title" - - /* - text = text.replace(/ - ^[ ]{0,3}\[([^\[\]]+)\]: // id = $1 attacklab: g_tab_width - 1 - [ \t]* - \n? // maybe *one* newline - [ \t]* - ? // url = $2 - (?=\s|$) // lookahead for whitespace instead of the lookbehind removed below - [ \t]* - \n? // maybe one newline - [ \t]* - ( // (potential) title = $3 - (\n*) // any lines skipped = $4 attacklab: lookbehind removed - [ \t]+ - ["(] - (.+?) // title = $5 - [")] - [ \t]* - )? // title is optional - (?:\n+|$) - /gm, function(){...}); - */ - - text = text.replace(/^[ ]{0,3}\[([^\[\]]+)\]:[ \t]*\n?[ \t]*?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, - function (wholeMatch, m1, m2, m3, m4, m5) { - m1 = m1.toLowerCase(); - g_urls.set(m1, _EncodeAmpsAndAngles(m2)); // Link IDs are case-insensitive - if (m4) { - // Oops, found blank lines, so it's not a title. - // Put back the parenthetical statement we stole. - return m3; - } else if (m5) { - g_titles.set(m1, m5.replace(/"/g, """)); - } - - // Completely remove the definition from the text - return ""; - } - ); - - return text; - } - - function _HashHTMLBlocks(text) { - - // Hashify HTML blocks: - // We only want to do this for block-level HTML tags, such as headers, - // lists, and tables. That's because we still want to wrap

s around - // "paragraphs" that are wrapped in non-block-level tags, such as anchors, - // phrase emphasis, and spans. The list of tags we're looking for is - // hard-coded: - var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" - var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" - - // First, look for nested blocks, e.g.: - //

- //
- // tags for inner block must be indented. - //
- //
- // - // The outermost tags must start at the left margin for this to match, and - // the inner nested divs must be indented. - // We need to do this before the next, more liberal match, because the next - // match will start at the first `
` and stop at the first `
`. - - // attacklab: This regex can be expensive when it fails. - - /* - text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_a) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*?\n // any number of lines, minimally matching - // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm, hashMatch); - - // - // Now match more liberally, simply from `\n` to `\n` - // - - /* - text = text.replace(/ - ( // save in $1 - ^ // start of line (with /m) - <($block_tags_b) // start tag = $2 - \b // word break - // attacklab: hack around khtml/pcre bug... - [^\r]*? // any number of lines, minimally matching - .* // the matching end tag - [ \t]* // trailing spaces/tabs - (?=\n+) // followed by a newline - ) // attacklab: there are sentinel newlines at end of document - /gm,function(){...}}; - */ - text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm, hashMatch); - - // Special case just for
. It was easier to make a special case than - // to make the other regex more complicated. - - /* - text = text.replace(/ - \n // Starting after a blank line - [ ]{0,3} - ( // save in $1 - (<(hr) // start tag = $2 - \b // word break - ([^<>])*? - \/?>) // the matching end tag - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashMatch); - */ - text = text.replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, hashMatch); - - // Special case for standalone HTML comments: - - /* - text = text.replace(/ - \n\n // Starting after a blank line - [ ]{0,3} // attacklab: g_tab_width - 1 - ( // save in $1 - -]|-[^>])(?:[^-]|-[^-])*)--) // see http://www.w3.org/TR/html-markup/syntax.html#comments and http://meta.stackexchange.com/q/95256 - > - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashMatch); - */ - text = text.replace(/\n\n[ ]{0,3}(-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g, hashMatch); - - // PHP and ASP-style processor instructions ( and <%...%>) - - /* - text = text.replace(/ - (?: - \n\n // Starting after a blank line - ) - ( // save in $1 - [ ]{0,3} // attacklab: g_tab_width - 1 - (?: - <([?%]) // $2 - [^\r]*? - \2> - ) - [ \t]* - (?=\n{2,}) // followed by a blank line - ) - /g,hashMatch); - */ - text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, hashMatch); - - return text; - } - - function hashBlock(text) { - text = text.replace(/(^\n+|\n+$)/g, ""); - // Replace the element text with a marker ("~KxK" where x is its key) - return "\n\n~K" + (g_html_blocks.push(text) - 1) + "K\n\n"; - } - - function hashMatch(wholeMatch, m1) { - return hashBlock(m1); - } - - var blockGamutHookCallback = function (t) { return _RunBlockGamut(t); } - - function _RunBlockGamut(text, doNotUnhash) { - // - // These are all the transformations that form block-level - // tags like paragraphs, headers, and list items. - // - - text = pluginHooks.preBlockGamut(text, blockGamutHookCallback); - - text = _DoHeaders(text); - - // Do Horizontal Rules: - var replacement = "
\n"; - text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, replacement); - text = text.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$/gm, replacement); - text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, replacement); - - text = _DoLists(text); - text = _DoCodeBlocks(text); - text = _DoBlockQuotes(text); - - text = pluginHooks.postBlockGamut(text, blockGamutHookCallback); - - // We already ran _HashHTMLBlocks() before, in Markdown(), but that - // was to escape raw HTML in the original Markdown source. This time, - // we're escaping the markup we've just created, so that we don't wrap - //

tags around block-level tags. - text = _HashHTMLBlocks(text); - text = _FormParagraphs(text, doNotUnhash); - - return text; - } - - function _RunSpanGamut(text) { - // - // These are all the transformations that occur *within* block-level - // tags like paragraphs, headers, and list items. - // - - text = pluginHooks.preSpanGamut(text); - - text = _DoCodeSpans(text); - text = _EscapeSpecialCharsWithinTagAttributes(text); - text = _EncodeBackslashEscapes(text); - - // Process anchor and image tags. Images must come first, - // because ![foo][f] looks like an anchor. - text = _DoImages(text); - text = _DoAnchors(text); - - // Make links out of things like `` - // Must come after _DoAnchors(), because you can use < and > - // delimiters in inline links like [this](). - text = _DoAutoLinks(text); - - text = text.replace(/~P/g, "://"); // put in place to prevent autolinking; reset now - - text = _EncodeAmpsAndAngles(text); - text = _DoItalicsAndBold(text); - - // Do hard breaks: - text = text.replace(/ +\n/g, "
\n"); - - text = pluginHooks.postSpanGamut(text); - - return text; - } - - function _EscapeSpecialCharsWithinTagAttributes(text) { - // - // Within tags -- meaning between < and > -- encode [\ ` * _] so they - // don't conflict with their use in Markdown for code, italics and strong. - // - - // Build a regex to find HTML tags and comments. See Friedl's - // "Mastering Regular Expressions", 2nd Ed., pp. 200-201. - - // SE: changed the comment part of the regex - - var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi; - - text = text.replace(regex, function (wholeMatch) { - var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, "$1`"); - tag = escapeCharacters(tag, wholeMatch.charAt(1) == "!" ? "\\`*_/" : "\\`*_"); // also escape slashes in comments to prevent autolinking there -- http://meta.stackexchange.com/questions/95987 - return tag; - }); - - return text; - } - - function _DoAnchors(text) { - - if (text.indexOf("[") === -1) - return text; - - // - // Turn Markdown link shortcuts into XHTML
tags. - // - // - // First, handle reference-style links: [link text] [id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[] // or anything else - )* - ) - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - ) - ()()()() // pad remaining backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeAnchorTag); - - // - // Next, inline-style links: [link text](url "optional title") - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ( - (?: - \[[^\]]*\] // allow brackets nested one level - | - [^\[\]] // or anything else - )* - ) - \] - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // Title = $7 - \6 // matching quote - [ \t]* // ignore any spaces/tabs between closing quote and ) - )? // title is optional - \) - ) - /g, writeAnchorTag); - */ - - text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeAnchorTag); - - // - // Last, handle reference-style shortcuts: [link text] - // These must come last in case you've also got [link test][1] - // or [link test](/foo) - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - \[ - ([^\[\]]+) // link text = $2; can't contain '[' or ']' - \] - ) - ()()()()() // pad rest of backreferences - /g, writeAnchorTag); - */ - text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); - - return text; - } - - function writeAnchorTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) { - if (m7 == undefined) m7 = ""; - var whole_match = m1; - var link_text = m2.replace(/:\/\//g, "~P"); // to prevent auto-linking withing the link. will be converted back after the auto-linker runs - var link_id = m3.toLowerCase(); - var url = m4; - var title = m7; - - if (url == "") { - if (link_id == "") { - // lower-case and turn embedded newlines into spaces - link_id = link_text.toLowerCase().replace(/ ?\n/g, " "); - } - url = "#" + link_id; - - if (g_urls.get(link_id) != undefined) { - url = g_urls.get(link_id); - if (g_titles.get(link_id) != undefined) { - title = g_titles.get(link_id); - } - } - else { - if (whole_match.search(/\(\s*\)$/m) > -1) { - // Special case for explicit empty url - url = ""; - } else { - return whole_match; - } - } - } - url = attributeSafeUrl(url); - - var result = ""; - - return result; - } - - function _DoImages(text) { - - if (text.indexOf("![") === -1) - return text; - - // - // Turn Markdown image shortcuts into tags. - // - - // - // First, handle reference-style labeled images: ![alt text][id] - // - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - - [ ]? // one optional space - (?:\n[ ]*)? // one optional newline followed by spaces - - \[ - (.*?) // id = $3 - \] - ) - ()()()() // pad rest of backreferences - /g, writeImageTag); - */ - text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag); - - // - // Next, handle inline images: ![alt text](url "optional title") - // Don't forget: encode * and _ - - /* - text = text.replace(/ - ( // wrap whole match in $1 - !\[ - (.*?) // alt text = $2 - \] - \s? // One optional whitespace character - \( // literal paren - [ \t]* - () // no id, so leave $3 empty - ? // src url = $4 - [ \t]* - ( // $5 - (['"]) // quote char = $6 - (.*?) // title = $7 - \6 // matching quote - [ \t]* - )? // title is optional - \) - ) - /g, writeImageTag); - */ - text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag); - - return text; - } - - function attributeEncode(text) { - // unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title) - // never makes sense to have verbatim HTML in it (and the sanitizer would totally break it) - return text.replace(/>/g, ">").replace(/" + _RunSpanGamut(m1) + "\n\n"; } - ); - - text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, - function (matchFound, m1) { return "

" + _RunSpanGamut(m1) + "

\n\n"; } - ); - - // atx-style headers: - // # Header 1 - // ## Header 2 - // ## Header 2 with closing hashes ## - // ... - // ###### Header 6 - // - - /* - text = text.replace(/ - ^(\#{1,6}) // $1 = string of #'s - [ \t]* - (.+?) // $2 = Header text - [ \t]* - \#* // optional closing #'s (not counted) - \n+ - /gm, function() {...}); - */ - - text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, - function (wholeMatch, m1, m2) { - var h_level = m1.length; - return "" + _RunSpanGamut(m2) + "\n\n"; - } - ); - - return text; - } - - function _DoLists(text, isInsideParagraphlessListItem) { - // - // Form HTML ordered (numbered) and unordered (bulleted) lists. - // - - // attacklab: add sentinel to hack around khtml/safari bug: - // http://bugs.webkit.org/show_bug.cgi?id=11231 - text += "~0"; - - // Re-usable pattern to match any entirel ul or ol list: - - /* - var whole_list = / - ( // $1 = whole list - ( // $2 - [ ]{0,3} // attacklab: g_tab_width - 1 - ([*+-]|\d+[.]) // $3 = first list item marker - [ \t]+ - ) - [^\r]+? - ( // $4 - ~0 // sentinel for workaround; should be $ - | - \n{2,} - (?=\S) - (?! // Negative lookahead for another list item marker - [ \t]* - (?:[*+-]|\d+[.])[ \t]+ - ) - ) - ) - /g - */ - var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; - if (g_list_level) { - text = text.replace(whole_list, function (wholeMatch, m1, m2) { - var list = m1; - var list_type = (m2.search(/[*+-]/g) > -1) ? "ul" : "ol"; - var first_number; - if (list_type === "ol") - first_number = parseInt(m2, 10) - - var result = _ProcessListItems(list, list_type, isInsideParagraphlessListItem); - - // Trim any trailing whitespace, to put the closing `` - // up on the preceding line, to get it past the current stupid - // HTML block parser. This is a hack to work around the terrible - // hack that is the HTML block parser. - result = result.replace(/\s+$/, ""); - var opening = "<" + list_type; - if (first_number && first_number !== 1) - opening += " start=\"" + first_number + "\""; - result = opening + ">" + result + "\n"; - return result; - }); - } else { - whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g; - text = text.replace(whole_list, function (wholeMatch, m1, m2, m3) { - var runup = m1; - var list = m2; - - var list_type = (m3.search(/[*+-]/g) > -1) ? "ul" : "ol"; - - var first_number; - if (list_type === "ol") - first_number = parseInt(m3, 10) - - var result = _ProcessListItems(list, list_type); - var opening = "<" + list_type; - if (first_number && first_number !== 1) - opening += " start=\"" + first_number + "\""; - - result = runup + opening + ">\n" + result + "\n"; - return result; - }); - } - - // attacklab: strip sentinel - text = text.replace(/~0/, ""); - - return text; - } - - var _listItemMarkers = { ol: "\\d+[.]", ul: "[*+-]" }; - - function _ProcessListItems(list_str, list_type, isInsideParagraphlessListItem) { - // - // Process the contents of a single ordered or unordered list, splitting it - // into individual list items. - // - // list_type is either "ul" or "ol". - - // The $g_list_level global keeps track of when we're inside a list. - // Each time we enter a list, we increment it; when we leave a list, - // we decrement. If it's zero, we're not in a list anymore. - // - // We do this because when we're not inside a list, we want to treat - // something like this: - // - // I recommend upgrading to version - // 8. Oops, now this line is treated - // as a sub-list. - // - // As a single paragraph, despite the fact that the second line starts - // with a digit-period-space sequence. - // - // Whereas when we're inside a list (or sub-list), that line will be - // treated as the start of a sub-list. What a kludge, huh? This is - // an aspect of Markdown's syntax that's hard to parse perfectly - // without resorting to mind-reading. Perhaps the solution is to - // change the syntax rules such that sub-lists must start with a - // starting cardinal number; e.g. "1." or "a.". - - g_list_level++; - - // trim trailing blank lines: - list_str = list_str.replace(/\n{2,}$/, "\n"); - - // attacklab: add sentinel to emulate \z - list_str += "~0"; - - // In the original attacklab showdown, list_type was not given to this function, and anything - // that matched /[*+-]|\d+[.]/ would just create the next
  • , causing this mismatch: - // - // Markdown rendered by WMD rendered by MarkdownSharp - // ------------------------------------------------------------------ - // 1. first 1. first 1. first - // 2. second 2. second 2. second - // - third 3. third * third - // - // We changed this to behave identical to MarkdownSharp. This is the constructed RegEx, - // with {MARKER} being one of \d+[.] or [*+-], depending on list_type: - - /* - list_str = list_str.replace(/ - (^[ \t]*) // leading whitespace = $1 - ({MARKER}) [ \t]+ // list marker = $2 - ([^\r]+? // list item text = $3 - (\n+) - ) - (?= - (~0 | \2 ({MARKER}) [ \t]+) - ) - /gm, function(){...}); - */ - - var marker = _listItemMarkers[list_type]; - var re = new RegExp("(^[ \\t]*)(" + marker + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + marker + ")[ \\t]+))", "gm"); - var last_item_had_a_double_newline = false; - list_str = list_str.replace(re, - function (wholeMatch, m1, m2, m3) { - var item = m3; - var leading_space = m1; - var ends_with_double_newline = /\n\n$/.test(item); - var contains_double_newline = ends_with_double_newline || item.search(/\n{2,}/) > -1; - - if (contains_double_newline || last_item_had_a_double_newline) { - item = _RunBlockGamut(_Outdent(item), /* doNotUnhash = */true); - } - else { - // Recursion for sub-lists: - item = _DoLists(_Outdent(item), /* isInsideParagraphlessListItem= */ true); - item = item.replace(/\n$/, ""); // chomp(item) - if (!isInsideParagraphlessListItem) // only the outer-most item should run this, otherwise it's run multiple times for the inner ones - item = _RunSpanGamut(item); - } - last_item_had_a_double_newline = ends_with_double_newline; - return "
  • " + item + "
  • \n"; - } - ); - - // attacklab: strip sentinel - list_str = list_str.replace(/~0/g, ""); - - g_list_level--; - return list_str; - } - - function _DoCodeBlocks(text) { - // - // Process Markdown `
    ` blocks.
    -            //  
    -
    -            /*
    -            text = text.replace(/
    -                (?:\n\n|^)
    -                (                               // $1 = the code block -- one or more lines, starting with a space/tab
    -                    (?:
    -                        (?:[ ]{4}|\t)           // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
    -                        .*\n+
    -                    )+
    -                )
    -                (\n*[ ]{0,3}[^ \t\n]|(?=~0))    // attacklab: g_tab_width
    -            /g ,function(){...});
    -            */
    -
    -            // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
    -            text += "~0";
    -
    -            text = text.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
    -                function (wholeMatch, m1, m2) {
    -                    var codeblock = m1;
    -                    var nextChar = m2;
    -
    -                    codeblock = _EncodeCode(_Outdent(codeblock));
    -                    codeblock = _Detab(codeblock);
    -                    codeblock = codeblock.replace(/^\n+/g, ""); // trim leading newlines
    -                    codeblock = codeblock.replace(/\n+$/g, ""); // trim trailing whitespace
    -
    -                    codeblock = "
    " + codeblock + "\n
    "; - - return "\n\n" + codeblock + "\n\n" + nextChar; - } - ); - - // attacklab: strip sentinel - text = text.replace(/~0/, ""); - - return text; - } - - function _DoCodeSpans(text) { - // - // * Backtick quotes are used for spans. - // - // * You can use multiple backticks as the delimiters if you want to - // include literal backticks in the code span. So, this input: - // - // Just type ``foo `bar` baz`` at the prompt. - // - // Will translate to: - // - //

    Just type foo `bar` baz at the prompt.

    - // - // There's no arbitrary limit to the number of backticks you - // can use as delimters. If you need three consecutive backticks - // in your code, use four for delimiters, etc. - // - // * You can use spaces to get literal backticks at the edges: - // - // ... type `` `bar` `` ... - // - // Turns to: - // - // ... type `bar` ... - // - - /* - text = text.replace(/ - (^|[^\\`]) // Character before opening ` can't be a backslash or backtick - (`+) // $2 = Opening run of ` - (?!`) // and no more backticks -- match the full run - ( // $3 = The code block - [^\r]*? - [^`] // attacklab: work around lack of lookbehind - ) - \2 // Matching closer - (?!`) - /gm, function(){...}); - */ - - text = text.replace(/(^|[^\\`])(`+)(?!`)([^\r]*?[^`])\2(?!`)/gm, - function (wholeMatch, m1, m2, m3, m4) { - var c = m3; - c = c.replace(/^([ \t]*)/g, ""); // leading whitespace - c = c.replace(/[ \t]*$/g, ""); // trailing whitespace - c = _EncodeCode(c); - c = c.replace(/:\/\//g, "~P"); // to prevent auto-linking. Not necessary in code *blocks*, but in code spans. Will be converted back after the auto-linker runs. - return m1 + "" + c + ""; - } - ); - - return text; - } - - function _EncodeCode(text) { - // - // Encode/escape certain characters inside Markdown code runs. - // The point is that in code, these characters are literals, - // and lose their special Markdown meanings. - // - // Encode all ampersands; HTML entities are not - // entities within a Markdown code span. - text = text.replace(/&/g, "&"); - - // Do the angle bracket song and dance: - text = text.replace(//g, ">"); - - // Now, escape characters that are magic in Markdown: - text = escapeCharacters(text, "\*_{}[]\\", false); - - // jj the line above breaks this: - //--- - - //* Item - - // 1. Subitem - - // special char: * - //--- - - return text; - } - - function _DoItalicsAndBoldStrict(text) { - - if (text.indexOf("*") === -1 && text.indexOf("_") === - 1) - return text; - - text = asciify(text); - - // must go first: - - // (^|[\W_]) Start with a non-letter or beginning of string. Store in \1. - // (?:(?!\1)|(?=^)) Either the next character is *not* the same as the previous, - // or we started at the end of the string (in which case the previous - // group had zero width, so we're still there). Because the next - // character is the marker, this means that if there are e.g. multiple - // underscores in a row, we can only match the left-most ones (which - // prevents foo___bar__ from getting bolded) - // (\*|_) The marker character itself, asterisk or underscore. Store in \2. - // \2 The marker again, since bold needs two. - // (?=\S) The first bolded character cannot be a space. - // ([^\r]*?\S) The actual bolded string. At least one character, and it cannot *end* - // with a space either. Note that like in many other places, [^\r] is - // just a workaround for JS' lack of single-line regexes; it's equivalent - // to a . in an /s regex, because the string cannot contain any \r (they - // are removed in the normalizing step). - // \2\2 The marker character, twice -- end of bold. - // (?!\2) Not followed by another marker character (ensuring that we match the - // rightmost two in a longer row)... - // (?=[\W_]|$) ...but by any other non-word character or the end of string. - text = text.replace(/(^|[\W_])(?:(?!\1)|(?=^))(\*|_)\2(?=\S)([^\r]*?\S)\2\2(?!\2)(?=[\W_]|$)/g, - "$1$3"); - - // This is almost identical to the regex, except 1) there's obviously just one marker - // character, and 2) the italicized string cannot contain the marker character. - text = text.replace(/(^|[\W_])(?:(?!\1)|(?=^))(\*|_)(?=\S)((?:(?!\2)[^\r])*?\S)\2(?!\2)(?=[\W_]|$)/g, - "$1$3"); - - return deasciify(text); - } - - function _DoItalicsAndBold_AllowIntrawordWithAsterisk(text) { - - if (text.indexOf("*") === -1 && text.indexOf("_") === - 1) - return text; - - text = asciify(text); - - // must go first: - // (?=[^\r][*_]|[*_]) Optimization only, to find potentially relevant text portions faster. Minimally slower in Chrome, but much faster in IE. - // ( Store in \1. This is the last character before the delimiter - // ^ Either we're at the start of the string (i.e. there is no last character)... - // | ... or we allow one of the following: - // (?= (lookahead; we're not capturing this, just listing legal possibilities) - // \W__ If the delimiter is __, then this last character must be non-word non-underscore (extra-word emphasis only) - // | - // (?!\*)[\W_]\*\* If the delimiter is **, then this last character can be non-word non-asterisk (extra-word emphasis)... - // | - // \w\*\*\w ...or it can be word/underscore, but only if the first bolded character is such a character as well (intra-word emphasis) - // ) - // [^\r] actually capture the character (can't use `.` since it could be \n) - // ) - // (\*\*|__) Store in \2: the actual delimiter - // (?!\2) not followed by the delimiter again (at most one more asterisk/underscore is allowed) - // (?=\S) the first bolded character can't be a space - // ( Store in \3: the bolded string - // - // (?:| Look at all bolded characters except for the last one. Either that's empty, meaning only a single character was bolded... - // [^\r]*? ... otherwise take arbitrary characters, minimally matching; that's all bolded characters except for the last *two* - // (?!\2) the last two characters cannot be the delimiter itself (because that would mean four underscores/asterisks in a row) - // [^\r] capture the next-to-last bolded character - // ) - // (?= lookahead at the very last bolded char and what comes after - // \S_ for underscore-bolding, it can be any non-space - // | - // \w for asterisk-bolding (otherwise the previous alternative would've matched, since \w implies \S), either the last char is word/underscore... - // | - // \S\*\*(?:[\W_]|$) ... or it's any other non-space, but in that case the character *after* the delimiter may not be a word character - // ) - // . actually capture the last character (can use `.` this time because the lookahead ensures \S in all cases) - // ) - // (?= lookahead; list the legal possibilities for the closing delimiter and its following character - // __(?:\W|$) for underscore-bolding, the following character (if any) must be non-word non-underscore - // | - // \*\*(?:[^*]|$) for asterisk-bolding, any non-asterisk is allowed (note we already ensured above that it's not a word character if the last bolded character wasn't one) - // ) - // \2 actually capture the closing delimiter (and make sure that it matches the opening one) - - text = text.replace(/(?=[^\r][*_]|[*_])(^|(?=\W__|(?!\*)[\W_]\*\*|\w\*\*\w)[^\r])(\*\*|__)(?!\2)(?=\S)((?:|[^\r]*?(?!\2)[^\r])(?=\S_|\w|\S\*\*(?:[\W_]|$)).)(?=__(?:\W|$)|\*\*(?:[^*]|$))\2/g, - "$1$3"); - - // now : - // (?=[^\r][*_]|[*_]) Optimization, see above. - // ( Store in \1. This is the last character before the delimiter - // ^ Either we're at the start of the string (i.e. there is no last character)... - // | ... or we allow one of the following: - // (?= (lookahead; we're not capturing this, just listing legal possibilities) - // \W_ If the delimiter is _, then this last character must be non-word non-underscore (extra-word emphasis only) - // | - // (?!\*) otherwise, we list two possiblities for * as the delimiter; in either case, the last characters cannot be an asterisk itself - // (?: - // [\W_]\* this last character can be non-word (extra-word emphasis)... - // | - // \D\*(?=\w)\D ...or it can be word (otherwise the first alternative would've matched), but only if - // a) the first italicized character is such a character as well (intra-word emphasis), and - // b) neither character on either side of the asterisk is a digit - // ) - // ) - // [^\r] actually capture the character (can't use `.` since it could be \n) - // ) - // (\*|_) Store in \2: the actual delimiter - // (?!\2\2\2) not followed by more than two more instances of the delimiter - // (?=\S) the first italicized character can't be a space - // ( Store in \3: the italicized string - // (?:(?!\2)[^\r])*? arbitrary characters except for the delimiter itself, minimally matching - // (?= lookahead at the very last italicized char and what comes after - // [^\s_]_ for underscore-italicizing, it can be any non-space non-underscore - // | - // (?=\w)\D\*\D for asterisk-italicizing, either the last char is word/underscore *and* neither character on either side of the asterisk is a digit... - // | - // [^\s*]\*(?:[\W_]|$) ... or that last char is any other non-space non-asterisk, but then the character after the delimiter (if any) must be non-word - // ) - // . actually capture the last character (can use `.` this time because the lookahead ensures \S in all cases) - // ) - // (?= lookahead; list the legal possibilities for the closing delimiter and its following character - // _(?:\W|$) for underscore-italicizing, the following character (if any) must be non-word non-underscore - // | - // \*(?:[^*]|$) for asterisk-italicizing, any non-asterisk is allowed; all other restrictions have already been ensured in the previous lookahead - // ) - // \2 actually capture the closing delimiter (and make sure that it matches the opening one) - - text = text.replace(/(?=[^\r][*_]|[*_])(^|(?=\W_|(?!\*)(?:[\W_]\*|\D\*(?=\w)\D))[^\r])(\*|_)(?!\2\2\2)(?=\S)((?:(?!\2)[^\r])*?(?=[^\s_]_|(?=\w)\D\*\D|[^\s*]\*(?:[\W_]|$)).)(?=_(?:\W|$)|\*(?:[^*]|$))\2/g, - "$1$3"); - - return deasciify(text); - } - - - function _DoBlockQuotes(text) { - - /* - text = text.replace(/ - ( // Wrap whole match in $1 - ( - ^[ \t]*>[ \t]? // '>' at the start of a line - .+\n // rest of the first line - (.+\n)* // subsequent consecutive lines - \n* // blanks - )+ - ) - /gm, function(){...}); - */ - - text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, - function (wholeMatch, m1) { - var bq = m1; - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - bq = bq.replace(/^[ \t]*>[ \t]?/gm, "~0"); // trim one level of quoting - - // attacklab: clean up hack - bq = bq.replace(/~0/g, ""); - - bq = bq.replace(/^[ \t]+$/gm, ""); // trim whitespace-only lines - bq = _RunBlockGamut(bq); // recurse - - bq = bq.replace(/(^|\n)/g, "$1 "); - // These leading spaces screw with
     content, so we need to fix that:
    -                    bq = bq.replace(
    -                            /(\s*
    [^\r]+?<\/pre>)/gm,
    -                        function (wholeMatch, m1) {
    -                            var pre = m1;
    -                            // attacklab: hack around Konqueror 3.5.4 bug:
    -                            pre = pre.replace(/^  /mg, "~0");
    -                            pre = pre.replace(/~0/g, "");
    -                            return pre;
    -                        });
    -
    -                    return hashBlock("
    \n" + bq + "\n
    "); - } - ); - return text; - } - - function _FormParagraphs(text, doNotUnhash) { - // - // Params: - // $text - string to process with html

    tags - // - - // Strip leading and trailing lines: - text = text.replace(/^\n+/g, ""); - text = text.replace(/\n+$/g, ""); - - var grafs = text.split(/\n{2,}/g); - var grafsOut = []; - - var markerRe = /~K(\d+)K/; - - // - // Wrap

    tags. - // - var end = grafs.length; - for (var i = 0; i < end; i++) { - var str = grafs[i]; - - // if this is an HTML marker, copy it - if (markerRe.test(str)) { - grafsOut.push(str); - } - else if (/\S/.test(str)) { - str = _RunSpanGamut(str); - str = str.replace(/^([ \t]*)/g, "

    "); - str += "

    " - grafsOut.push(str); - } - - } - // - // Unhashify HTML blocks - // - if (!doNotUnhash) { - end = grafsOut.length; - for (var i = 0; i < end; i++) { - var foundAny = true; - while (foundAny) { // we may need several runs, since the data may be nested - foundAny = false; - grafsOut[i] = grafsOut[i].replace(/~K(\d+)K/g, function (wholeMatch, id) { - foundAny = true; - return g_html_blocks[id]; - }); - } - } - } - return grafsOut.join("\n\n"); - } - - function _EncodeAmpsAndAngles(text) { - // Smart processing for ampersands and angle brackets that need to be encoded. - - // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: - // http://bumppo.net/projects/amputator/ - text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"); - - // Encode naked <'s - text = text.replace(/<(?![a-z\/?!]|~D)/gi, "<"); - - return text; - } - - function _EncodeBackslashEscapes(text) { - // - // Parameter: String. - // Returns: The string, with after processing the following backslash - // escape sequences. - // - - // attacklab: The polite way to do this is with the new - // escapeCharacters() function: - // - // text = escapeCharacters(text,"\\",true); - // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); - // - // ...but we're sidestepping its use of the (slow) RegExp constructor - // as an optimization for Firefox. This function gets called a LOT. - - text = text.replace(/\\(\\)/g, escapeCharacters_callback); - text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g, escapeCharacters_callback); - return text; - } - - var charInsideUrl = "[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]", - charEndingUrl = "[-A-Z0-9+&@#/%=~_|[\\])]", - autoLinkRegex = new RegExp("(=\"|<)?\\b(https?|ftp)(://" + charInsideUrl + "*" + charEndingUrl + ")(?=$|\\W)", "gi"), - endCharRegex = new RegExp(charEndingUrl, "i"); - - function handleTrailingParens(wholeMatch, lookbehind, protocol, link) { - if (lookbehind) - return wholeMatch; - if (link.charAt(link.length - 1) !== ")") - return "<" + protocol + link + ">"; - var parens = link.match(/[()]/g); - var level = 0; - for (var i = 0; i < parens.length; i++) { - if (parens[i] === "(") { - if (level <= 0) - level = 1; - else - level++; - } - else { - level--; - } - } - var tail = ""; - if (level < 0) { - var re = new RegExp("\\){1," + (-level) + "}$"); - link = link.replace(re, function (trailingParens) { - tail = trailingParens; - return ""; - }); - } - if (tail) { - var lastChar = link.charAt(link.length - 1); - if (!endCharRegex.test(lastChar)) { - tail = lastChar + tail; - link = link.substr(0, link.length - 1); - } - } - return "<" + protocol + link + ">" + tail; - } - - function _DoAutoLinks(text) { - - // note that at this point, all other URL in the text are already hyperlinked as
    - // *except* for the case - - // automatically add < and > around unadorned raw hyperlinks - // must be preceded by a non-word character (and not by =" or <) and followed by non-word/EOF character - // simulating the lookbehind in a consuming way is okay here, since a URL can neither and with a " nor - // with a <, so there is no risk of overlapping matches. - text = text.replace(autoLinkRegex, handleTrailingParens); - - // autolink anything like - - - var replacer = function (wholematch, m1) { - var url = attributeSafeUrl(m1); - - return "" + pluginHooks.plainLinkText(m1) + ""; - }; - text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer); - - // Email addresses: - /* - text = text.replace(/ - < - (?:mailto:)? - ( - [-.\w]+ - \@ - [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ - ) - > - /gi, _DoAutoLinks_callback()); - */ - - /* disabling email autolinking, since we don't do that on the server, either - text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, - function(wholeMatch,m1) { - return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); - } - ); - */ - return text; - } - - function _UnescapeSpecialChars(text) { - // - // Swap back in all the special characters we've hidden. - // - text = text.replace(/~E(\d+)E/g, - function (wholeMatch, m1) { - var charCodeToReplace = parseInt(m1); - return String.fromCharCode(charCodeToReplace); - } - ); - return text; - } - - function _Outdent(text) { - // - // Remove one level of line-leading tabs or spaces - // - - // attacklab: hack around Konqueror 3.5.4 bug: - // "----------bug".replace(/^-/g,"") == "bug" - - text = text.replace(/^(\t|[ ]{1,4})/gm, "~0"); // attacklab: g_tab_width - - // attacklab: clean up hack - text = text.replace(/~0/g, "") - - return text; - } - - function _Detab(text) { - if (!/\t/.test(text)) - return text; - - var spaces = [" ", " ", " ", " "], - skew = 0, - v; - - return text.replace(/[\n\t]/g, function (match, offset) { - if (match === "\n") { - skew = offset + 1; - return match; - } - v = (offset - skew) % 4; - skew = offset + 1; - return spaces[v]; - }); - } - - // - // attacklab: Utility functions - // - - function attributeSafeUrl(url) { - url = attributeEncode(url); - url = escapeCharacters(url, "*_:()[]") - return url; - } - - function escapeCharacters(text, charsToEscape, afterBackslash) { - // First we have to escape the escape characters so that - // we can build a character class out of them - var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g, "\\$1") + "])"; - - if (afterBackslash) { - regexString = "\\\\" + regexString; - } - - var regex = new RegExp(regexString, "g"); - text = text.replace(regex, escapeCharacters_callback); - - return text; - } - - - function escapeCharacters_callback(wholeMatch, m1) { - var charCodeToEscape = m1.charCodeAt(0); - return "~E" + charCodeToEscape + "E"; - } - - }; // end of the Markdown.Converter constructor - +"use strict"; +var Markdown; + +if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module + Markdown = exports; +else + Markdown = {}; + +// The following text is included for historical reasons, but should +// be taken with a pinch of salt; it's not all true anymore. + +// +// Wherever possible, Showdown is a straight, line-by-line port +// of the Perl version of Markdown. +// +// This is not a normal parser design; it's basically just a +// series of string substitutions. It's hard to read and +// maintain this way, but keeping Showdown close to the original +// design makes it easier to port new features. +// +// More importantly, Showdown behaves like markdown.pl in most +// edge cases. So web applications can do client-side preview +// in Javascript, and then build identical HTML on the server. +// +// This port needs the new RegExp functionality of ECMA 262, +// 3rd Edition (i.e. Javascript 1.5). Most modern web browsers +// should do fine. Even with the new regular expression features, +// We do a lot of work to emulate Perl's regex functionality. +// The tricky changes in this file mostly have the "attacklab:" +// label. Major or self-explanatory changes don't. +// +// Smart diff tools like Araxis Merge will be able to match up +// this file with markdown.pl in a useful way. A little tweaking +// helps: in a copy of markdown.pl, replace "#" with "//" and +// replace "$text" with "text". Be sure to ignore whitespace +// and line endings. +// + + +// +// Usage: +// +// var text = "Markdown *rocks*."; +// +// var converter = new Markdown.Converter(); +// var html = converter.makeHtml(text); +// +// alert(html); +// +// Note: move the sample code to the bottom of this +// file before uncommenting it. +// + +(function () { + + function identity(x) { return x; } + function returnFalse(x) { return false; } + + function HookCollection() { } + + HookCollection.prototype = { + + chain: function (hookname, func) { + var original = this[hookname]; + if (!original) + throw new Error("unknown hook " + hookname); + + if (original === identity) + this[hookname] = func; + else + this[hookname] = function (text) { + var args = Array.prototype.slice.call(arguments, 0); + args[0] = original.apply(null, args); + return func.apply(null, args); + }; + }, + set: function (hookname, func) { + if (!this[hookname]) + throw new Error("unknown hook " + hookname); + this[hookname] = func; + }, + addNoop: function (hookname) { + this[hookname] = identity; + }, + addFalse: function (hookname) { + this[hookname] = returnFalse; + } + }; + + Markdown.HookCollection = HookCollection; + + // g_urls and g_titles allow arbitrary user-entered strings as keys. This + // caused an exception (and hence stopped the rendering) when the user entered + // e.g. [push] or [__proto__]. Adding a prefix to the actual key prevents this + // (since no builtin property starts with "s_"). See + // http://meta.stackexchange.com/questions/64655/strange-wmd-bug + // (granted, switching from Array() to Object() alone would have left only __proto__ + // to be a problem) + function SaveHash() { } + SaveHash.prototype = { + set: function (key, value) { + this["s_" + key] = value; + }, + get: function (key) { + return this["s_" + key]; + } + }; + + Markdown.Converter = function (OPTIONS) { + var pluginHooks = this.hooks = new HookCollection(); + + // given a URL that was encountered by itself (without markup), should return the link text that's to be given to this link + pluginHooks.addNoop("plainLinkText"); + + // called with the orignal text as given to makeHtml. The result of this plugin hook is the actual markdown source that will be cooked + pluginHooks.addNoop("preConversion"); + + // called with the text once all normalizations have been completed (tabs to spaces, line endings, etc.), but before any conversions have + pluginHooks.addNoop("postNormalization"); + + // Called with the text before / after creating block elements like code blocks and lists. Note that this is called recursively + // with inner content, e.g. it's called with the full text, and then only with the content of a blockquote. The inner + // call will receive outdented text. + pluginHooks.addNoop("preBlockGamut"); + pluginHooks.addNoop("postBlockGamut"); + + // called with the text of a single block element before / after the span-level conversions (bold, code spans, etc.) have been made + pluginHooks.addNoop("preSpanGamut"); + pluginHooks.addNoop("postSpanGamut"); + + // called with the final cooked HTML code. The result of this plugin hook is the actual output of makeHtml + pluginHooks.addNoop("postConversion"); + + // + // Private state of the converter instance: + // + + // Global hashes, used by various utility routines + var g_urls; + var g_titles; + var g_html_blocks; + + // Used to track when we're inside an ordered or unordered list + // (see _ProcessListItems() for details): + var g_list_level; + + OPTIONS = OPTIONS || {}; + var asciify = identity, deasciify = identity; + if (OPTIONS.nonAsciiLetters) { + + /* In JavaScript regular expressions, \w only denotes [a-zA-Z0-9_]. + * That's why there's inconsistent handling e.g. with intra-word bolding + * of Japanese words. That's why we do the following if OPTIONS.nonAsciiLetters + * is true: + * + * Before doing bold and italics, we find every instance + * of a unicode word character in the Markdown source that is not + * matched by \w, and the letter "Q". We take the character's code point + * and encode it in base 51, using the "digits" + * + * A, B, ..., P, R, ..., Y, Z, a, b, ..., y, z + * + * delimiting it with "Q" on both sides. For example, the source + * + * > In Chinese, the smurfs are called 藍精靈, meaning "blue spirits". + * + * turns into + * + * > In Chinese, the smurfs are called QNIhQQMOIQQOuUQ, meaning "blue spirits". + * + * Since everything that is a letter in Unicode is now a letter (or + * several letters) in ASCII, \w and \b should always do the right thing. + * + * After the bold/italic conversion, we decode again; since "Q" was encoded + * alongside all non-ascii characters (as "QBfQ"), and the conversion + * will not generate "Q", the only instances of that letter should be our + * encoded characters. And since the conversion will not break words, the + * "Q...Q" should all still be in one piece. + * + * We're using "Q" as the delimiter because it's probably one of the + * rarest characters, and also because I can't think of any special behavior + * that would ever be triggered by this letter (to use a silly example, if we + * delimited with "H" on the left and "P" on the right, then "Ψ" would be + * encoded as "HTTP", which may cause special behavior). The latter would not + * actually be a huge issue for bold/italic, but may be if we later use it + * in other places as well. + * */ + (function () { + var lettersThatJavaScriptDoesNotKnowAndQ = /[Q\u00aa\u00b5\u00ba\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376-\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0523\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0621-\u064a\u0660-\u0669\u066e-\u066f\u0671-\u06d3\u06d5\u06e5-\u06e6\u06ee-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07c0-\u07ea\u07f4-\u07f5\u07fa\u0904-\u0939\u093d\u0950\u0958-\u0961\u0966-\u096f\u0971-\u0972\u097b-\u097f\u0985-\u098c\u098f-\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc-\u09dd\u09df-\u09e1\u09e6-\u09f1\u0a05-\u0a0a\u0a0f-\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32-\u0a33\u0a35-\u0a36\u0a38-\u0a39\u0a59-\u0a5c\u0a5e\u0a66-\u0a6f\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2-\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0-\u0ae1\u0ae6-\u0aef\u0b05-\u0b0c\u0b0f-\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32-\u0b33\u0b35-\u0b39\u0b3d\u0b5c-\u0b5d\u0b5f-\u0b61\u0b66-\u0b6f\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99-\u0b9a\u0b9c\u0b9e-\u0b9f\u0ba3-\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0be6-\u0bef\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c33\u0c35-\u0c39\u0c3d\u0c58-\u0c59\u0c60-\u0c61\u0c66-\u0c6f\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0-\u0ce1\u0ce6-\u0cef\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d28\u0d2a-\u0d39\u0d3d\u0d60-\u0d61\u0d66-\u0d6f\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32-\u0e33\u0e40-\u0e46\u0e50-\u0e59\u0e81-\u0e82\u0e84\u0e87-\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa-\u0eab\u0ead-\u0eb0\u0eb2-\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0ed0-\u0ed9\u0edc-\u0edd\u0f00\u0f20-\u0f29\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8b\u1000-\u102a\u103f-\u1049\u1050-\u1055\u105a-\u105d\u1061\u1065-\u1066\u106e-\u1070\u1075-\u1081\u108e\u1090-\u1099\u10a0-\u10c5\u10d0-\u10fa\u10fc\u1100-\u1159\u115f-\u11a2\u11a8-\u11f9\u1200-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f4\u1401-\u166c\u166f-\u1676\u1681-\u169a\u16a0-\u16ea\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u17e0-\u17e9\u1810-\u1819\u1820-\u1877\u1880-\u18a8\u18aa\u1900-\u191c\u1946-\u196d\u1970-\u1974\u1980-\u19a9\u19c1-\u19c7\u19d0-\u19d9\u1a00-\u1a16\u1b05-\u1b33\u1b45-\u1b4b\u1b50-\u1b59\u1b83-\u1ba0\u1bae-\u1bb9\u1c00-\u1c23\u1c40-\u1c49\u1c4d-\u1c7d\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u203f-\u2040\u2054\u2071\u207f\u2090-\u2094\u2102\u2107\u210a-\u2113\u2115\u2119-\u211d\u2124\u2126\u2128\u212a-\u212d\u212f-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2183-\u2184\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2c6f\u2c71-\u2c7d\u2c80-\u2ce4\u2d00-\u2d25\u2d30-\u2d65\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u2e2f\u3005-\u3006\u3031-\u3035\u303b-\u303c\u3041-\u3096\u309d-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31b7\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fc3\ua000-\ua48c\ua500-\ua60c\ua610-\ua62b\ua640-\ua65f\ua662-\ua66e\ua67f-\ua697\ua717-\ua71f\ua722-\ua788\ua78b-\ua78c\ua7fb-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8d0-\ua8d9\ua900-\ua925\ua930-\ua946\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa50-\uaa59\uac00-\ud7a3\uf900-\ufa2d\ufa30-\ufa6a\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40-\ufb41\ufb43-\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe33-\ufe34\ufe4d-\ufe4f\ufe70-\ufe74\ufe76-\ufefc\uff10-\uff19\uff21-\uff3a\uff3f\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc]/g; + var cp_Q = "Q".charCodeAt(0); + var cp_A = "A".charCodeAt(0); + var cp_Z = "Z".charCodeAt(0); + var dist_Za = "a".charCodeAt(0) - cp_Z - 1; + + asciify = function(text) { + return text.replace(lettersThatJavaScriptDoesNotKnowAndQ, function (m) { + var c = m.charCodeAt(0); + var s = ""; + var v; + while (c > 0) { + v = (c % 51) + cp_A; + if (v >= cp_Q) + v++; + if (v > cp_Z) + v += dist_Za; + s = String.fromCharCode(v) + s; + c = c / 51 | 0; + } + return "Q" + s + "Q"; + }) + }; + + deasciify = function(text) { + return text.replace(/Q([A-PR-Za-z]{1,3})Q/g, function (m, s) { + var c = 0; + var v; + for (var i = 0; i < s.length; i++) { + v = s.charCodeAt(i); + if (v > cp_Z) + v -= dist_Za; + if (v > cp_Q) + v--; + v -= cp_A; + c = (c * 51) + v; + } + return String.fromCharCode(c); + }) + } + })(); + } + + var _DoItalicsAndBold = OPTIONS.asteriskIntraWordEmphasis ? _DoItalicsAndBold_AllowIntrawordWithAsterisk : _DoItalicsAndBoldStrict; + + this.makeHtml = function (text) { + + // + // Main function. The order in which other subs are called here is + // essential. Link and image substitutions need to happen before + // _EscapeSpecialCharsWithinTagAttributes(), so that any *'s or _'s in the + // and tags get encoded. + // + + // This will only happen if makeHtml on the same converter instance is called from a plugin hook. + // Don't do that. + if (g_urls) + throw new Error("Recursive call to converter.makeHtml"); + + // Create the private state objects. + g_urls = new SaveHash(); + g_titles = new SaveHash(); + g_html_blocks = []; + g_list_level = 0; + + text = pluginHooks.preConversion(text); + + // attacklab: Replace ~ with ~T + // This lets us use tilde as an escape char to avoid md5 hashes + // The choice of character is arbitray; anything that isn't + // magic in Markdown will work. + text = text.replace(/~/g, "~T"); + + // attacklab: Replace $ with ~D + // RegExp interprets $ as a special character + // when it's in a replacement string + text = text.replace(/\$/g, "~D"); + + // Standardize line endings + text = text.replace(/\r\n/g, "\n"); // DOS to Unix + text = text.replace(/\r/g, "\n"); // Mac to Unix + + // Make sure text begins and ends with a couple of newlines: + text = "\n\n" + text + "\n\n"; + + // Convert all tabs to spaces. + text = _Detab(text); + + // Strip any lines consisting only of spaces and tabs. + // This makes subsequent regexen easier to write, because we can + // match consecutive blank lines with /\n+/ instead of something + // contorted like /[ \t]*\n+/ . + text = text.replace(/^[ \t]+$/mg, ""); + + text = pluginHooks.postNormalization(text); + + // Turn block-level HTML blocks into hash entries + text = _HashHTMLBlocks(text); + + // Strip link definitions, store in hashes. + text = _StripLinkDefinitions(text); + + text = _RunBlockGamut(text); + + text = _UnescapeSpecialChars(text); + + // attacklab: Restore dollar signs + text = text.replace(/~D/g, "$$"); + + // attacklab: Restore tildes + text = text.replace(/~T/g, "~"); + + text = pluginHooks.postConversion(text); + + g_html_blocks = g_titles = g_urls = null; + + return text; + }; + + function _StripLinkDefinitions(text) { + // + // Strips link definitions from text, stores the URLs and titles in + // hash references. + // + + // Link defs are in the form: ^[id]: url "optional title" + + /* + text = text.replace(/ + ^[ ]{0,3}\[([^\[\]]+)\]: // id = $1 attacklab: g_tab_width - 1 + [ \t]* + \n? // maybe *one* newline + [ \t]* + ? // url = $2 + (?=\s|$) // lookahead for whitespace instead of the lookbehind removed below + [ \t]* + \n? // maybe one newline + [ \t]* + ( // (potential) title = $3 + (\n*) // any lines skipped = $4 attacklab: lookbehind removed + [ \t]+ + ["(] + (.+?) // title = $5 + [")] + [ \t]* + )? // title is optional + (?:\n+|$) + /gm, function(){...}); + */ + + text = text.replace(/^[ ]{0,3}\[([^\[\]]+)\]:[ \t]*\n?[ \t]*?(?=\s|$)[ \t]*\n?[ \t]*((\n*)["(](.+?)[")][ \t]*)?(?:\n+)/gm, + function (wholeMatch, m1, m2, m3, m4, m5) { + m1 = m1.toLowerCase(); + g_urls.set(m1, _EncodeAmpsAndAngles(m2)); // Link IDs are case-insensitive + if (m4) { + // Oops, found blank lines, so it's not a title. + // Put back the parenthetical statement we stole. + return m3; + } else if (m5) { + g_titles.set(m1, m5.replace(/"/g, """)); + } + + // Completely remove the definition from the text + return ""; + } + ); + + return text; + } + + function _HashHTMLBlocks(text) { + + // Hashify HTML blocks: + // We only want to do this for block-level HTML tags, such as headers, + // lists, and tables. That's because we still want to wrap

    s around + // "paragraphs" that are wrapped in non-block-level tags, such as anchors, + // phrase emphasis, and spans. The list of tags we're looking for is + // hard-coded: + var block_tags_a = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del" + var block_tags_b = "p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math" + + // First, look for nested blocks, e.g.: + //

    + //
    + // tags for inner block must be indented. + //
    + //
    + // + // The outermost tags must start at the left margin for this to match, and + // the inner nested divs must be indented. + // We need to do this before the next, more liberal match, because the next + // match will start at the first `
    ` and stop at the first `
    `. + + // attacklab: This regex can be expensive when it fails. + + /* + text = text.replace(/ + ( // save in $1 + ^ // start of line (with /m) + <($block_tags_a) // start tag = $2 + \b // word break + // attacklab: hack around khtml/pcre bug... + [^\r]*?\n // any number of lines, minimally matching + // the matching end tag + [ \t]* // trailing spaces/tabs + (?=\n+) // followed by a newline + ) // attacklab: there are sentinel newlines at end of document + /gm,function(){...}}; + */ + text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm, hashMatch); + + // + // Now match more liberally, simply from `\n` to `\n` + // + + /* + text = text.replace(/ + ( // save in $1 + ^ // start of line (with /m) + <($block_tags_b) // start tag = $2 + \b // word break + // attacklab: hack around khtml/pcre bug... + [^\r]*? // any number of lines, minimally matching + .* // the matching end tag + [ \t]* // trailing spaces/tabs + (?=\n+) // followed by a newline + ) // attacklab: there are sentinel newlines at end of document + /gm,function(){...}}; + */ + text = text.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math)\b[^\r]*?.*<\/\2>[ \t]*(?=\n+)\n)/gm, hashMatch); + + // Special case just for
    . It was easier to make a special case than + // to make the other regex more complicated. + + /* + text = text.replace(/ + \n // Starting after a blank line + [ ]{0,3} + ( // save in $1 + (<(hr) // start tag = $2 + \b // word break + ([^<>])*? + \/?>) // the matching end tag + [ \t]* + (?=\n{2,}) // followed by a blank line + ) + /g,hashMatch); + */ + text = text.replace(/\n[ ]{0,3}((<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g, hashMatch); + + // Special case for standalone HTML comments: + + /* + text = text.replace(/ + \n\n // Starting after a blank line + [ ]{0,3} // attacklab: g_tab_width - 1 + ( // save in $1 + -]|-[^>])(?:[^-]|-[^-])*)--) // see http://www.w3.org/TR/html-markup/syntax.html#comments and http://meta.stackexchange.com/q/95256 + > + [ \t]* + (?=\n{2,}) // followed by a blank line + ) + /g,hashMatch); + */ + text = text.replace(/\n\n[ ]{0,3}(-]|-[^>])(?:[^-]|-[^-])*)--)>[ \t]*(?=\n{2,}))/g, hashMatch); + + // PHP and ASP-style processor instructions ( and <%...%>) + + /* + text = text.replace(/ + (?: + \n\n // Starting after a blank line + ) + ( // save in $1 + [ ]{0,3} // attacklab: g_tab_width - 1 + (?: + <([?%]) // $2 + [^\r]*? + \2> + ) + [ \t]* + (?=\n{2,}) // followed by a blank line + ) + /g,hashMatch); + */ + text = text.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g, hashMatch); + + return text; + } + + function hashBlock(text) { + text = text.replace(/(^\n+|\n+$)/g, ""); + // Replace the element text with a marker ("~KxK" where x is its key) + return "\n\n~K" + (g_html_blocks.push(text) - 1) + "K\n\n"; + } + + function hashMatch(wholeMatch, m1) { + return hashBlock(m1); + } + + var blockGamutHookCallback = function (t) { return _RunBlockGamut(t); } + + function _RunBlockGamut(text, doNotUnhash) { + // + // These are all the transformations that form block-level + // tags like paragraphs, headers, and list items. + // + + text = pluginHooks.preBlockGamut(text, blockGamutHookCallback); + + text = _DoHeaders(text); + + // Do Horizontal Rules: + var replacement = "
    \n"; + text = text.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm, replacement); + text = text.replace(/^[ ]{0,2}([ ]?-[ ]?){3,}[ \t]*$/gm, replacement); + text = text.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm, replacement); + + text = _DoLists(text); + text = _DoCodeBlocks(text); + text = _DoBlockQuotes(text); + + text = pluginHooks.postBlockGamut(text, blockGamutHookCallback); + + // We already ran _HashHTMLBlocks() before, in Markdown(), but that + // was to escape raw HTML in the original Markdown source. This time, + // we're escaping the markup we've just created, so that we don't wrap + //

    tags around block-level tags. + text = _HashHTMLBlocks(text); + text = _FormParagraphs(text, doNotUnhash); + + return text; + } + + function _RunSpanGamut(text) { + // + // These are all the transformations that occur *within* block-level + // tags like paragraphs, headers, and list items. + // + + text = pluginHooks.preSpanGamut(text); + + text = _DoCodeSpans(text); + text = _EscapeSpecialCharsWithinTagAttributes(text); + text = _EncodeBackslashEscapes(text); + + // Process anchor and image tags. Images must come first, + // because ![foo][f] looks like an anchor. + text = _DoImages(text); + text = _DoAnchors(text); + + // Make links out of things like `` + // Must come after _DoAnchors(), because you can use < and > + // delimiters in inline links like [this](). + text = _DoAutoLinks(text); + + text = text.replace(/~P/g, "://"); // put in place to prevent autolinking; reset now + + text = _EncodeAmpsAndAngles(text); + text = _DoItalicsAndBold(text); + + // Do hard breaks: + text = text.replace(/ +\n/g, "
    \n"); + + text = pluginHooks.postSpanGamut(text); + + return text; + } + + function _EscapeSpecialCharsWithinTagAttributes(text) { + // + // Within tags -- meaning between < and > -- encode [\ ` * _] so they + // don't conflict with their use in Markdown for code, italics and strong. + // + + // Build a regex to find HTML tags and comments. See Friedl's + // "Mastering Regular Expressions", 2nd Ed., pp. 200-201. + + // SE: changed the comment part of the regex + + var regex = /(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|-]|-[^>])(?:[^-]|-[^-])*)--)>)/gi; + + text = text.replace(regex, function (wholeMatch) { + var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, "$1`"); + tag = escapeCharacters(tag, wholeMatch.charAt(1) == "!" ? "\\`*_/" : "\\`*_"); // also escape slashes in comments to prevent autolinking there -- http://meta.stackexchange.com/questions/95987 + return tag; + }); + + return text; + } + + function _DoAnchors(text) { + + if (text.indexOf("[") === -1) + return text; + + // + // Turn Markdown link shortcuts into XHTML
    tags. + // + // + // First, handle reference-style links: [link text] [id] + // + + /* + text = text.replace(/ + ( // wrap whole match in $1 + \[ + ( + (?: + \[[^\]]*\] // allow brackets nested one level + | + [^\[] // or anything else + )* + ) + \] + + [ ]? // one optional space + (?:\n[ ]*)? // one optional newline followed by spaces + + \[ + (.*?) // id = $3 + \] + ) + ()()()() // pad remaining backreferences + /g, writeAnchorTag); + */ + text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeAnchorTag); + + // + // Next, inline-style links: [link text](url "optional title") + // + + /* + text = text.replace(/ + ( // wrap whole match in $1 + \[ + ( + (?: + \[[^\]]*\] // allow brackets nested one level + | + [^\[\]] // or anything else + )* + ) + \] + \( // literal paren + [ \t]* + () // no id, so leave $3 empty + ? + [ \t]* + ( // $5 + (['"]) // quote char = $6 + (.*?) // Title = $7 + \6 // matching quote + [ \t]* // ignore any spaces/tabs between closing quote and ) + )? // title is optional + \) + ) + /g, writeAnchorTag); + */ + + text = text.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeAnchorTag); + + // + // Last, handle reference-style shortcuts: [link text] + // These must come last in case you've also got [link test][1] + // or [link test](/foo) + // + + /* + text = text.replace(/ + ( // wrap whole match in $1 + \[ + ([^\[\]]+) // link text = $2; can't contain '[' or ']' + \] + ) + ()()()()() // pad rest of backreferences + /g, writeAnchorTag); + */ + text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag); + + return text; + } + + function writeAnchorTag(wholeMatch, m1, m2, m3, m4, m5, m6, m7) { + if (m7 == undefined) m7 = ""; + var whole_match = m1; + var link_text = m2.replace(/:\/\//g, "~P"); // to prevent auto-linking withing the link. will be converted back after the auto-linker runs + var link_id = m3.toLowerCase(); + var url = m4; + var title = m7; + + if (url == "") { + if (link_id == "") { + // lower-case and turn embedded newlines into spaces + link_id = link_text.toLowerCase().replace(/ ?\n/g, " "); + } + url = "#" + link_id; + + if (g_urls.get(link_id) != undefined) { + url = g_urls.get(link_id); + if (g_titles.get(link_id) != undefined) { + title = g_titles.get(link_id); + } + } + else { + if (whole_match.search(/\(\s*\)$/m) > -1) { + // Special case for explicit empty url + url = ""; + } else { + return whole_match; + } + } + } + url = attributeSafeUrl(url); + + var result = ""; + + return result; + } + + function _DoImages(text) { + + if (text.indexOf("![") === -1) + return text; + + // + // Turn Markdown image shortcuts into tags. + // + + // + // First, handle reference-style labeled images: ![alt text][id] + // + + /* + text = text.replace(/ + ( // wrap whole match in $1 + !\[ + (.*?) // alt text = $2 + \] + + [ ]? // one optional space + (?:\n[ ]*)? // one optional newline followed by spaces + + \[ + (.*?) // id = $3 + \] + ) + ()()()() // pad rest of backreferences + /g, writeImageTag); + */ + text = text.replace(/(!\[(.*?)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g, writeImageTag); + + // + // Next, handle inline images: ![alt text](url "optional title") + // Don't forget: encode * and _ + + /* + text = text.replace(/ + ( // wrap whole match in $1 + !\[ + (.*?) // alt text = $2 + \] + \s? // One optional whitespace character + \( // literal paren + [ \t]* + () // no id, so leave $3 empty + ? // src url = $4 + [ \t]* + ( // $5 + (['"]) // quote char = $6 + (.*?) // title = $7 + \6 // matching quote + [ \t]* + )? // title is optional + \) + ) + /g, writeImageTag); + */ + text = text.replace(/(!\[(.*?)\]\s?\([ \t]*()?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g, writeImageTag); + + return text; + } + + function attributeEncode(text) { + // unconditionally replace angle brackets here -- what ends up in an attribute (e.g. alt or title) + // never makes sense to have verbatim HTML in it (and the sanitizer would totally break it) + return text.replace(/>/g, ">").replace(/" + _RunSpanGamut(m1) + "\n\n"; } + ); + + text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, + function (matchFound, m1) { return "

    " + _RunSpanGamut(m1) + "

    \n\n"; } + ); + + // atx-style headers: + // # Header 1 + // ## Header 2 + // ## Header 2 with closing hashes ## + // ... + // ###### Header 6 + // + + /* + text = text.replace(/ + ^(\#{1,6}) // $1 = string of #'s + [ \t]* + (.+?) // $2 = Header text + [ \t]* + \#* // optional closing #'s (not counted) + \n+ + /gm, function() {...}); + */ + + text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, + function (wholeMatch, m1, m2) { + var h_level = m1.length; + return "" + _RunSpanGamut(m2) + "\n\n"; + } + ); + + return text; + } + + function _DoLists(text, isInsideParagraphlessListItem) { + // + // Form HTML ordered (numbered) and unordered (bulleted) lists. + // + + // attacklab: add sentinel to hack around khtml/safari bug: + // http://bugs.webkit.org/show_bug.cgi?id=11231 + text += "~0"; + + // Re-usable pattern to match any entirel ul or ol list: + + /* + var whole_list = / + ( // $1 = whole list + ( // $2 + [ ]{0,3} // attacklab: g_tab_width - 1 + ([*+-]|\d+[.]) // $3 = first list item marker + [ \t]+ + ) + [^\r]+? + ( // $4 + ~0 // sentinel for workaround; should be $ + | + \n{2,} + (?=\S) + (?! // Negative lookahead for another list item marker + [ \t]* + (?:[*+-]|\d+[.])[ \t]+ + ) + ) + ) + /g + */ + var whole_list = /^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm; + if (g_list_level) { + text = text.replace(whole_list, function (wholeMatch, m1, m2) { + var list = m1; + var list_type = (m2.search(/[*+-]/g) > -1) ? "ul" : "ol"; + var first_number; + if (list_type === "ol") + first_number = parseInt(m2, 10) + + var result = _ProcessListItems(list, list_type, isInsideParagraphlessListItem); + + // Trim any trailing whitespace, to put the closing `` + // up on the preceding line, to get it past the current stupid + // HTML block parser. This is a hack to work around the terrible + // hack that is the HTML block parser. + result = result.replace(/\s+$/, ""); + var opening = "<" + list_type; + if (first_number && first_number !== 1) + opening += " start=\"" + first_number + "\""; + result = opening + ">" + result + "\n"; + return result; + }); + } else { + whole_list = /(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/g; + text = text.replace(whole_list, function (wholeMatch, m1, m2, m3) { + var runup = m1; + var list = m2; + + var list_type = (m3.search(/[*+-]/g) > -1) ? "ul" : "ol"; + + var first_number; + if (list_type === "ol") + first_number = parseInt(m3, 10) + + var result = _ProcessListItems(list, list_type); + var opening = "<" + list_type; + if (first_number && first_number !== 1) + opening += " start=\"" + first_number + "\""; + + result = runup + opening + ">\n" + result + "\n"; + return result; + }); + } + + // attacklab: strip sentinel + text = text.replace(/~0/, ""); + + return text; + } + + var _listItemMarkers = { ol: "\\d+[.]", ul: "[*+-]" }; + + function _ProcessListItems(list_str, list_type, isInsideParagraphlessListItem) { + // + // Process the contents of a single ordered or unordered list, splitting it + // into individual list items. + // + // list_type is either "ul" or "ol". + + // The $g_list_level global keeps track of when we're inside a list. + // Each time we enter a list, we increment it; when we leave a list, + // we decrement. If it's zero, we're not in a list anymore. + // + // We do this because when we're not inside a list, we want to treat + // something like this: + // + // I recommend upgrading to version + // 8. Oops, now this line is treated + // as a sub-list. + // + // As a single paragraph, despite the fact that the second line starts + // with a digit-period-space sequence. + // + // Whereas when we're inside a list (or sub-list), that line will be + // treated as the start of a sub-list. What a kludge, huh? This is + // an aspect of Markdown's syntax that's hard to parse perfectly + // without resorting to mind-reading. Perhaps the solution is to + // change the syntax rules such that sub-lists must start with a + // starting cardinal number; e.g. "1." or "a.". + + g_list_level++; + + // trim trailing blank lines: + list_str = list_str.replace(/\n{2,}$/, "\n"); + + // attacklab: add sentinel to emulate \z + list_str += "~0"; + + // In the original attacklab showdown, list_type was not given to this function, and anything + // that matched /[*+-]|\d+[.]/ would just create the next
  • , causing this mismatch: + // + // Markdown rendered by WMD rendered by MarkdownSharp + // ------------------------------------------------------------------ + // 1. first 1. first 1. first + // 2. second 2. second 2. second + // - third 3. third * third + // + // We changed this to behave identical to MarkdownSharp. This is the constructed RegEx, + // with {MARKER} being one of \d+[.] or [*+-], depending on list_type: + + /* + list_str = list_str.replace(/ + (^[ \t]*) // leading whitespace = $1 + ({MARKER}) [ \t]+ // list marker = $2 + ([^\r]+? // list item text = $3 + (\n+) + ) + (?= + (~0 | \2 ({MARKER}) [ \t]+) + ) + /gm, function(){...}); + */ + + var marker = _listItemMarkers[list_type]; + var re = new RegExp("(^[ \\t]*)(" + marker + ")[ \\t]+([^\\r]+?(\\n+))(?=(~0|\\1(" + marker + ")[ \\t]+))", "gm"); + var last_item_had_a_double_newline = false; + list_str = list_str.replace(re, + function (wholeMatch, m1, m2, m3) { + var item = m3; + var leading_space = m1; + var ends_with_double_newline = /\n\n$/.test(item); + var contains_double_newline = ends_with_double_newline || item.search(/\n{2,}/) > -1; + + if (contains_double_newline || last_item_had_a_double_newline) { + item = _RunBlockGamut(_Outdent(item), /* doNotUnhash = */true); + } + else { + // Recursion for sub-lists: + item = _DoLists(_Outdent(item), /* isInsideParagraphlessListItem= */ true); + item = item.replace(/\n$/, ""); // chomp(item) + if (!isInsideParagraphlessListItem) // only the outer-most item should run this, otherwise it's run multiple times for the inner ones + item = _RunSpanGamut(item); + } + last_item_had_a_double_newline = ends_with_double_newline; + return "
  • " + item + "
  • \n"; + } + ); + + // attacklab: strip sentinel + list_str = list_str.replace(/~0/g, ""); + + g_list_level--; + return list_str; + } + + function _DoCodeBlocks(text) { + // + // Process Markdown `
    ` blocks.
    +            //  
    +
    +            /*
    +            text = text.replace(/
    +                (?:\n\n|^)
    +                (                               // $1 = the code block -- one or more lines, starting with a space/tab
    +                    (?:
    +                        (?:[ ]{4}|\t)           // Lines must start with a tab or a tab-width of spaces - attacklab: g_tab_width
    +                        .*\n+
    +                    )+
    +                )
    +                (\n*[ ]{0,3}[^ \t\n]|(?=~0))    // attacklab: g_tab_width
    +            /g ,function(){...});
    +            */
    +
    +            // attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
    +            text += "~0";
    +
    +            text = text.replace(/(?:\n\n|^\n?)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
    +                function (wholeMatch, m1, m2) {
    +                    var codeblock = m1;
    +                    var nextChar = m2;
    +
    +                    codeblock = _EncodeCode(_Outdent(codeblock));
    +                    codeblock = _Detab(codeblock);
    +                    codeblock = codeblock.replace(/^\n+/g, ""); // trim leading newlines
    +                    codeblock = codeblock.replace(/\n+$/g, ""); // trim trailing whitespace
    +
    +                    codeblock = "
    " + codeblock + "\n
    "; + + return "\n\n" + codeblock + "\n\n" + nextChar; + } + ); + + // attacklab: strip sentinel + text = text.replace(/~0/, ""); + + return text; + } + + function _DoCodeSpans(text) { + // + // * Backtick quotes are used for spans. + // + // * You can use multiple backticks as the delimiters if you want to + // include literal backticks in the code span. So, this input: + // + // Just type ``foo `bar` baz`` at the prompt. + // + // Will translate to: + // + //

    Just type foo `bar` baz at the prompt.

    + // + // There's no arbitrary limit to the number of backticks you + // can use as delimters. If you need three consecutive backticks + // in your code, use four for delimiters, etc. + // + // * You can use spaces to get literal backticks at the edges: + // + // ... type `` `bar` `` ... + // + // Turns to: + // + // ... type `bar` ... + // + + /* + text = text.replace(/ + (^|[^\\`]) // Character before opening ` can't be a backslash or backtick + (`+) // $2 = Opening run of ` + (?!`) // and no more backticks -- match the full run + ( // $3 = The code block + [^\r]*? + [^`] // attacklab: work around lack of lookbehind + ) + \2 // Matching closer + (?!`) + /gm, function(){...}); + */ + + text = text.replace(/(^|[^\\`])(`+)(?!`)([^\r]*?[^`])\2(?!`)/gm, + function (wholeMatch, m1, m2, m3, m4) { + var c = m3; + c = c.replace(/^([ \t]*)/g, ""); // leading whitespace + c = c.replace(/[ \t]*$/g, ""); // trailing whitespace + c = _EncodeCode(c); + c = c.replace(/:\/\//g, "~P"); // to prevent auto-linking. Not necessary in code *blocks*, but in code spans. Will be converted back after the auto-linker runs. + return m1 + "" + c + ""; + } + ); + + return text; + } + + function _EncodeCode(text) { + // + // Encode/escape certain characters inside Markdown code runs. + // The point is that in code, these characters are literals, + // and lose their special Markdown meanings. + // + // Encode all ampersands; HTML entities are not + // entities within a Markdown code span. + text = text.replace(/&/g, "&"); + + // Do the angle bracket song and dance: + text = text.replace(//g, ">"); + + // Now, escape characters that are magic in Markdown: + text = escapeCharacters(text, "\*_{}[]\\", false); + + // jj the line above breaks this: + //--- + + //* Item + + // 1. Subitem + + // special char: * + //--- + + return text; + } + + function _DoItalicsAndBoldStrict(text) { + + if (text.indexOf("*") === -1 && text.indexOf("_") === - 1) + return text; + + text = asciify(text); + + // must go first: + + // (^|[\W_]) Start with a non-letter or beginning of string. Store in \1. + // (?:(?!\1)|(?=^)) Either the next character is *not* the same as the previous, + // or we started at the end of the string (in which case the previous + // group had zero width, so we're still there). Because the next + // character is the marker, this means that if there are e.g. multiple + // underscores in a row, we can only match the left-most ones (which + // prevents foo___bar__ from getting bolded) + // (\*|_) The marker character itself, asterisk or underscore. Store in \2. + // \2 The marker again, since bold needs two. + // (?=\S) The first bolded character cannot be a space. + // ([^\r]*?\S) The actual bolded string. At least one character, and it cannot *end* + // with a space either. Note that like in many other places, [^\r] is + // just a workaround for JS' lack of single-line regexes; it's equivalent + // to a . in an /s regex, because the string cannot contain any \r (they + // are removed in the normalizing step). + // \2\2 The marker character, twice -- end of bold. + // (?!\2) Not followed by another marker character (ensuring that we match the + // rightmost two in a longer row)... + // (?=[\W_]|$) ...but by any other non-word character or the end of string. + text = text.replace(/(^|[\W_])(?:(?!\1)|(?=^))(\*|_)\2(?=\S)([^\r]*?\S)\2\2(?!\2)(?=[\W_]|$)/g, + "$1$3"); + + // This is almost identical to the regex, except 1) there's obviously just one marker + // character, and 2) the italicized string cannot contain the marker character. + text = text.replace(/(^|[\W_])(?:(?!\1)|(?=^))(\*|_)(?=\S)((?:(?!\2)[^\r])*?\S)\2(?!\2)(?=[\W_]|$)/g, + "$1$3"); + + return deasciify(text); + } + + function _DoItalicsAndBold_AllowIntrawordWithAsterisk(text) { + + if (text.indexOf("*") === -1 && text.indexOf("_") === - 1) + return text; + + text = asciify(text); + + // must go first: + // (?=[^\r][*_]|[*_]) Optimization only, to find potentially relevant text portions faster. Minimally slower in Chrome, but much faster in IE. + // ( Store in \1. This is the last character before the delimiter + // ^ Either we're at the start of the string (i.e. there is no last character)... + // | ... or we allow one of the following: + // (?= (lookahead; we're not capturing this, just listing legal possibilities) + // \W__ If the delimiter is __, then this last character must be non-word non-underscore (extra-word emphasis only) + // | + // (?!\*)[\W_]\*\* If the delimiter is **, then this last character can be non-word non-asterisk (extra-word emphasis)... + // | + // \w\*\*\w ...or it can be word/underscore, but only if the first bolded character is such a character as well (intra-word emphasis) + // ) + // [^\r] actually capture the character (can't use `.` since it could be \n) + // ) + // (\*\*|__) Store in \2: the actual delimiter + // (?!\2) not followed by the delimiter again (at most one more asterisk/underscore is allowed) + // (?=\S) the first bolded character can't be a space + // ( Store in \3: the bolded string + // + // (?:| Look at all bolded characters except for the last one. Either that's empty, meaning only a single character was bolded... + // [^\r]*? ... otherwise take arbitrary characters, minimally matching; that's all bolded characters except for the last *two* + // (?!\2) the last two characters cannot be the delimiter itself (because that would mean four underscores/asterisks in a row) + // [^\r] capture the next-to-last bolded character + // ) + // (?= lookahead at the very last bolded char and what comes after + // \S_ for underscore-bolding, it can be any non-space + // | + // \w for asterisk-bolding (otherwise the previous alternative would've matched, since \w implies \S), either the last char is word/underscore... + // | + // \S\*\*(?:[\W_]|$) ... or it's any other non-space, but in that case the character *after* the delimiter may not be a word character + // ) + // . actually capture the last character (can use `.` this time because the lookahead ensures \S in all cases) + // ) + // (?= lookahead; list the legal possibilities for the closing delimiter and its following character + // __(?:\W|$) for underscore-bolding, the following character (if any) must be non-word non-underscore + // | + // \*\*(?:[^*]|$) for asterisk-bolding, any non-asterisk is allowed (note we already ensured above that it's not a word character if the last bolded character wasn't one) + // ) + // \2 actually capture the closing delimiter (and make sure that it matches the opening one) + + text = text.replace(/(?=[^\r][*_]|[*_])(^|(?=\W__|(?!\*)[\W_]\*\*|\w\*\*\w)[^\r])(\*\*|__)(?!\2)(?=\S)((?:|[^\r]*?(?!\2)[^\r])(?=\S_|\w|\S\*\*(?:[\W_]|$)).)(?=__(?:\W|$)|\*\*(?:[^*]|$))\2/g, + "$1$3"); + + // now : + // (?=[^\r][*_]|[*_]) Optimization, see above. + // ( Store in \1. This is the last character before the delimiter + // ^ Either we're at the start of the string (i.e. there is no last character)... + // | ... or we allow one of the following: + // (?= (lookahead; we're not capturing this, just listing legal possibilities) + // \W_ If the delimiter is _, then this last character must be non-word non-underscore (extra-word emphasis only) + // | + // (?!\*) otherwise, we list two possiblities for * as the delimiter; in either case, the last characters cannot be an asterisk itself + // (?: + // [\W_]\* this last character can be non-word (extra-word emphasis)... + // | + // \D\*(?=\w)\D ...or it can be word (otherwise the first alternative would've matched), but only if + // a) the first italicized character is such a character as well (intra-word emphasis), and + // b) neither character on either side of the asterisk is a digit + // ) + // ) + // [^\r] actually capture the character (can't use `.` since it could be \n) + // ) + // (\*|_) Store in \2: the actual delimiter + // (?!\2\2\2) not followed by more than two more instances of the delimiter + // (?=\S) the first italicized character can't be a space + // ( Store in \3: the italicized string + // (?:(?!\2)[^\r])*? arbitrary characters except for the delimiter itself, minimally matching + // (?= lookahead at the very last italicized char and what comes after + // [^\s_]_ for underscore-italicizing, it can be any non-space non-underscore + // | + // (?=\w)\D\*\D for asterisk-italicizing, either the last char is word/underscore *and* neither character on either side of the asterisk is a digit... + // | + // [^\s*]\*(?:[\W_]|$) ... or that last char is any other non-space non-asterisk, but then the character after the delimiter (if any) must be non-word + // ) + // . actually capture the last character (can use `.` this time because the lookahead ensures \S in all cases) + // ) + // (?= lookahead; list the legal possibilities for the closing delimiter and its following character + // _(?:\W|$) for underscore-italicizing, the following character (if any) must be non-word non-underscore + // | + // \*(?:[^*]|$) for asterisk-italicizing, any non-asterisk is allowed; all other restrictions have already been ensured in the previous lookahead + // ) + // \2 actually capture the closing delimiter (and make sure that it matches the opening one) + + text = text.replace(/(?=[^\r][*_]|[*_])(^|(?=\W_|(?!\*)(?:[\W_]\*|\D\*(?=\w)\D))[^\r])(\*|_)(?!\2\2\2)(?=\S)((?:(?!\2)[^\r])*?(?=[^\s_]_|(?=\w)\D\*\D|[^\s*]\*(?:[\W_]|$)).)(?=_(?:\W|$)|\*(?:[^*]|$))\2/g, + "$1$3"); + + return deasciify(text); + } + + + function _DoBlockQuotes(text) { + + /* + text = text.replace(/ + ( // Wrap whole match in $1 + ( + ^[ \t]*>[ \t]? // '>' at the start of a line + .+\n // rest of the first line + (.+\n)* // subsequent consecutive lines + \n* // blanks + )+ + ) + /gm, function(){...}); + */ + + text = text.replace(/((^[ \t]*>[ \t]?.+\n(.+\n)*\n*)+)/gm, + function (wholeMatch, m1) { + var bq = m1; + + // attacklab: hack around Konqueror 3.5.4 bug: + // "----------bug".replace(/^-/g,"") == "bug" + + bq = bq.replace(/^[ \t]*>[ \t]?/gm, "~0"); // trim one level of quoting + + // attacklab: clean up hack + bq = bq.replace(/~0/g, ""); + + bq = bq.replace(/^[ \t]+$/gm, ""); // trim whitespace-only lines + bq = _RunBlockGamut(bq); // recurse + + bq = bq.replace(/(^|\n)/g, "$1 "); + // These leading spaces screw with
     content, so we need to fix that:
    +                    bq = bq.replace(
    +                            /(\s*
    [^\r]+?<\/pre>)/gm,
    +                        function (wholeMatch, m1) {
    +                            var pre = m1;
    +                            // attacklab: hack around Konqueror 3.5.4 bug:
    +                            pre = pre.replace(/^  /mg, "~0");
    +                            pre = pre.replace(/~0/g, "");
    +                            return pre;
    +                        });
    +
    +                    return hashBlock("
    \n" + bq + "\n
    "); + } + ); + return text; + } + + function _FormParagraphs(text, doNotUnhash) { + // + // Params: + // $text - string to process with html

    tags + // + + // Strip leading and trailing lines: + text = text.replace(/^\n+/g, ""); + text = text.replace(/\n+$/g, ""); + + var grafs = text.split(/\n{2,}/g); + var grafsOut = []; + + var markerRe = /~K(\d+)K/; + + // + // Wrap

    tags. + // + var end = grafs.length; + for (var i = 0; i < end; i++) { + var str = grafs[i]; + + // if this is an HTML marker, copy it + if (markerRe.test(str)) { + grafsOut.push(str); + } + else if (/\S/.test(str)) { + str = _RunSpanGamut(str); + str = str.replace(/^([ \t]*)/g, "

    "); + str += "

    " + grafsOut.push(str); + } + + } + // + // Unhashify HTML blocks + // + if (!doNotUnhash) { + end = grafsOut.length; + for (var i = 0; i < end; i++) { + var foundAny = true; + while (foundAny) { // we may need several runs, since the data may be nested + foundAny = false; + grafsOut[i] = grafsOut[i].replace(/~K(\d+)K/g, function (wholeMatch, id) { + foundAny = true; + return g_html_blocks[id]; + }); + } + } + } + return grafsOut.join("\n\n"); + } + + function _EncodeAmpsAndAngles(text) { + // Smart processing for ampersands and angle brackets that need to be encoded. + + // Ampersand-encoding based entirely on Nat Irons's Amputator MT plugin: + // http://bumppo.net/projects/amputator/ + text = text.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g, "&"); + + // Encode naked <'s + text = text.replace(/<(?![a-z\/?!]|~D)/gi, "<"); + + return text; + } + + function _EncodeBackslashEscapes(text) { + // + // Parameter: String. + // Returns: The string, with after processing the following backslash + // escape sequences. + // + + // attacklab: The polite way to do this is with the new + // escapeCharacters() function: + // + // text = escapeCharacters(text,"\\",true); + // text = escapeCharacters(text,"`*_{}[]()>#+-.!",true); + // + // ...but we're sidestepping its use of the (slow) RegExp constructor + // as an optimization for Firefox. This function gets called a LOT. + + text = text.replace(/\\(\\)/g, escapeCharacters_callback); + text = text.replace(/\\([`*_{}\[\]()>#+-.!])/g, escapeCharacters_callback); + return text; + } + + var charInsideUrl = "[-A-Z0-9+&@#/%?=~_|[\\]()!:,.;]", + charEndingUrl = "[-A-Z0-9+&@#/%=~_|[\\])]", + autoLinkRegex = new RegExp("(=\"|<)?\\b(https?|ftp)(://" + charInsideUrl + "*" + charEndingUrl + ")(?=$|\\W)", "gi"), + endCharRegex = new RegExp(charEndingUrl, "i"); + + function handleTrailingParens(wholeMatch, lookbehind, protocol, link) { + if (lookbehind) + return wholeMatch; + if (link.charAt(link.length - 1) !== ")") + return "<" + protocol + link + ">"; + var parens = link.match(/[()]/g); + var level = 0; + for (var i = 0; i < parens.length; i++) { + if (parens[i] === "(") { + if (level <= 0) + level = 1; + else + level++; + } + else { + level--; + } + } + var tail = ""; + if (level < 0) { + var re = new RegExp("\\){1," + (-level) + "}$"); + link = link.replace(re, function (trailingParens) { + tail = trailingParens; + return ""; + }); + } + if (tail) { + var lastChar = link.charAt(link.length - 1); + if (!endCharRegex.test(lastChar)) { + tail = lastChar + tail; + link = link.substr(0, link.length - 1); + } + } + return "<" + protocol + link + ">" + tail; + } + + function _DoAutoLinks(text) { + + // note that at this point, all other URL in the text are already hyperlinked as
    + // *except* for the case + + // automatically add < and > around unadorned raw hyperlinks + // must be preceded by a non-word character (and not by =" or <) and followed by non-word/EOF character + // simulating the lookbehind in a consuming way is okay here, since a URL can neither and with a " nor + // with a <, so there is no risk of overlapping matches. + text = text.replace(autoLinkRegex, handleTrailingParens); + + // autolink anything like + + + var replacer = function (wholematch, m1) { + var url = attributeSafeUrl(m1); + + return "" + pluginHooks.plainLinkText(m1) + ""; + }; + text = text.replace(/<((https?|ftp):[^'">\s]+)>/gi, replacer); + + // Email addresses: + /* + text = text.replace(/ + < + (?:mailto:)? + ( + [-.\w]+ + \@ + [-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+ + ) + > + /gi, _DoAutoLinks_callback()); + */ + + /* disabling email autolinking, since we don't do that on the server, either + text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, + function(wholeMatch,m1) { + return _EncodeEmailAddress( _UnescapeSpecialChars(m1) ); + } + ); + */ + return text; + } + + function _UnescapeSpecialChars(text) { + // + // Swap back in all the special characters we've hidden. + // + text = text.replace(/~E(\d+)E/g, + function (wholeMatch, m1) { + var charCodeToReplace = parseInt(m1); + return String.fromCharCode(charCodeToReplace); + } + ); + return text; + } + + function _Outdent(text) { + // + // Remove one level of line-leading tabs or spaces + // + + // attacklab: hack around Konqueror 3.5.4 bug: + // "----------bug".replace(/^-/g,"") == "bug" + + text = text.replace(/^(\t|[ ]{1,4})/gm, "~0"); // attacklab: g_tab_width + + // attacklab: clean up hack + text = text.replace(/~0/g, "") + + return text; + } + + function _Detab(text) { + if (!/\t/.test(text)) + return text; + + var spaces = [" ", " ", " ", " "], + skew = 0, + v; + + return text.replace(/[\n\t]/g, function (match, offset) { + if (match === "\n") { + skew = offset + 1; + return match; + } + v = (offset - skew) % 4; + skew = offset + 1; + return spaces[v]; + }); + } + + // + // attacklab: Utility functions + // + + function attributeSafeUrl(url) { + url = attributeEncode(url); + url = escapeCharacters(url, "*_:()[]") + return url; + } + + function escapeCharacters(text, charsToEscape, afterBackslash) { + // First we have to escape the escape characters so that + // we can build a character class out of them + var regexString = "([" + charsToEscape.replace(/([\[\]\\])/g, "\\$1") + "])"; + + if (afterBackslash) { + regexString = "\\\\" + regexString; + } + + var regex = new RegExp(regexString, "g"); + text = text.replace(regex, escapeCharacters_callback); + + return text; + } + + + function escapeCharacters_callback(wholeMatch, m1) { + var charCodeToEscape = m1.charCodeAt(0); + return "~E" + charCodeToEscape + "E"; + } + + }; // end of the Markdown.Converter constructor + })(); \ No newline at end of file diff --git a/roles/www_base/tasks/main.yml b/roles/www_base/tasks/main.yml index f19bea409..6d47379e9 100644 --- a/roles/www_base/tasks/main.yml +++ b/roles/www_base/tasks/main.yml @@ -17,7 +17,7 @@ - php{{ php_version }}-xml # Was below - php{{ php_version }}-xmlrpc state: present - when: is_debuntu | bool + when: is_debuntu - name: Using html.yml include_tasks: html.yml diff --git a/roles/www_options/tasks/main.yml b/roles/www_options/tasks/main.yml index 70df9f95c..70295837a 100644 --- a/roles/www_options/tasks/main.yml +++ b/roles/www_options/tasks/main.yml @@ -21,7 +21,7 @@ - name: Enable IIAB pages via NGINX (e.g. on port 80) if nginx_install include_tasks: roles/nginx/tasks/homepage.yml when: nginx_installed is defined - #when: nginx_install | bool + #when: nginx_install - debug: msg: 'THE 3 ANSIBLE STANZAS BELOW ONLY RUN... when: (nginx_high_php_limits or moodle_install or nextcloud_install or pbx_install or wordpress_install) and nginx_enabled' @@ -63,7 +63,7 @@ - { regexp: '^max_execution_time', line: 'max_execution_time = 300 ; default is 30' } - { regexp: '^max_input_time', line: 'max_input_time = 300 ; default is 60' } - { regexp: '^memory_limit', line: 'memory_limit = 512M ; default is 128M / Nextcloud requests 512M' } - when: nginx_high_php_limits | bool + when: nginx_high_php_limits - name: Restart 'php{{ php_version }}-fpm' systemd service systemd: @@ -87,7 +87,7 @@ src: 020_apache_poweroff.j2 dest: /etc/sudoers.d/020_apache_poweroff mode: '0440' - when: apache_allow_sudo | bool + when: apache_allow_sudo - name: Remove {{ apache_user }} (per variable apache_user) permission to poweroff, removing /etc/sudoers.d/020_apache_poweroff file: @@ -111,7 +111,7 @@ systemd: name: nginx state: restarted - when: nginx_enabled | bool + when: nginx_enabled # RECORD www_options AS INSTALLED