Project description

Implementing a persistent audio player on a Drupal website has long been a frustrating task. (See here, here, here, here and here, among others.) Ajax pages solves this problem by implementing full page reloads via Ajax, with the possibility to create region(s) that will be exempt from such loading. An audio player can be put in such a region to implement continuous audio playback as the user browses the website's pages.

Live demos: Mediazoic, New Canadian Music

Features

  • Works inobtrusively out of the box
  • Requires only minimal theme modifications
  • Browser address bar updating using HTML5's history.pushState()
  • Full page reloading (page_top, page and page_bottom regions)
  • Transparently ajaxifies forms, including GET ones
  • Handles redirects
  • Loads additional CSS and JS files as required
  • JS/CSS preprocessors and aggregation friendly
  • Ajax requests are GET and fully cacheable (also with Boost!)

Similar projects

AJAXify pages attempts to solve a similar problem but it uses a generic, client-side based approach to reloading page content. While this makes for simpler code, this also brings important problems that prevent AJAXify pages from being a truly generic solution:

  • No redirect handling
  • No loading of extra CSS and JS files with aggregation/compression enabled
  • No ajaxifying of forms
  • No Drupal.settings updating (would have to resort to brutally parsing HTML?)

Ajax pages, on the other hand, relies heavily on the Drupal Ajax framework and intelligent processing of Ajax requests on the server side. This helps make the above functionality possible, and more.

Links

Project page: http://drupal.org/sandbox/jamix/1988012
Git repository: git clone --branch 7.x-1.x http://git.drupal.org/sandbox/jamix/1988012.git ajax_pages

Comments

PA robot’s picture

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

yandex-plugins’s picture

jamix’s picture

Thank you. Just for a record, here is what yandex-plugins is referring to:

FILE: /var/www/drupal-7-pareview/pareview_temp/README.txt
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
54 | WARNING | Line exceeds 80 characters; contains 83 characters
--------------------------------------------------------------------------------

FILE: /var/www/drupal-7-pareview/pareview_temp/ajax_pages.module
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
130 | ERROR | If the line declaring an array spans longer than 80 characters,
| | each element should be broken into its own line
--------------------------------------------------------------------------------

I am aware of both issues and not fixing them is deliberate. For #1, there's no way to sensibly break that line since it's a string of PHP code. #2 is a nearly verbatim quote from core (block_admin_configure()) with formatting preserved.

Dalay’s picture

Hi, jamix.
No errors found, just don't understand some thing.

From README.txt:

* In your theme's html.tpl.php file, wrap the output of the page_top, page and
  page_bottom regions inside a div with a unique id.
  ...
* Go to the settings page at Administration -> Configuration -> User interface 
  -> Ajax pages and define the Page wrapper selector.

Why force the user to perform extra steps? I would rather implement this functionality with a hook_preprocess_html() in the module. The same goes for "Adding a persistent region".

jamix’s picture

Hi Dalay, thank you for the comments. How exactly would you implement wrapping the output of the page_top, page and page_bottom regions via hook_preprocess_html()? And, more importantly, if we were to do such things for the end user, how would we know a). How many persistent regions they want, b). Where they should be output in relation to the page wrapper (before or after, with some other div's inbetween perhaps) and c). How they should be ordered?

There's just too many variables here so all these are best solved on the theme level by the end user. Trying to automate these tasks would bring unnecessary complexity to the module.

Dalay’s picture

How exactly would you implement wrapping the output of the page_top, page and page_bottom regions via hook_preprocess_html()?

I hurried. It will be easier with using hook_page_build(), like:

function  ajax_pages_page_build(&$page) {
  $page['page_top']['#prefix'] = '<div id="page-wrapper">';
  $page['page_bottom']['#suffix'] = '</div>';
}
And, more importantly, if we were to do such things for the end user, how would we know a). How many persistent regions they want...

Yes, perhaps you're right here, Artem.

Dalay’s picture

