summaryrefslogtreecommitdiff
path: root/app/models/page.rb
AgeCommit message (Collapse)Author
28 hoursclone_attributes_from: update translations in place, not delete+recreateerdgeist
Every promotion (autosave creation, draft creation, draft save) ran every locale's translation through delete-all-then-recreate unconditionally, giving every locale a fresh created_at/updated_at regardless of whether its content actually changed. Confirmed via Node.find(546).draft.translations -- both DE and EN shared one identical timestamp despite only EN having been edited. This silently defeated Page.find_with_outdated_translations' whole staleness comparison: every save reset every locale back into lockstep, so timestamps could never actually drift apart the way the feature depends on. The existing test for it only ever passed by manually backdating a timestamp with record_timestamps = false, bypassing normal save flow entirely -- not something that happens through ordinary editing. Now updates a matching locale's translation only when its own attributes actually differ, creates one genuinely new, and removes one genuinely gone from the source -- same end state, but real per-locale timestamps survive an unrelated save. search_vector is excluded from both the comparison and the copied attributes: it's DB-trigger-maintained from title/abstract, not real content, and comparing a precomputed tsvector risked a false 'changed' from representation noise alone. Also reloads the source's translations association, not just self's -- clone_attributes_from previously only guaranteed a fresh self, leaving any caller holding a page reference across an earlier mutation vulnerable to reading a stale cached association.
30 hoursAdd per-node translation management: list, edit, destroy, compareerdgeist
Replaces the old locale-switch-and-edit-the-same-screen workflow, which conflated presentation locale with content locale and let an editor silently drift into editing the wrong language with no persistent signal that anything had changed. Non-default-locale content now has its own explicit routes and screens, never sharing a route param with the ambient chrome locale. - PageTranslationsController: index/show/edit/update/destroy, scoped to Page.non_default_locales; update handles first-time creation too, so there's no separate new/create step. - Reads go through the actual PageTranslation row (Page#translation_summary), never through the Globalize fallback-bearing accessor -- fallback is correct for public rendering but wrong for editing, where a missing translation needs to look empty, not borrowed from another locale. - Translations ride on the page's own draft/head cycle; no independent publish state. - nodes#show gains a Translations section (per-locale Lock+Edit / Create+Lock, Destroy, a link into the read-only Compare view) and a locale indicator on its own default-locale content; nodes#edit, nodes#update, and nodes#autosave are pinned to the default locale via Globalize.with_locale regardless of the ambient route locale. - nodes#show no longer double-loads the node or calls wipe_draft! on every view (see previous commit for why that's now safe). - .preview_link_row is renamed .aligned_action_row now that it has a second real consumer.
3 daysMake page_translations' search trigger self-installingerdgeist
search_vector is populated by a raw Postgres trigger created via execute() in a migration -- invisible to schema.rb, which only represents structure Rails understands. Any database rebuilt from schema.rb rather than replayed migrations (test, a fresh db:setup, disaster recovery) silently lost full-text search entirely, with no error -- NULL @@ anything is never true in Postgres. Page.ensure_search_vector_trigger!, called from an after_initialize initializer, reinstalls the trigger via CREATE OR REPLACE on every boot, in every environment. Idempotent and cheap.
5 daysInclude assets, tags and template in diff between revisionserdgeist
5 daysRetire vendored cacycle_diff.js for a diff-lcs-based diff viewerdgeist
Revisions#diff now computes an inline or side-by-side word diff server-side (Page#diff_against, lib/html_word_diff.rb) instead of shipping raw/escaped content to the browser for a 2008-era vendored JS differ to mangle. View mode is picked via a `view` param, settable either on the diff page itself or directly from the revisions#index sticky bar next to "Diff revisions". Also fixes a pre-existing bug in RevisionsController#diff's single- revision branch, which set params[:start]/params[:end] instead of params[:start_revision]/params[:end_revision].
5 daysFix malformed-HTML fallout across RSS, link rewriting, and flash messagingerdgeist
Editors' TinyMCE output can contain unclosed void elements like <br>, which is valid HTML5 but invalid XML -- three different places assumed the stricter rule and broke or silently misbehaved on the looser one. The Atom feed's <content type="xhtml"> block required real, well-formed XML structure but was handed a raw, unescaped body string; switched to type="html" with CGI.escapeHTML, matching how title/summary already handle the same content. rewrite_links_in_body used libxml's strict XML parser to rewrite internal links to be locale-prefixed, which raised on exactly this class of malformed markup -- silently, since the whole method was wrapped in rescue; nil, meaning the link rewrite (not the save) quietly failed with no error anywhere. Replaced with Nokogiri's lenient HTML parser, which repairs malformed void elements rather than rejecting them; also drops the bare rescue now that the actual failure mode it was guarding against shouldn't occur, and fixes two adjacent bugs found while in this method: a typo'd /sytem/uploads/ regex that could never match, and a missing https:// exclusion alongside the existing http:// one. Also addresses stale flash messaging surfaced while testing the above: update's save confirmation was being clobbered by edit's own "locked and ready" notice on the very next request, since nothing distinguished a fresh lock acquisition from a redirect back after saving. The save confirmation now names the next step (publish from Status) and flags a stale translation if one exists, using Page#outdated_translations?, already present but previously unused by any controller.
6 daysMake sure that page title actually is saved through to ORMerdgeist
8 daysAdd tree-position scoping to Page.aggregateerdgeist
New :children option ("direct" or "all") on the [aggregate] shortcode, composable with the existing :tags filter - both apply as independent successive .where clauses, ANDing together automatically, no special casing needed. content_helper.rb passes the current @page.node through as :node whenever :children is requested, since Page.aggregate has no way to resolve "which node" from the shortcode's bare option strings on its own. Guarded so nothing changes for any existing [aggregate] shortcode that never uses children= - :node stays nil, the new branch never fires. "all" resolves via node.descendants.pluck(:id) rather than embedding the descendants relation directly as a subquery. Not proven strictly necessary - extensive debugging this session initially pointed at a subquery/table-alias collision, but every actual failure traced instead to accumulated test-node debris left in the dev DB by earlier interrupted runs, confirmed by re-running against a cleaned database. Kept anyway as a one-round-trip-cheaper, more defensive default regardless.
9 daysAdd preview_token to pageserdgeist
New column + unique index, plus ensure_preview_token!/revoke_preview_token! on Page. Generated lazily (only when explicitly requested) rather than via has_secure_token's default auto-generate-on-create, so a live, shareable secret isn't silently minted for every page ever created.
9 daysAdd erfa/chaostreff node-kind creation conventionserdgeist
lib/ccc_conventions.rb: NODE_KINDS registry replaces the kind-specific branches previously scattered across nodes_controller#create (tags), unique_path-position check). Each kind declares its parent lookup (a Proc - Update's "update"/"press_release" continue to genuinely find-or-create their year-folder via Update.find_or_create_parent; erfa/chaostreff use a plain find_by_unique_name!, since their parent nodes are fixed and a missing one should fail loudly, not be silently created), its tags, and (new) its default template. Node gains a default_template_name column (migration, with backfill for existing update-tree nodes via node.update? - reusing that method rather than re-deriving its unique_path check in raw SQL). Page#set_template now inherits from node.default_template_name, falling back to the old update?-based check only when the column is blank, and only fills in template_name when nothing's already been explicitly chosen - a deliberate change from the previous behavior, which unconditionally overwrote template_name on every save regardless of manual selection. Node#update? itself is unchanged and still used as-is by admin_controller's sitemap filtering - a genuinely different, still valid use of that check. "generic" stays special-cased in the controller, parametrized by params[:parent_id] at request time - doesn't fit "kind implies a fixed lookup" and isn't in the registry. nodes#new's four hardcoded radio buttons and nodes_controller's kind-specific case/when branches are both replaced by iterating/looking up this one registry - adding a new kind now means one new hash entry, not four scattered edits.
2026-06-30Fix events CRUD for standalone events and add events to admin menuerdgeist
- event_params now permits title, description, is_primary - event_information helper lists all node.events, not just the first - Occurrence.generate handles nil node (standalone events) - Page.aggregate order_by title uses correlated subquery to avoid GROUP BY conflict with tag-filter path; order_direction whitelisted to ASC/DESC to prevent SQL injection - Events link added to admin menu bar - events/index shows title, is_primary; drops latitude/longitude columns
2026-06-30Phase 2: chapter nodes, aggregate partial, fixeserdgeist
- _chapter.html.erb: new partial for erfa/chaostreff aggregated lists; renders title, location, external_url, sanitized body - content_helper: fix aggregate attr regex to allow hyphens in values (erfa-detail tag was silently dropped); add debug logging (remove) - page.rb: suppress libxml stderr noise in rewrite_links_in_body - db/seeds/chapters.rb: one-shot seed script for erfa and chaostreff chapter nodes under parent nodes 548/549; creates bilingual pages, external_url, primary events with RRULEs where known Note: run Node.rebuild!(false) after execution to fix lft/rgt values
2026-06-27Stage 7 click-testing fixeserdgeist
- aggregate: switch to shortcode syntax [aggregate ...]; fix paragraph wrapping by excising the shortcode and its surrounding <p> before sanitize, concatenating collection output outside sanitized content - page.rb: remove aggregate XML unwrapping from rewrite_links_in_body (no longer needed with shortcode approach) - rss builders: explicit CGI.escapeHTML on title/abstract; Builder 3.3.0 does not escape when target buffer is html_safe (ActionView default) - tinymce: disable menubar and promotion nag; add code plugin, remove paste plugin (built into TinyMCE 8 core); configure via admin_interface.js directly (config/tinymce.yml affects tinymce() helper only, not tinymce.init)
2026-06-27Stage 7: Rails 7.2 → 8.1 on Ruby 3.2.11erdgeist
- Bump Rails to 8.1.3 (Ruby unchanged at 3.2.11, new gemset rails8-upgrade) - config.load_defaults 8.1; merge app:update diffs for all environment files - Remove routing-filter 0.7.0; replace with native scope '(:locale)' in routes.rb and default_url_options in ApplicationController - Delete config/initializers/routing_filter_rails71_patch.rb - Replace vendored TinyMCE 3.x (~200 files) with tinymce-rails ~> 8.3; migrate admin_interface.js from jQuery .tinymce()/advanced theme to tinymce.init(); add config/tinymce.yml; note: TinyMCE 7+ is GPL - rails-i18n ~> 8.0 added explicitly (previously indirect dependency) - awesome_nested_set, acts-as-taggable-on pinned to git main/master (gemspec activerecord < 8.1 ceiling; no functional incompatibility; repin to version once upstream releases updated gemspecs) - globalize ~> 7.0, libxml-ruby ~> 5.0, nokogiri ~> 1.18, pg ~> 1.5 - sass-rails, coffee-rails, uglifier moved from :assets group to main (Sprockets 4 convention; :assets group no longer meaningful) - Node: head, draft, lock_owner marked belongs_to optional: true - Page: node, user, editor marked belongs_to optional: true - Static assets in public/images/ and public/javascripts/ referenced via plain HTML tags; Rails 8 load_defaults raises on pipeline helpers for undeclared assets - sessions_controller_test.rb: remove stale require and dead rescue_action - users_controller_test.rb: assert button[type=submit] not input[type=submit] (Rails 8 button_to renders <button> not <input>) - test_helper.rb: node.reload after children.create! (awesome_nested_set 3.9.0 does not refresh parent in memory after callback) - 129 runs, 339 assertions, 3 failures, 0 errors — identical baseline to 7.2
2026-06-26Stage 5: Rails 6.1 → 7.2 on Ruby 3.2.11erdgeist
- Bump Rails to 7.2.3, Ruby to 3.2.11 (new gemset rails7-upgrade) - pg pinned to 1.4.6 (bridge: Ruby 3.2 compatible, PostgreSQL 9.6 tolerant) - acts-as-taggable-on → 12.x (Rails 7.2 + Ruby 3.2 support) - awesome_nested_set → 3.7.0 (Rails 7.2 support, avoids 3.9.0 lft/rgt bug) - globalize → 7.0 (Rails 7.x required) - libxml-ruby → 5.x (Ruby 3.2 required) - unicorn → 6.x; fix unicorn.rb: RAILS_ROOT→Rails.root, RAILS_ENV→ENV, File.exists?→File.exist? - Add puma for development server - Remove dead initializers: assets.rb, ruby2.rb, backtrace_silencers.rb, new_rails_defaults.rb - Fix File.exists? → File.exist? in page.rb and authors_importer.rb - Add routing_filter_rails71_patch.rb (restores params[:locale] on Rails 7.1+)
2026-06-26Stage 4: Rails 5.2 -> 6.1 on Ruby 2.7.2erdgeist
- routing-filter 0.6.3 -> 0.7.0 (Rails 6.1 compatibility) - RSS named routes rss_xml/rss_rdf added - RouteWithParams workarounds: will_paginate_patch, content_path shim, safe_path helper - Paperclip removed, replaced with FileAttachment concern (preserves URL scheme) - Assets resource moved to /admin/assets (Sprockets middleware conflict) - ApplicationRecord base class added, all models migrated - Strong parameters added to Assets, Occurrences, Events, MenuItems controllers - update_attributes -> update throughout - render :nothing -> head :ok/:not_found throughout - language_selector rewritten (removes :overwrite_params) - Environment files updated for Rails 6.1 (eager_load, public_file_server, ActionMailer) - Arel::Visitors::DepthFirst and Integer/Float duration patches removed from test_helper - AssetsController tests added (10 tests covering upload, variants, destroy, auth) - ImageMagick geometry: 460x250! for headline crop (not # which is invalid in IM6) 129 runs, 311 assertions, 5 failures (all pre-existing), 0 errors
2026-06-25Rails 5.2 application fixeserdgeist
- Rename before_filter → before_action across all controllers - Fix string conditions in validators to lambda syntax (node.rb) - Fix publish_draft!: move staged slug/parent logic outside draft guard, use move_to_child_of for parent changes, add nil guard for no-op calls - Fix update_unique_names_of_children: use parent_id traversal instead of lft/rgt descendants (awesome_nested_set 3.x lft/rgt update bug) - Fix unique_path to return Array instead of String - Fix Occurrence.delete_all syntax for Rails 5 - Fix Page.find_with_outdated_translations: use includes instead of all - Fix outdated_translations?: use find instead of splat array
2026-06-25Rails 4.2 model and controller fixeserdgeist
- Wrap all scopes in lambdas (required in Rails 4) - Move scopes after associations in page.rb (evaluated at load time in Rails 4) - Convert association :order options to lambda syntax - Remove attr_accessible from page.rb and user.rb - Add Strong Parameters: user_params in UsersController, node_params/page_params in NodesController - Fix clone_attributes_from: exclude id/page_id/timestamps when cloning translations - Fix redirect_to :back → request.referer fallback in nodes_controller - Fix node_path/publish and unlock actions: pass @node argument
2026-06-24Fix tagged content aggregator, assets path, and add regression testserdgeist
- Replace tagged_with calls in Page.aggregate, TagsController, RssController with direct SQL joins (acts-as-taggable-on 3.5 broken on Rails 3.2) - Fix Paperclip :path/:url to use plain :id format matching existing uploads - Add proper regression tests for aggregator, tags, and rss controllers - Fix assert_select assertions to target div.body div.article_partial
2026-06-24Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgradeerdgeist
- Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs
2026-06-23Update deployed state to what's currently runningerdgeist
2025-01-28Big overhaul patch and style changesCharlie Root
2012-02-18Bugfix: Finally after all those years, asset urls are not rewritten anymore with a locale prefix! Hoorray!hukl
2010-03-03do not rewrite paths for assetshukl
2010-01-14Updated globalize2 to latest version. Modified existing code accoringlyhukl
2009-12-01refactored the Page.aggregate to instanciate a lot less AR objects. Its actually instanciating only the ones being displayed. Still over 150 but still a ↵hukl
massive improvement compared to over 1500 before.
2009-11-17don't set the published_at upon creation of the first draft but rather on publishhukl
2009-11-15removed date and author from the standard template and introduced a dedicated update template which will get auto assigned if a node is created under ↵hukl
updates/<year>/<slug> Added tests and convenient method
2009-11-11implemented that pages now have an author and an editorhukl
2009-11-03default now 25hukl
2009-11-02make sure user and published_at stay the samehukl
2009-10-27fix for emtpy assets arrayhukl
2009-10-20allow to overwrite the original user in edit viewhukl
2009-09-17switched tagging plugin again for postgresql compatibility hukl
2009-09-05prepend public_link with slashhukl
2009-09-04moved the image sorting into the model and wrapped it into a transactionhukl
2009-09-01cloning a page clones the asset references as wellhukl
2009-09-01added expirimental routing for image galerieshukl
added plain image gallery template refinements
2009-09-01added related_assets to pageshukl
2009-08-16migration to add missing columns and indexes for acts_as_taggable_redux as well as other related modificationshukl
2009-08-15changed the implementation of Page.aggregate once more. Now faster, better shorter with acts_as_taggable_reduxhukl
2009-08-15added pagination for aggregators. costed me the whole day. crappy plugins ARGH! More work to do!hukl
2009-07-18Test::Unit Fixtures can't handle globalize2's translated attributes which is why its impossible to set translated attributes via fixtures. Therefor I ↵hukl
removed the page fixtures entirely and and made sure that a title is set to "Untitled" when it is not specified otherwise. If a new node is created, its initial draft has "Untitled" set as title automatically. Modified tests accordingly
2009-07-18cleaned up the Page#public_link methodhukl
2009-04-18changed :include to :join which is much faster. adding named scopes with includes if they are neededhukl
2009-03-30added named scope for headshukl
2009-03-29minor refactorhukl
2009-03-29a few more assertionshukl
2009-03-29refactored the outdated translations functionality. also adding flexibility to allow filtering with custom values.hukl
2009-03-29Added unit test to verify the basic functionality of the find_with_outdated_translations method. Found and fixed some issued on the way. [ x ] Testing rockshukl