victorkane / lit-drupal-lean

Distro project for DrupalPicchu2014 Drupal Lean Process Workshop
GNU General Public License v2.0
10 stars 4 forks source link

As a Workshop Member I would like to post literary pieces in order to receive critiques from others #8

Closed victorkane closed 10 years ago

victorkane commented 10 years ago

Cloned from: 6: User Story Template https://github.com/victorkane/lit-drupal-lean/issues/issue/6

Problem Statement List

Check or strikethrough if confirmed IRL as problems

Drupal Lean Process uses the following atomic hypothesis statement (often called sub-hypothesis when they are created as a result of dividing up an unwieldy, difficult to test hypothesis into atomic chunks) which goes together really well with the User Story testable/implementable atom:

We believe that [doing this/ building this feature/ creating this experience] for [these people/ personas] will achieve [this outcome]. We will know this is true when we see [this market feedback, quantitative measure, or qualitative insight]. (taken from Gothelf, Jeff (2013-02-22). Lean UX: Applying Lean Principles to Improve User Experience, Ch 3)

Check or strikethrough if confirmed IRL as a worthwhile hypothesis for MVP building and testing

Personas are separate issues (probably created while working on this user story issue) since they may be re-used in user stories.

This is the actual issue title

As a Workshop Member I would like to post literary pieces in order to receive critiques from others

User Story Confirmation

To be expressed in the Comments section of this issue

victorkane commented 10 years ago

Before starting MVP 01 let's create a base feature lit_base that

and then another feature lit_zen which depends on lit_base and specifies Zen as theme, or else just include it in lit_base (for now).

victorkane commented 10 years ago

You don't have to download features and upload them to the server when you first create them any more! Advanced features lets you write the feature initially to a specified directory. Afterwards, it's drush feature management as always :) Or just use the GUI if you really want to. Make sure web server can write to the specified directory:

lit@awebfactory:~/lit-dev/docroot$ mkdir sites/all/modules/features
lit@awebfactory:~/lit-dev/docroot$ sudo chown www-data sites/all/modules/features/
lit@awebfactory:~/lit-dev/docroot$ ls -l sites/all/modules/features/
Module Lit Base written to sites/all/modules/features/lit_base
victorkane commented 10 years ago

Before implementing MVP 01, let's add automatic nodetitles for both texts and critiques (automatically generating title and hiding the title field).

Text: [node:field_text_type]: [node:field-short-title] by [current-user:name] [current-date:custom:YmdHi] Critique: CRIT by [current-user:name] [current-date:custom:YmdHi], of: [node:field-text-being-critiqued]

victorkane commented 10 years ago

When we run the install profile, feature lit_layout doesn't get properly reverted, the masquerade block is not assigned to the proper region with the status 1 and lit_layout feature is in overridden state without the masquerade block being enabled. Workaround is to go in and revert lit_layout either through gui or drush. Then the block appears. So after install, go ahead and do a drush features-revert-all command. Still need to find out why, but not now :)

$ drush features-revert-all
The following modules will be reverted: lit_layout
Do you really want to continue? (y/n): y
Do you really want to revert lit_layout.fe_block_settings? (y/n): y
Reverted lit_layout.fe_block_settings. 

Better (even though a little dangerous, but we know what we're doing, don't we :) ?):

$ drush -y features-revert-all
victorkane commented 10 years ago

So we've created some content for default or demo content authored by default users bard and muse. Now, should we use Node export with features integration or UUID features to add our demo content to the install profile? See discussion at https://drupal.org/node/1311428. Based on https://drupal.org/comment/6997038#comment-6997038 I am inspired to try UUID features first, to see if the year that has passed has made its usability acceptable, at least for our purposes.

victorkane commented 10 years ago

So we have a bug in that node_export isn't designed at all to retain demo authorship of nodes. UUID Features, on the other hand, seems to retain uid's, which, in this case is fine. So let's simply disable Lit Demo Content feature and not have it included in install program (not mentioned, not present in features to be reverted list) and instead create a Lit Default Content feature based on UUID Features.

