Unique Paths / Duplicate Parts

8 views
Skip to first unread message

Alan Gutierrez

unread,
Sep 7, 2009, 7:15:53 AM9/7/09
to adva...@googlegroups.com
I've just edited the sections.rb model so that the path is unique, not
the permalink slug.

http://github.com/bigeasy/adva_cms/commit/d0d3cf8bbb22eae13b1e9d9808f443c852a4593d

I'm building a website that uses each section as a single page in the
website. Different departments have different paths in the side, but
they often share page names, such as...

city/animal-control/faq
city/police/faq
faq

Adva was change these paths to read...

city/animal-control/faq-1
city/police/faq-2
faq-3

My questions are:

1) Does this have any adverse side effects? (I'm not seeing any.)
2) Is this a generally desirable behavior? (Can it be merged into the
base.)

I can see has_permalink is used in other engines, so I assume that
this change will have to be made to those engines. I'm willing to
submit this change with tests if it generally desirable.

Alan Gutierrez
http://twitter.com/bigeasy

Marko Seppä

unread,
Sep 15, 2009, 5:10:54 AM9/15/09
to adva...@googlegroups.com
Hi Alan,

thanks for your fix suggestion and reporting this problem to the list.

We have checked the change you have made but it does not correctly
solve the given problem, giving a path as a url_attribute can cause
some problems when generating the permalinks of a child sections etc.
so it does not work with the current implementation.

The validation of the permalink is done by has_permalink (acts_as_url)
plugin and you would need to fix this in the plugin level instead. The
has_permalink implementation can be found from:

engines/adva_cms/vendor/plugins/stringex/lib/lucky_sneaks/acts_as_url.rb

If you are interested to check on it.

-- Marko

Alan Gutierrez

unread,
Sep 21, 2009, 4:09:41 PM9/21/09
to adva...@googlegroups.com
Marko

I've now looked at the acts_as_url.rb plugin. Some time pack I chatted
with Clemens on IRC.

Clemens suggested, that in order to reuse a URL path part to define a
section, that URL path part would have to be unique within the scope
of both the site and the parent section.

I can see that acts_as_url.rb does not allow more of a scope beyond a
single attribute, so that will be the first thing I attempt to change.

Alan

Alan Gutierrez

unread,
Sep 22, 2009, 2:00:52 PM9/22/09
to adva...@googlegroups.com
Marko

Here is a change that appears to be working for me. It ensures that
the permalink is unique for a given site and parent id.

http://github.com/bigeasy/adva_cms/commit/daeafdcf2e24241da89d09beb721ce7d36443be2

It is a modification to acts_as_url.rb that optionally accepts an
array of scopes.

Alan

On Sep 15, 2009, at 4:10 AM, Marko Seppä wrote:

>

Marko Seppä

unread,
Sep 25, 2009, 4:40:22 AM9/25/09
to adva...@googlegroups.com
Hi Alan,

I tried your change but I get 1 error related to categories when
running the test suite. I am using master branch. Also I get lots of
to_a complaints to my console screen. So seems like it is not fully
working with current adva-cms implementation. By working for you do
you mean that all the test pass on your machine?

-- Marko

Alan Gutierrez

unread,
Sep 25, 2009, 2:03:24 PM9/25/09
to adva...@googlegroups.com
Marko

I've not been able to get the test suite to run without errors yet, so
I didn't try the tests. I'll work on this more next week.

Alan

Marko Seppä

unread,
Sep 29, 2009, 3:43:00 AM9/29/09
to adva...@googlegroups.com
Hi Alan,

what kind of problems are you having with the test suite? I tried to
run the test suite yesterday with postgresql and noticed that it
generates tons of errors, but for mysql and sqlite3 tests should be
runnable.

-- Marko

Alan Gutierrez

unread,
Oct 7, 2009, 10:48:52 PM10/7/09
to adva...@googlegroups.com
Marko

I've just attempted to run the test suite against a bare bones Rails
app that includes Adva.

I installed Adva using git submodule and included the most recent
master.

I created a script/test-avda-cms

ruby script/test-adva-cms

And I get a stacktrace...

