Giter Club home page Giter Club logo

diff's Introduction

Diff

The diff module is used to show differences between content revisions. It replaces the normal Revisions tab seen when administering nodes.

Diff enhances the listing of revisions with an option to view the differences between any two content revisions and revert back to older versions.

Access to this feature is controlled with the 'View revisions' permission. The feature can be enabled/disabled with 'Compare revisions' settings available on the configuration page for each content type.

It also provides a predefined block 'Inline differences' that can be added to any layout by using Backdrop's layout administration.

This is a port from the Drupal module of the same name, currently version 7.x-3.4.

Installation

Install this module using the official Backdrop CMS instructions at https://backdropcms.org/guide/modules.

Configuration

The main configuration settings can be found at admin/config/content/diff/settings. These enable additional 'Compare revisions' settings to be found in the configuration page for each content type - admin/structure/types.

Help & Documentation

See readme.txt for more information about usage.

License

This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.

Current maintainers

Credits

Grateful thanks to the developers and maintainers (past and present) of the Drupal 7 module.

Maintainers for Drupal:

Supporting organisations for the D7 module

diff's People

Contributors

briangilbert avatar dww avatar graham-72 avatar herbdool avatar klonos avatar massgov-outsider avatar podarok avatar robertgarrigos avatar spittlehill avatar zlyware avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diff's Issues

PHP warning from diff_node_view_alter() after installation

I've just enabled Diff and not done anything else. It looks like the default value for some config settings is NULL, when the code is expecting an array.

On the home page node of my site, I'm seeing

Warning: in_array() expects parameter 2 to be array, null given in diff_node_view_alter() (line 314 of /path/to/backdrop/modules/contrib/diff/diff.module).

going to the Diff entities config tab, I get

Warning: Invalid argument supplied for foreach() in form_type_checkboxes_value() (line 2434 of /path/to/backdrop/core/includes/form.inc).

Saving the config pages, without making any changes, make the warnings there go away.

I enabled revisions on a content type but the home page warning is still there.

Fatal TypeError on an upgrade-in-progress

TypeError: in_array(): Argument #2 ($haystack) must be of type array, null given in in_array() (line 300 of /app/modules/contrib/diff/diff.module).

I'm not exactly sure where this is coming from yet but will update as I find out more.

Deprecated function element_sort()

Similarly to #26 it's giving:

The function diff_compare_entities() (diff.pages.inc:480) called deprecated function element_sort(). It will be removed in the next major release of Backdrop.

Replacing element_sort() with backdrop_sort() didn't work. So until #27 is resolved, I need Comment Alter module (which depends on Diff) to work properly without flooding the log with the above error and therefore came up with a temporary solution in the PR offered below.

Offering to co-maintain the Diff module

Hey @Graham-72 ๐Ÿ‘‹๐Ÿผ not sure if you are around, but there are a few issues with this module that I would like to help fix, and I'm generally interested in helping you maintain the module. Do you accept?

Selected diff mode is not properly styled/denoted.

I'm splitting this from #16

  • D7 (notice how the "Standard" diff mode is also denoted as the currently selected one, by making it not look like a link ๐Ÿ‘๐Ÿผ ):
  • Backdrop (both options are shown as links - can you tell which diff mode is active?? ๐Ÿ‘Ž๐Ÿผ ):

There's a @todo item in https://github.com/backdrop-contrib/diff/blob/1.x-1.x/diff.pages.inc#L250

  $links = array();
  foreach (diff_available_states('node') as $alternative_state => $label) {
    if ($alternative_state == $state) {
      // @todo: Should we show both or just alternatives?
    }
    $links[$alternative_state] = array(
      'title' => $label,
      'href' => ...,
    );
  }

That @todo item seems to have been placed there in order to skip adding the currently selected diff mode as a link, but I think that we should still show it, but denote the active vs available diff modes differently. I propose that we make them look like secondary buttons instead.

Rough mockup:

...or with smaller buttons:

It always shows 'No visible changes'

Tested on text and integer types fields, unfortunately whatever change I make it always shows 'No visible changes'. Tried both dev and the officially released versions. Am I doing something wrong? Anyone using this module successfully?

Switch to using the Core-provided Diff Engine

Backdrop core includes a diff engine that is more up-to-date and compatible with PHP 8+, which would avoid problems like #26. Right now Diff module duplicates the entire DiffEngine which is directly available in core (used by the config sync form). This module should stop shipping it's own copy and use the one in core instead.

Regression: Default diff state mode not respected.

Testing Diff 7.x-3.3 in a D7.82 sandbox

  1. When I compared revisions, I got the "HTML" (raw) mode shown out of the box:
    image
    The path I was at was node/1/revisions/view/1/2.
  2. I switched to "Marked down" mode, which took me to node/1/revisions/view/1/2/raw-plain
  3. I switched back to "Standard" mode, which took me to node/1/revisions/view/1/2 (notice: no /raw added to the end of the path)
  4. I then navigated to admin/config/content/diff/entities and switched the "Diff default state" setting to "- None -" (which I find of no use at all by the way), and saved settings.
  5. When I compared revisions again, I got this:
    image

Testing Diff 3.4.0 in a Backdrop 1.20.0 demo sandbox

  1. I navigated to admin/config/content/diff/entities and confirmed that the "Diff default state" setting was set to "HTML view" (raw) out of the box.
  2. When I compared revisions, I got this (which is basically the "- None -" diff mode ๐Ÿ‘Ž๐Ÿผ ):
    image
    The path I was at was node/1/revisions/view/1/2.
  3. I switched to "Marked down" mode, which took me to node/1/revisions/view/1/2/raw-plain ๐Ÿ‘๐Ÿผ
  4. I switched back to "Standard" mode, which took me to node/1/revisions/view/1/2/raw (differs compared to the 7.x behavior, which is that no /raw is being added to the end of the path)
  5. I navigated to admin/config/content/diff/entities and changed the "Diff default state" setting to "Plain view" (raw-plain).
  6. When I compared revisions, I got the "- None -" diff mode again ๐Ÿ‘Ž๐Ÿผ

Storing config settings for each node type.

Diff requires three settings for each node type and these are displayed and administered on the administration form for the content type under a new entry 'Content revisions'.

In porting this module from Drupal I have added these config settings to the json file for the node type in order that they are updated through the normal saving of the content type. Maybe they should instead be stored in diff.settings.json?

In order to initiate these three settings if they have not yet been set, I have added code to function diff_form_node_type_form_alter. Is this the right way to deal with this?

"Use administration theme" setting is broken

Steps to reproduce:

  1. In a vanilla backdrop installation, install and enable the Diff module.
  2. Go to admin/config/content/diff/entities and make sure that the "Use administration theme" setting is on.
  3. Compare two revisions of a node -> the Basis theme is being used instead of Seven ๐Ÿ‘Ž๐Ÿผ
  4. Go to admin/config/content/diff/entities and disable the "Use administration theme" setting. Save.
  5. Compare two revisions of a node -> the Basis theme is being used ๐Ÿคท๐Ÿผ

Deprecated function: The each() function is deprecated.

When viewing a diff in Standard mode, I get the following error message:

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in _DiffEngine->_diag() (line 315 of /var/www/html/web/modules/contrib/diff/DiffEngine.php). 

image

I'm running PHP 7.4, and it looks like this function was removed entirely in PHP 8.0 (meaning Diff probably doesn't work in PHP 8)

See https://www.php.net/manual/en/function.each.php

Revise config settings.

The initial port of this module (release 1.x-3.2.0) does not create and maintain config settings completely and correctly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.