Author

Mar 25 2020
Mar 25

Pre-requisites

  • Dozer -- Hide status bar icons on macOS

  • Bitbar -- Put anything in your Mac OS X menu bar

Problem/Motivation

Can't get (real-time) notifications without checking mailbox or logging into drupal.org when

  1. An issue having a new comment,
  2. A documentation page gets updated
  3. A new post is published to Planet Drupal
  4. A new Change Record is published

The 4 cases can be classified into two types:

  • Login required: 1.2, 3 is available on user's dashboard page, logging in drupal.org is required
  • Login optional: 4 do not have to login drupal.org, anonymous ussers is able to access Change Record list pages.

Proposed resolution

Using Bitbar, which can put anything in the menu bar by using any programing langage. and put Drupalicon in your macOS's menu bar!

See the demo: https://github.com/jungleran/macos-menu-bar-the-drupal-way/blob/master/macos-menu-bar-the-drupal-way.gif or https://github.com/jungleran/macos-menu-bar-the-drupal-way/blob/master/macos-menu-bar-the-drupal-way.mp4

Login required

Using a HTTP client to visit the target page which contains information we care, further more, the HTTP client handles over the page content to a DOM parser to extract information we want, The last stop is to output them to a proper format following Bitbar's documentation. and display icon(s) in the menu bar.

An example: https://github.com/jungleran/macos-menu-bar-the-drupal-way/blob/master/do.5m.py

By changing your drupal.org credentials in the code, you should be able to see issue/documentation links of "My posts" and posts of "Planet Drupal" from you drupal.org dashboard page as menu items on your macOs menu bar.


  1. # Change your drupal.org credentials here

  2. username = 'YOUR_DRUAP.ORG_ACCOUNT'

  3. password = "YOUR_PASSWORD"

Read the documentation https://github.com/matryer/bitbar to get the example working for you.

Login optional

The process is similar to the above, just do not have to handle logging in.

See example: https://github.com/jungleran/macos-menu-bar-the-drupal-way/blob/master/do.cr.15m.py

This example pulls Change Records(CR) from https://www.drupal.org/list-changes/drupal, all three types of CR are pulled and display each item as menu item. The three types of CR are:

  • Published
  • Reviews
  • Draft

Also see the README.md in the repo of the examples. https://github.com/jungleran/macos-menu-bar-the-drupal-way

Enhancement

As more menus are putting into the menu bar, it's going to get crowded soon. So Here comes Dozer to hide some of them when necessary.

Dozer is a free and open-source project, an alternative of Bartender which is a payware.

PS: Python3 is used to write the examples.

Remaining tasks

Get ready your own Drupal menu bar.

User interface changes

Drupalicon conquers your menu bar.

Release notes snippet

  • Target OS: macOS
  • Target readers : Drupal contributors/Core contributors.
  • Target goal: Happy Drupaling!
Feb 08 2020
Feb 08

Why Acquica Dev Desktop 2?

So if we could get Acquica Dev Desktop working as what we expected, it would be a good alternative for Drupal devs who use macOS.

Clean up

Remove export PATH="$PATH:/Applications/DevDesktop/tools" from ~/.profile to avoid conflicts, meanwhile, add aliases to ~/.profile for easy switching PHP environment


  1. alias p71="export PHP_ID=php7_1; export PATH=/Applications/DevDesktop/php7_1_x64/bin:/Applications/DevDesktop/mysql/bin:/Applications/DevDesktop/drush_9:$PATH"

  2. alias p72="export PHP_ID=php7_2; export PATH=/Applications/DevDesktop/php7_2_x64/bin:/Applications/DevDesktop/mysql/bin:/Applications/DevDesktop/drush_9:$PATH"

  3. alias p73="export PHP_ID=php7_3; export PATH=/Applications/DevDesktop/php7_3_x64/bin:/Applications/DevDesktop/mysql/bin:/Applications/DevDesktop/drush_9:$PATH"

Install extensions

Tools required:


  1. # required to build extensions

  2. $ brew install autoconf pkg-config

Pecl extenisons

Just follow up Add a PHP extension to Acquia Dev Desktop

Non-Pecl extensions/built-in extensions

No resource on the Internet as I know so far (Feb 8, 2020) introducing how to install non-pecl extension and built-in extensions for Acquia Dev Desktop

imap

  1. $ brew install krb5 openssl@1.1 imap-uw

  2. ### Active php 7.3

  3. $ p73

  4. ### Download

  5. $ wget https://www.php.net/distributions/php-7.3.39.tar.gz && tar xzf php-7.3.39.tar.gz

  6. $ cd php-7.3.39/ext/imap

  7. $ phpize

  8. $ ./configure --with-kerberos=/usr/local/opt/krb5 --with-imap-ssl=/usr/local/opt/openssl\@1.1 --with-imap=/usr/local/opt/imap-uw

  9. $ make

  10. $ make install

ldap

  1. $ brew install openldap

  2. ### Active php 7.3

  3. $ p73

  4. ### Download

  5. $ wget https://www.php.net/distributions/php-7.3.39.tar.gz && tar xzf php-7.3.39.tar.gz

  6. $ cd php-7.3.39/ext/ldap

  7. $ phpize

  8. $./configure --with-ldap=/usr/local/opt/openldap

  9. $ make

  10. $ make install

Extras

Append two lines to settings.php


  1. $databases['default']['default']['charset'] = 'utf8mb4';

  2. $databases['default']['default']['collation'] = 'utf8mb4_general_ci';