/Users/alan/git/adva_development/vendor/plugins/adva_blog/test/
functional/blog_articles_routes_test.rb:32: Called id for nil, which
would mistakenly be 4 -- if you really wanted the id of nil, use
object_id (RuntimeError)
from /Users/alan/git/adva_development/vendor/plugins/adva_blog/test/
functional/blog_articles_routes_test.rb:30:in `each'
from /Users/alan/git/adva_development/vendor/plugins/adva_blog/test/
functional/blog_articles_routes_test.rb:30
from /Users/alan/git/adva_development/vendor/plugins/adva_blog/test/
functional/blog_articles_routes_test.rb:29:in `each'
from /Users/alan/git/adva_development/vendor/plugins/adva_blog/test/
functional/blog_articles_routes_test.rb:29
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
node.rb:23:in `instance_eval'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
node.rb:23:in `define'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
context.rb:16:in `build'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
context.rb:16:in `each'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
context.rb:16:in `build'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
context.rb:14:in `each'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/with/
context.rb:14:in `build'
from /Users/alan/git/adva_development/vendor/adva/test/with/lib/
with.rb:21:in `describe'
from /Users/alan/git/adva_development/vendor/plugins/adva_blog/test/
functional/blog_articles_routes_test.rb:28
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from /opt/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/
active_support/dependencies.rb:158:in `require'
from ./vendor/adva/script/test:46:in `run'
from ./vendor/adva/script/test:46:in `each'
from ./vendor/adva/script/test:46:in `run'
from ./vendor/adva/script/test:53
from script/test-adva-cms:3:in `load'
from script/test-adva-cms:3


Alan

Alan Gutierrez

unread,
Oct 7, 2009, 11:10:50 PM10/7/09
to adva-cms
Marko

A little more progress.

I ran...

ruby script/test-adva-cms -p
Preparing the database ...
/opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require': no such file to load -- /Users/alan/git/
adva_development/vendor/engines/adva_cms/test/test_helper
(MissingSourceFile)
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from /opt/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/
active_support/dependencies.rb:158:in `require'
from /Users/alan/git/adva_development/vendor/plugins/adva_cells/test/
test_helper.rb:1
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from /opt/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/
active_support/dependencies.rb:158:in `require'
from /Users/alan/git/adva_development/vendor/plugins/adva_cells/test/
integration/article_with_contact_mailer_test.rb:1
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from /opt/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
from /opt/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/
active_support/dependencies.rb:158:in `require'
from ./vendor/adva/script/test:46:in `run'
from ./vendor/adva/script/test:46:in `each'
from ./vendor/adva/script/test:46:in `run'
from ./vendor/adva/script/test:53
from script/test-adva-cms:3:in `load'
from script/test-adva-cms:3


ruby script/test-adva-cms vendor/plugins/adva_cms

Which emitted a test run with warning and ended with...

1) Error:
test_categories_are_not_selectable_in_single_article_mode
(IntegrationTests::AdminSectionArticleTest):
NoMethodError: undefined method `stubs' for #<Class:0x2333dec>
activerecord (2.3.3) lib/active_record/base.rb:1959:in
`method_missing_without_paginate'
vendor/plugins/adva_cms/vendor/plugins/will_paginate/lib/
will_paginate/finder.rb:167:in `method_missing'
vendor/plugins/adva_cms/test/integration/admin/
section_article_test.rb:87:in `section_in_single_article_mode'
vendor/plugins/adva_cms/test/integration/admin/
section_article_test.rb:36:in
`test_categories_are_not_selectable_in_single_article_mode'
activesupport (2.3.3) lib/active_support/testing/
setup_and_teardown.rb:62:in `__send__'
activesupport (2.3.3) lib/active_support/testing/
setup_and_teardown.rb:62:in `run'
actionpack (2.3.3) lib/action_controller/integration.rb:645:in
`run'

2) Error:
test_categories_are_selectable_in_multi_article_mode
(IntegrationTests::AdminSectionArticleTest):
NoMethodError: undefined method `stubs' for #<Class:0x2333dec>
activerecord (2.3.3) lib/active_record/base.rb:1959:in
`method_missing_without_paginate'
vendor/plugins/adva_cms/vendor/plugins/will_paginate/lib/
will_paginate/finder.rb:167:in `method_missing'
vendor/plugins/adva_cms/test/integration/admin/
section_article_test.rb:94:in `section_in_multi_article_mode'
vendor/plugins/adva_cms/test/integration/admin/
section_article_test.rb:43:in
`test_categories_are_selectable_in_multi_article_mode'
activesupport (2.3.3) lib/active_support/testing/
setup_and_teardown.rb:62:in `__send__'
activesupport (2.3.3) lib/active_support/testing/
setup_and_teardown.rb:62:in `run'
actionpack (2.3.3) lib/action_controller/integration.rb:645:in
`run'