How exactly would you implement wrapping the output of the page_top, page and page_bottom regions via hook_preprocess_html()?

I hurried. It will be easier with using hook_page_build(), like:

function  ajax_pages_page_build(&$page) {
  $page['page_top']['#prefix'] = '<div id="page-wrapper">';
  $page['page_bottom']['#suffix'] = '</div>';
}
And, more importantly, if we were to do such things for the end user, how would we know a). How many persistent regions they want...

Yes, perhaps you're right here, Artem.

Dalay’s picture

Remove repost, please. )

jamix’s picture

I hurried. It will be easier with using hook_page_build(), like:

Using #prefix and #suffix on $page['page_top'] and $page['page_bottom'] looks a bit hacky to me. Sure, in most cases the order of the regions in html.tpl.php will be what we expect it to be (page_top, page, page_bottom) and thus such wrapping will work, but in some whacky situations where the user alters their html.tpl.php, that may lead to unforeseen and hard to trace bugs.

Dalay’s picture

Using #prefix and #suffix on $page['page_top'] and $page['page_bottom'] looks a bit hacky to me.

Why? Using Render API is a hacky for you?))

... but in some whacky situations where the user alters their html.tpl.php, that may lead to unforeseen and hard to trace bugs.

In this case, and your code will not work:
line 232, ajax_pages.module

$content = $html_variables['page_top'] . $html_variables['page'] . $html_variables['page_bottom'];
jamix’s picture

Why? Using Render API is a hacky for you?))

No, but it's hacky to assume a certain order in which the elements will be output.

In this case, and your code will not work:
line 232, ajax_pages.module

Good point. I think it will make sense to add a template for that bit so that if necessary, it could be modified to correspond to what's inside the html.tpl.php wrapper. This is hardly a review blocker though and can be dealt with in the module's issue queue.

petu’s picture

Hello jamix!

I reviewed your module:

FILE: /var/www/drupal-7-pareview/pareview_temp/README.txt
--------------------------------------------------------------------------------
FOUND 0 ERROR(S) AND 1 WARNING(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
54 | WARNING | Line exceeds 80 characters; contains 83 characters
--------------------------------------------------------------------------------

FILE: /var/www/drupal-7-pareview/pareview_temp/ajax_pages.module
--------------------------------------------------------------------------------
FOUND 1 ERROR(S) AFFECTING 1 LINE(S)
--------------------------------------------------------------------------------
130 | ERROR | If the line declaring an array spans longer than 80 characters,
| | each element should be broken into its own line
--------------------------------------------------------------------------------

  1. There is no critical errors in lines above, but it's better to fix all of them.

BTW: I'm going to use your module in my client's project. So it would be great to add a feature to apply your module just for several pages in addition for suppression Ajax pages. Like it does for blocks for example.

Thank you for your module!

petu’s picture

Status: Needs review » Needs work
klausi’s picture

Status: Needs work » Needs review

minor coding standard errors are not application blockers, please do a manual review.

and do not use t() in hook_menu().

petu’s picture

Status: Needs review » Reviewed & tested by the community

Hello Klaus!

You are right about t() in hook_menu(). Шэму corrected my previous post.
I've reviewed the code manually, installed the module on my project.
I suppose the code is ok.

mlncn’s picture

Thanks for your contribution, jamix! You are now a vetted Git user. You can promote this to a full project and also create new projects as either a sandbox or a full project.

This is a solid project and i'm not going to set it back to needs work after a month at RTBC, but please do remove that t() in hook_menu().

Here are some recommended readings to help with excellent maintainership:

You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!

Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

And thanks to the reviewers!

kscheirer’s picture

Status: Reviewed & tested by the community » Fixed

fixed in #16.

----
Top Shelf Modules - Crafted, Curated, Contributed.

jamix’s picture

Thank you, and thanks to all of the reviewers for helping make Ajax pages a full project!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Anonymous’s picture

Issue summary: View changes

Formatting changes