victorkane commented 10 years ago

The saga continues:

Notice: Undefined property: stdClass::$nid in DrupalDefaultEntityController->load() (line 216 of /home/lit/lit-dev/docroot/includes/entity.inc).
Notice: Trying to get property of non-object in _node_index_node() (line 2784 of /home/lit/lit-dev/docroot/modules/node/node.module).
Warning: Attempt to assign property of non-object in node_build_content() (line 1399 of /home/lit/lit-dev/docroot/modules/node/node.module).
Notice: Trying to get property of non-object in node_build_content() (line 1419 of /home/lit/lit-dev/docroot/modules/node/node.module).

Let's add some code of our own for that !!

victorkane commented 10 years ago

So this looks very complicated for now. A patch is underway for the above error, see https://drupal.org/node/2052387 and very recent attempt to fix it and some other problems at https://drupal.org/comment/8247997#comment-8247997 So, let's go back to the Node Export version, and just leave the demo content for now with four or five poems written by Anonymous, and come back to this problem of exporting and importing uuid based users (because each user does have a uuid!) at some later time.

victorkane commented 10 years ago

So what we need to do now is simply create a nice set of demo texts, then work on MVP 01 so when you click on demo you get logged in as bard or muse and you get to critique the poems.

victorkane commented 10 years ago

Let's break down MVP 01 into tasks:

Use these statements ending in "for MVP 01 #8" in commits.

victorkane commented 10 years ago

Reported as d.o. issue 2162909

We first had to solve the bug about why the lit_layout feature wasn't getting properly reverted by lit.install during the installation process. We could see in the recent log messages that for each of the three feature reverts, an error message was getting generated:

Warning: Invalid argument supplied for foreach() in _features_restore() (line 936 of /home/lit/lit-test/docroot/sites/all/modules/contrib/features/features.module).

The code in lit.install generated by Profiler Builder was as follows:

  // revert features to ensure they are all installed
  $features = array(
    'lit_base',
    'lit_demo_content',
    'lit_demo_layout'
  );
  features_revert($features);

Changing that to the following reduced the number of errors from three to two (and got the block actually appearing upon install!):

  // revert features to ensure they are all installed
  $features = array(
    'lit_base',
    'lit_demo_content'
  );
  features_revert($features);
  features_revert(array('lit_layout' => array('fe_block_settings')));

I finally got rid of all errors and got perfect feature reverts by using the formula

features_revert(array('module' => array('component')));
in the following code (manually replacing the generated code):

  // revert features to ensure they are all installed
  $features = array(
    array('lit_base' => TRUE),
    array('lit_demo_content' => TRUE),
  );
  features_revert($features);
  features_revert(array('lit_layout' => array('fe_block_settings')));

In the Recent log messages, the errors replaced with the following:

features    12/26/2013 - 12:34  Revert completed for lit_layout / fe_block_settings.    Anonymous (not verified)    
features    12/26/2013 - 12:34  Reverting lit_layout / fe_block_settings.   Anonymous (not verified)    
features    12/26/2013 - 12:34  Rebuild completed for lit_demo_content / node_export... Anonymous (not verified)    
features    12/26/2013 - 12:33  Rebuilding lit_demo_content / node_export_features. Anonymous (not verified)    
system  12/26/2013 - 12:33  lit_demo_content module enabled.    Anonymous (not verified)    
system  12/26/2013 - 12:33  lit_demo_content module installed.  Anonymous (not verified)
victorkane commented 10 years ago