3) Error:
test_#content_status_returns_span_with_pending_title_and_alt_if_passed_object_is_not_published
(LinkToContentHelperTest):
NoMethodError: undefined method `stubs' for #<Article:0x6f64fcc>
activerecord (2.3.3) lib/active_record/attribute_methods.rb:260:in
`method_missing'
vendor/plugins/adva_cms/test/unit/helpers/content_helper_test.rb:
63:in
`test_#content_status_returns_span_with_pending_title_and_alt_if_passed_object_is_not_published'
activesupport (2.3.3) lib/active_support/testing/
setup_and_teardown.rb:62:in `__send__'
activesupport (2.3.3) lib/active_support/testing/
setup_and_teardown.rb:62:in `run'

513 tests, 1209 assertions, 0 failures, 3 errors

Alan

Alan Gutierrez

unread,
Oct 8, 2009, 9:15:21 AM10/8/09
to adva-cms
Marko

The example project I'm using can be found here...

http://github.com/bigeasy/adva_development

I'm using git submodules to pull in Adva from a GitHub fork of the
project.

Alan Gutierrez

Alan Gutierrez

unread,
Oct 8, 2009, 4:07:03 PM10/8/09
to adva...@googlegroups.com
Marko

Thank you for your help this morning. As noted, the problem was that I
did not have mocha installed. For posterity, here is how I
successfully run the tests.

git clone git://github.com/bigeasy/adva_development.git && cd
adva_development \
&& git submodule init && git submodule update
rake adva:install:all -R vendor/adva/engines/adva_cms/lib/tasks &&
rake db:test:clone

Now, getting back to my changes to acts_as_permalink.rb...

I've changed the http://github.com/bigeasy/adva_development repository
to reference a branch my cloned Adva.

http://github.com/bigeasy/adva_cms/tree/acts_as_permalink

If you checkout and run the tests as above, you'll see the same single
error that we had this morning, no new errors, so hopefully, no damage
caused by my changed.

If so, I humbly request that the patch be accepted. The goal is to
allow the reuse of URL permalink parts as in...

city/police/faq
city/animal-control/faq
city/sanitation/faq

Where the current Adva CMS will make the faq part unique for an entire
site, instead of a particular site and section.

city/police/faq-1
city/animal-control/faq-2
city/sanitation/faq-3

Also, I don't see where the permalinks get updated when a section is
saved. They only get updated when I rearrange the sections in the
section layout, so that might be my next task.

Alan

Marko Seppä

unread,
Oct 9, 2009, 7:00:21 AM10/9/09
to adva...@googlegroups.com
Hi Alan,

I just applied your patch to adva-cms master.

Thanks for contribution!

-- Marko

Alan Gutierrez

unread,
Nov 8, 2009, 12:31:29 AM11/8/09
to adva...@googlegroups.com
Looks like my fix to acts_as_url is being thwarted by validation in
the Session model that uses site_id as the scope instead of site_id
and parent_id.

I've created a development branch of an Adva CMS fork that has this
little change. I've updated the example project that I used for
testing...

http://github.com/bigeasy/adva_development

You can pull this project and run ...

git submodule init && git submodule update

And then run the tests. Five test fail, however the same five tests
fail without the change.

test_sets_the_mail_up_correctly_for_articles
test_sets_the_mail_up_correctly_for_comments
test_sets_the_mail_up_correctly_for_wikipages
test_comment_should_be_rejected_when_sent_as_an_anonymous_and_default_spam_filter_is_set_to_
test_comment_should_be_rejected_when_sent_as_an_anonymous_and_spam_filter_is_disabled

Thank you.

Alan
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "adva-cms" group.
> To post to this group, send email to adva...@googlegroups.com
> To unsubscribe from this group, send email to adva-cms+u...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/adva-cms?hl=en
> -~----------~----~----~----~------~----~------~--~---
>

Alan Gutierrez

unread,
Nov 11, 2009, 2:40:05 AM11/11/09
to adva-cms
Nudge, nudge. Alan

Marko Seppä

unread,
Nov 20, 2009, 8:12:01 AM11/20/09
to adva...@googlegroups.com
Hi Alan,

sorry for a long delay on this. Just applied your patch to the adva-
cms master.

Thanks for contribution,

-- Marko
> --
>
> You received this message because you are subscribed to the Google
> Groups "adva-cms" group.
> To post to this group, send email to adva...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/adva-cms?hl=
> .
>
>

Reply all
Reply to author
Forward
0 new messages