diff --git a/.github/workflows/review.yml b/.github/workflows/review.yml new file mode 100644 index 0000000..afc1ddf --- /dev/null +++ b/.github/workflows/review.yml @@ -0,0 +1,27 @@ +name: Review + +on: [pull_request] + +env: + TARGET_DRUPAL_CORE_VERSION: 11 + +jobs: + drupal-lint: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + + - name: Lint Drupal + run: | + docker compose --profile lint run drupal-lint + + drupal-check: + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - uses: actions/checkout@v4 + + - name: Check Drupal compatibility + run: | + docker compose --profile lint run drupal-check diff --git a/README.md b/README.md index 7241327..4f4e665 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,8 @@ # AI Sorting -Intelligent content ordering for Drupal Views using machine learning. Content automatically learns which items engage users most and surfaces the best-performing content. +Intelligent content ordering for Drupal Views using machine learning. Content +automatically learns which items engage users most and surfaces the +best-performing content. ## Features @@ -36,7 +38,8 @@ Intelligent content ordering for Drupal Views using machine learning. Content au ## Configuration - **Cache Lifetime** - How often content order refreshes -- **Automatic Cache Setup** - Views cache automatically configured for optimal performance +- **Automatic Cache Setup** - Views cache automatically configured for optimal + performance ## Dependencies @@ -44,4 +47,5 @@ Intelligent content ordering for Drupal Views using machine learning. Content au ## Related Modules -- [RL module](https://www.drupal.org/project/rl) - Core Thompson Sampling algorithm and API for developers \ No newline at end of file +- [RL module](https://www.drupal.org/project/rl) - Core Thompson Sampling + algorithm and API for developers diff --git a/ai_sorting.info.yml b/ai_sorting.info.yml index 1da7996..5711118 100644 --- a/ai_sorting.info.yml +++ b/ai_sorting.info.yml @@ -5,4 +5,4 @@ core_version_requirement: ^10.3 | ^11 package: Custom dependencies: - drupal:views - - rl \ No newline at end of file + - rl diff --git a/ai_sorting.libraries.yml b/ai_sorting.libraries.yml index 88ecedb..bad7f68 100644 --- a/ai_sorting.libraries.yml +++ b/ai_sorting.libraries.yml @@ -12,4 +12,4 @@ ai_sorting_rewards: js/ai-sorting-rewards.js: {} dependencies: - core/drupal - - core/drupalSettings \ No newline at end of file + - core/drupalSettings diff --git a/ai_sorting.module b/ai_sorting.module index b44375c..d0bfca4 100644 --- a/ai_sorting.module +++ b/ai_sorting.module @@ -5,6 +5,7 @@ * Primary module file for AI Sorting. */ +use Drupal\node\NodeInterface; use Drupal\Core\Routing\RouteMatchInterface; use Drupal\views\ViewExecutable; use Drupal\Core\Url; @@ -17,7 +18,10 @@ function ai_sorting_help($route_name, RouteMatchInterface $route_match) { case 'help.page.ai_sorting': $output = ''; $output .= '

' . t('About') . '

'; - $output .= '

' . t('The AI Sorting module provides an intelligent sorting mechanism for Drupal Views using reinforcement learning algorithms.') . '

'; + $output .= '

' . t( + 'The AI Sorting module provides an intelligent sorting mechanism + for Drupal Views using reinforcement learning algorithms.' + ) . '