Where are the database setttings:


  1. # On macOS

  2. $ open ${HOME}/.acquia/DevDesktop/DrupalSettings

Remove all tools under following folders, besides drush and reinstall by running composer install, especially having phpcs configured already.

  • /Applications/DevDesktop/drush_9/drush
  • /Applications/DevDesktop/tools

Change drush version


  1. $ cd /Applications/DevDesktop/tools

  2. # edit composer.json, change the version

  3. $ composer install -vvv

References

Feb 08 2020
Feb 08

Since joining Planet Drupal in 2016, no seriously new blog posts for a long time. Last year, my personal site was rebuilt with Drupal 8 again. And a few months ago, I found my feed was removed from Planet Drupal. Recently, I wanted to join in it again. The first task is to make a valid RSS. This is the background.

Suggestions from How to get your feed to the Planet

If your site uses Drupal, you can create a "Drupal Planet" taxonomy term and use it to tag any content you want to appear on the Planet. Drupal automatically creates an RSS feed for each taxonomy term, and you can submit that term’s feed URL in your Drupal Planet application. Alternatively, you can use the Drupal Planet feature module, which uses Flag and Views modules to create the feed. If you are not using Drupal, you will need to make sure your site can create a feed just for your Planet content.

Using Planet content is inapplicable as it has no Drupal 8 release.

Previously, my feed had the term "Drupal Planet" exactly, and I did submit http://ranqiangjun.com/taxonomy/term/1/feed. This time I want to avoid using the term, instead, creating a content type Planet Drupal and a View Planet Drupal to provide an RSS feed,

Content type: Planet Drupal

Creating content type called Planet Drupal (machine name: planet_drupal) with a body filed. nothing fancy here.

View: Planet Drupal

Add a view Planet Drupal (machine name: planet_drupal) with a page display and a feed display

For the page display, it's free to make it whatever you want it to be, let's focus on the feed display

Feed display


  1. TITLE

  2. Title:Planet Drupal

  3. FORMAT

  4. Format:RSS Feed | Settings

  5. Show:Fields | Settings

  6. FIELDS

  7. Content: Title

  8. Content: Authored by [hidden]

  9. Content: Authored on [hidden]

  10. Content: Body [hidden]

  11. Content: Link to Content [hidden]

  12. Content: UUID [hidden]

  13. ...

  14. FEED SETTINGS

  15. Path:/planet.xml

  16. Attach to:Page

For the fields added

  • Title, remember uncheck Link to the Content
  • Authored by, Formatter: label, unchecked Link label to the referenced entity
  • Authored on, Date format: Custom, Custom date format: r, here is important. It should be a RFC 2822 formatted date. r is the proper format character.
  • Body, Formatter: Summary or Trimmed, Trimmed limit: 600 characters
  • Link to Content, Check Output the URL as text, Checked or unchecked Use absolute link (begins with "http://") are both ok.
  • UUID, we know UUID is unique, it's used as the GUID in feed. by default no formmater for UUID field type, but there is a module called uuid_extra which provides an UUID formatter, so install it, and choose Formatter: UUID.

Next mapping the fields to feed fields

  • Title field <-- Content: Title
  • Link field <-- Content: Link to Content
  • Description field <-- Content: Body
  • Creator field <-- Content: Authored by
  • Publication date field <-- Content: Authored on
  • GUID field <-- Content: UUID, and uncheck GUID is permalink

So far so good, let's check if our feed is valid. Go to W3C Feed Validation Service and submit

Bingo, it's valid, but it complains

Let's fix it.

By checking https://dri.es/taxonomy/term/1/feed, which is a valid feed. it contains only one namespace xmlns:dc="http://purl.org/dc/elements/1.1/, so let's only keep the one. And fix Missing atom:link with rel="self" needs adding one namespace and inserting a atom:link to your feed in the channel section

Solution: If you haven't already done so, declare the Atom namespace at the top of your feed, thus: Then insert a atom:link to your feed in the channel section. Below is an example to get you started. Be sure to replace the value of the href attribute with the URL of your feed.

So our solution would be alteing the namespaces inside the implementation of template_preprocess_views_view_rss, and adding a new variable called feed_url as the href of the atom:link tag being inserted. let's assume we have a theme called planet

Inside planet.theme file, add the implementation of hook_preprocess_views_view_rss


  1. /**

  2.  * Implements hook_preprocess_HOOK().

  3.  */

  4. function planet_preprocess_views_view_rss(&$variables) {

  5. /** @var \Drupal\views\ViewExecutable $view */

  6. $view = $variables['view'];

  7. if ($view->current_display === 'feed_1' && $view->id() === 'planet_chinese') {

  8. // Provide a new variable for the custom template.

  9. $display = $view->getDisplay();

  10. $variables['feed_url'] = $display->getUrl()->setAbsolute()->toString();

  11. // Alter namespaces.

  12. $style = $view->getStyle();

  13. $style->namespaces = array_filter( $style->namespaces, function ($key) {
  14. return $key === 'xmlns:dc';

  15. }, ARRAY_FILTER_USE_KEY);

  16. $style->namespaces['xmlns:atom'] = 'http://www.w3.org/2005/Atom';

  17. $variables['namespaces'] = new Attribute($style->namespaces);

  18. }

  19. }

Copy the views-view-rss.html.twig from core/modules/views/templates into the planet theme's templates folder and insert the atom:link tag inside channel.


  1. ...

  2. <channel>

  3. {% if feed_url %}{{ feed_url }}" rel="self" type="application/rss+xml" /> {% endif %}
  4. ...

PS

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web