We need to create a module for the landing page options block. For this we use the module builder module scaffolding module as a drush plugin (see #19). In order to see which hooks we need to use, we do:

lit@awebfactory:~/lit-dev/docroot$ drush mb-list | grep block
...
  Preset block: Add blocks to your module
    hook_block_info
    hook_block_configure
    hook_block_save
    hook_block_view
lit@awebfactory:~/lit-dev/docroot$ 

To see all options for the drush mb command (to actually create the module scaffolding), do:

lit@awebfactory:~/lit-dev/docroot$ drush help mb

To create our application custom blocks module, we do:

lit@awebfactory:~/lit-dev/docroot$ drush mb lit_blocks block_info 
Enter the required hook preset groups (optional): 
Enter the required router paths, eg 'path/foo' (optional): 
Enter the human readable name [Lit blocks]: ^C
lit@awebfactory:~/lit-dev/docroot$ drush mb lit_blocks block_info block_configure block_save block_view
Enter the required hook preset groups (optional): block
Enter the required router paths, eg 'path/foo' (optional): sites/all/modules/custom
Enter the human readable name [Lit blocks]: L^H^H^H^H^H^H
Enter the description (optional) [TODO: Description of module]: 
Enter the help text (optional): 
Enter the dependencies (optional): 
Enter the package (optional): Lit
---- module folder: sites/all/modules/custom/lit_blocks
victorkane commented 10 years ago

Now that we have the scaffolding, a good resource for actually writing a custom block module (which we prefer in order to comply with the principle of everything in code) is Four Kitchen's Building Custom Blocks with Drupal 7. To understand this, one has to understand Drupal 7 Render Arrays, and why they even exist. See:

victorkane commented 10 years ago

Added hook_theme() to lit_blocks module with scaffolding:

lit@awebfactory:~/lit-dev/docroot$ drush mb lit_blocks theme --add --write
Enter the required hook preset groups (optional): block
Enter the required router paths, eg 'path/foo' (optional): 
Enter the human readable name [Lit blocks]: 
Enter the description (optional) [TODO: Description of module]: 
Enter the help text (optional): 
Enter the dependencies (optional): 
Enter the package (optional): 
---- module folder: /home/lit/lit-dev/docroot/sites/all/modules/custom/lit_blocks
... (code followed, but was written thanks to --write directive)
victorkane commented 10 years ago

Sass, see #30

victorkane commented 10 years ago

For many of the sections pointed to by the landing page options block, we need panels or some kind of page manager, which Drupal doesn't have. The alternatives are:

Special template files could be cool, but we don't want to work on the theme level. Panels would be first choice, but everyone wants something lighter (like the Revamped Block System and Layout Support Backdrop CMS is working on for their version 1.0). For this project, let's go with the Context module, with which I can declare certain blocks (which can load arbitrary content in arbitrary layout) for certain URLs.

In this way, we can set up lightweight "panels" for various URLs by associating a Section content type assigned to a footer menu and managed by Context module. This should be part of the layout feature.

victorkane commented 10 years ago
victorkane commented 10 years ago
victorkane commented 10 years ago

Steps to implement Demo:

postponed: critiques can have critiques

victorkane commented 10 years ago

To flag stuff as demo, let's use a field we never use, the sticky field! So just modify the fix authorship code to set the sticky field, and our demo security will have the criteria of users of role demo will have access to the demo views including sticky nodes filter, and users of role workshop member will have access to the views where (not sticky is in the filter).

victorkane commented 10 years ago

To create the demo section:

If Full HTML text format is desired it can be selected when editing section.

victorkane commented 10 years ago
      <a id="main-content"></a>
      <?php if (drupal_is_front_page()): ?>
      <?php
          unset($title_prefix);
          unset($title);
          unset($title_suffix);
          unset($page['content']);
        ?>
      <?php endif; ?>

For Lit Layout feature

For Lit Demo feature

Add demo functionality to demo section:

victorkane commented 10 years ago

Menu condition doesn't work for everything in code contexts since it hard codes 'nid' (the curse of Drupal):


-    'menu' => array(
 -      'values' => array(
 -        'node/21' => 'node/21',
 -      ),
 -    ),
victorkane commented 10 years ago

Scaffolding for Lit utils module in which to implement menu callbacks to log in demo users programmatically:

lit@awebfactory:~/lit-dev/docroot$ drush mb lit_utils menu --write
Enter the required hook preset groups (optional): menu
Enter the required router paths, eg &#039;path/foo&#039; (optional): sites/all/modules/custom
Enter the human readable name [Lit utils]: 
Enter the description (optional) [TODO: Description of module]: Utils for Literary Workshop web app
Enter the help text (optional): 
Enter the dependencies (optional): 
Enter the package (optional): Lit
---- module folder: sites/all/modules/custom/lit_utils
victorkane commented 10 years ago

We're having trouble with menu links, nids, etc., so let's get rid of the footer menu altogether! We have a block, and if user is anonymous, we leave it there. For now, Demo feature only enables Lit utils module (later it will contain views).

victorkane commented 10 years ago

Demo Feature must be enabled manually (reverted) after install profile has completed.

victorkane commented 10 years ago

In order to implement the front page listing of all community (non-private) texts, we get rid of not printing content on front page since we want to take advantage of the Front page view.

victorkane commented 10 years ago

Using Chaos Tools Bulk Export Module (bulk_export) to place demo view (and non-demo front page view for now) into code, instead of features.

It is possible to create a module for:

We click on views, and select the Front Page (frontpage) view. I entered "lit_views_demo" into the module name field, and clicked on the Export button.

The result are three blocks, with code for the following files:

We can create the lit_views package module and place the lit_views_demo module in it, and integrate it into the demo feature!

victorkane commented 10 years ago

After last commit, installed from scratch, enabled demo module, masqueraded as bard, front page shows perfect cycling of demo content. Selected five pieces of content of type text from the admin content page and made them non-sticky, so admin and workshop member view works a charm on front page too when they are logged in.

victorkane commented 10 years ago

For account page listing of own texts (My texts), let's:

- [ ] Place module in a Lit User feature Don't f*_ing need a feature!!! _Ctools Bulk Export exports several features at once!!!**

victorkane commented 10 years ago

For the implementation of embedded view of associated critiques to full text node page, together with a link to add critique of your own (postponed: nested threads of critiques, we're not doing disqus today):

One plan is:

(just like in Eaton's old D6 Views Gallery). However, the latter uses the References module (specifically node reference) instead of entity reference.

For an entity reference replacement, see discussion at https://drupal.org/node/1263118 and how far the solutions offered might take us. Actually, this discussion seems to have born a child: https://drupal.org/project/entityreference_prepopulate

We should try out separate dummy entityreference_prepopulate and eva dry runs.

victorkane commented 10 years ago

We start with Entityreference prepopulate. Video Drupal 7 Entity Reference Prepopulate Module - Daily Dose of Drupal

Steps for using it in order to be able to add a way of easily adding a Critique to a Text:

The question now remains of how to create a link which appears every time we see a Text node (or reference to it, etc.), since the link is not supported itself out of the box. But that can be added in, using any method affecting the display of the node. Possible avenues:

We'll go ahead and create a content type specific node template.

Since the content type is already part of the Lit Base module, we will add to that feature the entity reference prepopulate module as well; committing the template implemented link at the same time.

victorkane commented 10 years ago

For the implementation of an embedded view of associated critiques for full text node pages, we will use the EVA: Entity Views Attachment module.

But wait, let's KISS

This is not a particularly demo thing, this is a base thing, since it is intrinsic to any use of the text full node display. So the views module should go in as a dependency of Lit Base feature, where Text itself and the add a critique link is a dependency.

victorkane commented 10 years ago

Now that the Demo feature is initially complete, to close this User Story we need to satisfy the following:

Almost everything has already been implemented.

Acceptance test for gap analysis:

lit@awebfactory.com.ar To gertrudes@awebfactory.com.ar Today at 3:56 PM gertrudes,

Thank you for registering at lit. Your application for an account is currently pending approval. Once it has been approved, you will receive another e-mail containing information about how to log in, set your password, and other details.

-- lit team

Admin receives a notification also:

lit@awebfactory.com.ar To lit@awebfactory.com.ar Today at 11:37 PM jamesj has applied for an account.

http://lit-dev.opentimebook.com/user/14/edit

  • Admin logs in and at People, edits user, assigns workshop member role and enables as active account

gertrudes receives mail:

Account details for gertrudes at lit (approved) lit@awebfactory.com.ar To gertrudes@awebfactory.com.ar Today at 3:59 PM gertrudes,

Your account at lit has been activated.

You may now log in by clicking this link or copying and pasting it into your browser:

http://lit-dev.opentimebook.com/user/reset/12/1388861959/1L0i_No0NmteRnbHrHoAt3HsP30hjMaiyhfD_2EJuhE

This link can only be used once to log in and will lead you to a page where you can set your password.

After setting your password, you will be able to log in at http://lit-dev.opentimebook.com/user in the future using:

username: gertrudes password: Your password

-- lit team

  • New workshop member logs in by clicking on the provided link, then editing and saving password and other user account details
  • New workshop member creates four or five texts

Fail: user has no link on front page or anywhere else to create text. Fixed by commit b321265d757f55a51c169dbf57e84f88537a6ce3

Bug: what happened to the controls on the front page carousel? Fixed by 8f0f00a1ef1bc18b38e9655ab5b11556b9b6e93c

Bug Workshop members and Demo users don't have permissions for text filters. Fixed by 665731ad45647955e3c182c6a47e90c9b97dff0b

Pass

Pass (gertrudes & jamesj)

Pass

Done

Pass

Fail

Fixed by 222b5c7cb168b4a647ee43fa9e0ba51829779c4b

victorkane commented 10 years ago

php.ini to prevent hanging upon user registration

realpath_cache_size = 512k
max_execution_time = 120
max_input_time = 120
memory_limit = 128M

# /etc/init.d/apache2 restart

For mail:

root@awebfactory:~# hostname opentimebook.com
root@awebfactory:~# echo opentimebook.com > /etc/hostname

Then installed postfix and sent some mails by hand:

lit@opentimebook:~$ sendmail victorkane@gmail.com
Subject: Keep trying
Never give up mind you
one
two
.
lit@opentimebook:~$ mail
-bash: mail: command not found
lit@opentimebook:~$ sendmail victorkane@gmail.com
subject: This is a test
from: lit@opentimebook.com
one
two
three
.
lit@opentimebook:~$ sendmail gertrudes@awebfactory.com.ar
subject: one
two
three
.

in another terminal:

tail -f /var/log/mail.log

Jan  4 18:45:48 opentimebook postfix/pickup[809]: 7CF5AC054A: uid=1001 from=<lit>
Jan  4 18:45:48 opentimebook postfix/cleanup[1367]: 7CF5AC054A: message-id=<20140104184548.7CF5AC054A@operntimebook.com>
Jan  4 18:45:48 opentimebook postfix/qmgr[810]: 7CF5AC054A: from=<lit@operntimebook.com>, size=291, nrcpt=1 (queue active)
Jan  4 18:45:51 opentimebook postfix/smtp[1369]: 7CF5AC054A: to=<victorkane@gmail.com>, relay=gmail-smtp-in.l.google.com[74.125.129.27]:25, delay=31, delays=29/0.01/0.27/2.4, dsn=2.0.0, status=sent (250 2.0.0 OK 1388861151 n8si49622817pax.131 - gsmtp)
Jan  4 18:45:51 opentimebook postfix/qmgr[810]: 7CF5AC054A: removed
Jan  4 18:47:15 opentimebook postfix/pickup[809]: E67DCC054A: uid=1001 from=<lit>
Jan  4 18:47:15 opentimebook postfix/cleanup[1367]: E67DCC054A: message-id=<20140104184715.E67DCC054A@operntimebook.com>
Jan  4 18:47:15 opentimebook postfix/qmgr[810]: E67DCC054A: from=<lit@operntimebook.com>, size=276, nrcpt=1 (queue active)
Jan  4 18:47:16 opentimebook postfix/smtp[1369]: E67DCC054A: to=<gertrudes@awebfactory.com.ar>, relay=awebfactory.com.ar[184.154.137.146]:25, delay=11, delays=10/0/0.22/0.27, dsn=2.0.0, status=sent (250 OK id=1VzWFg-0006ID-C7)
Jan  4 18:47:16 opentimebook postfix/qmgr[810]: E67DCC054A: removed