'; return $output; } } @@ -32,44 +36,50 @@ function ai_sorting_views_pre_render(ViewExecutable $view) { return; } - // Collect node IDs and URLs for JavaScript tracking + // Collect node IDs and URLs for JavaScript tracking. $nids = []; $nid_url_map = []; - + foreach ($view->result as $index => $row) { - + $nid = NULL; - - // Try different ways to get the node ID + + // Try different ways to get the node ID. if (isset($row->nid)) { $nid = $row->nid; - } elseif (isset($row->node_field_data_nid)) { + } + elseif (isset($row->node_field_data_nid)) { $nid = $row->node_field_data_nid; - } elseif (isset($row->_entity) && $row->_entity instanceof \Drupal\node\NodeInterface) { + } + elseif (isset($row->_entity) && $row->_entity instanceof NodeInterface) { $nid = $row->_entity->id(); - } elseif (isset($row->_object) && method_exists($row->_object, 'id')) { + } + elseif (isset($row->_object) && method_exists($row->_object, 'id')) { $nid = $row->_object->id(); } - + if ($nid) { $nids[] = $nid; - $nid_url_map[$nid] = Url::fromRoute('entity.node.canonical', ['node' => $nid])->toString(); + $nid_url_map[$nid] = Url::fromRoute('entity.node.canonical', + ['node' => $nid])->toString(); } } if (!empty($nids)) { - // Generate experiment UUID from view and display + // Generate experiment UUID from view and display. $experiment_uuid = sha1($view->id() . ':' . $view->current_display); - // Register this experiment with the RL module - $registration_service = \Drupal::service('ai_sorting.experiment_registration'); + // Register this experiment with the RL module. + $registration_service = \Drupal::service( + 'ai_sorting.experiment_registration' + ); $registration_service->registerExperiment($experiment_uuid); - // Get RL module path for optimized endpoint + // Get RL module path for optimized endpoint. $rl_path = \Drupal::service('extension.list.module')->getPath('rl'); $base_path = \Drupal::request()->getBasePath(); - // Attach JavaScript libraries and settings + // Attach JavaScript libraries and settings. $view->element['#attached']['library'][] = 'ai_sorting/ai_sorting_turns'; $view->element['#attached']['library'][] = 'ai_sorting/ai_sorting_rewards'; $view->element['#attached']['drupalSettings']['aiSorting']['views'][$view->id()] = [ @@ -93,4 +103,4 @@ function ai_sorting_views_data_alter(array &$data) { 'id' => 'ai_sorting', ], ]; -} \ No newline at end of file +} diff --git a/ai_sorting.permissions.yml b/ai_sorting.permissions.yml index 89f3f43..8cf3fa3 100644 --- a/ai_sorting.permissions.yml +++ b/ai_sorting.permissions.yml @@ -1,3 +1,3 @@ administer ai sorting: title: 'Administer AI Sorting' - description: 'Configure AI sorting parameters in Views' \ No newline at end of file + description: 'Configure AI sorting parameters in Views' diff --git a/ai_sorting.services.yml b/ai_sorting.services.yml index 00e75f9..51508ef 100644 --- a/ai_sorting.services.yml +++ b/ai_sorting.services.yml @@ -15,4 +15,3 @@ services: ai_sorting.experiment_registration: class: Drupal\ai_sorting\Service\ExperimentRegistrationService arguments: ['@rl.experiment_registry'] - diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..091c2a1 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,32 @@ +services: + + drupal-lint: + image: composer:2.7 + profiles: ["lint"] + working_dir: /src + command: bash -c "./scripts/run-drupal-lint.sh" + environment: + TARGET_DRUPAL_CORE_VERSION: 11 + volumes: + - .:/src + + drupal-lint-auto-fix: + image: composer:2.7 + profiles: ["lint"] + working_dir: /src + command: bash -c "./scripts/run-drupal-lint-auto-fix.sh" + environment: + TARGET_DRUPAL_CORE_VERSION: 11 + volumes: + - .:/src + + drupal-check: + image: composer:2.7 + profiles: ["lint"] + working_dir: / + command: bash -c "/src/scripts/run-drupal-check.sh" + tty: true + environment: + DRUPAL_RECOMMENDED_PROJECT: 11.2.x-dev + volumes: + - .:/src diff --git a/docs/ai_sorting_project_desc.html b/docs/ai_sorting_project_desc.html index 2abdc55..903b755 100644 --- a/docs/ai_sorting_project_desc.html +++ b/docs/ai_sorting_project_desc.html @@ -1,6 +1,17 @@ -

About AI Sorting

+

This module is part of the AI module ecosystem and included in DXPR CMS.

+ +
Transform your content marketing with AI Sorting - the Drupal module that automatically learns which content engages your audience and promotes it for maximum impact. Stop guessing what works and let machine learning optimize your content visibility.
-

Transform your content marketing with AI Sorting - the Drupal module that automatically learns which content engages your audience and promotes it for maximum impact. Stop guessing what works and let machine learning optimize your content visibility.

+

You need AI Sorting if

+ + +

About AI Sorting

Boost Your Content Performance

@@ -68,6 +79,12 @@

Enterprise-Ready

  • Mobile Responsive - Works across all devices and platforms
  • +
    +

    Prefer a turnkey demo site?

    +

    Spin up DXPR CMS—Drupal pre-configured with DXPR Builder, DXPR Theme, AI Sorting module, and security best practices.

    +

    Get DXPR CMS »

    +
    +

    Dependencies