-
Notifications
You must be signed in to change notification settings - Fork 127
Forums
More important than the thread's forum id (detailed below in Abandoned Approach ) is the idea of a comment's context:
Table "public.comment"
Column | Type | Modifiers
------------+--------------------------+------------------------------------------------------
id | integer | not null default nextval('comment_id_seq'::regclass)
users_id | bigint |
content | text | not null
context | text | not null
context_id | bigint | not null
deleted | integer | not null default 0
readonly | integer | not null default 0
is_html | integer | not null default 0
data | text | not null default '{}'::text
created | timestamp with time zone | not null
updated | timestamp with time zone | not null
ghosted | integer | not null default 1
checked | bigint |
seen_live | integer | not null default 0
parent_id | bigint |
What is it?
ddgc=# select distinct context from comment;
context
-----------------------------------
DDGC::DB::Result::Thread
DDGC::DB::Result::User::Blog
DDGC::DB::Result::Idea
DDGC::DB::Result::Token::Language
(4 rows)
If you look at The forum page, specifically the "Latest comments on ..." section, these contexts match the models for the various entities the site has commenting available on (apart from Instant answers which has its own controller as discussed in Abandoned Approach
So, rather than extending the thread model with forums and having to perform work on the controller and all links pointing to forums (including support for legacy links), how much is involved in creating new contexts for use by threads/comments, including ACLs for levels like community leader, admin and so on?
In theory, this should hide new comments by "ghost" users.
Forum IDs are kind of half-formed, may require too much work to be worth what they bring.
The "Instant Answers" and "General Ramblings" forum are separate controllers entirely which might be fair enough, since they have differing behaviour (mainly votes, status ("Needs a Developer"...) look & feel).
If we want to create new forums for Different user Roles, what's in place?
ddgc=# \d thread
Table "public.thread"
Column | Type | Modifiers
------------+--------------------------+-----------------------------------------------------
id | integer | not null default nextval('thread_id_seq'::regclass)
users_id | bigint | not null
forum | integer | not null default 1
comment_id | bigint |
key | text | not null
title | text | not null
data | text |
sticky | integer | not null default 0
readonly | integer | not null default 0
done | integer | not null default 0
deleted | integer | not null default 0
created | timestamp with time zone | not null
updated | timestamp with time zone | not null
ghosted | integer | not null default 1
checked | bigint |
seen_live | integer | not null default 0
old_url | text |
Looks like forum
might tell us where a thread belongs. Since there's only one forum, we get exactly what we might expect from the following query:
ddgc=# select distinct forum from thread;
forum
-------
1
(1 row)
Forum 1, where's that defined? lib/DDGC/DB/Result/Thread.pm
:
sub forums {
my ( $self ) = @_;
{
'1' => {
name => 'General Rambling',
},
'2' => {
name => 'Forum Manager Forum',
user_filter => sub { $_[1]->is('forum_manager') },
},
'3' => {
name => 'Translation Manager Forum',
user_filter => sub { $_[1]->is('translation_manager') },
},
}
}
The General Rambling forum, as we expect. Except this data is not tied to forum or link generation. Links in templates/forum/nav.tx
:
<: my $general_name = "General Ramblings" :>
<: my $ideas_name = "Instant Answers" :>
<: if $current_page { :>
<span class="button-group button-group--nav">
<: if $current_page == 'general' { :>
<span class="button disabled button-nav-current"><: $general_name :></span>
<: } else { :>
<a href="<: $u('Forum','index') :>" class="button"><: $general_name :></a>
<: } if $current_page == 'ideas' { :>
<span class="button disabled button-nav-current"><: $ideas_name :></span>
<: } else { :>
<a href="<: $u('Ideas','index') :>" class="button"><: $ideas_name :></a>
<: } :>
</span>
<: } else { :>
Links to (our currently only) Forum and Instant Answers, pretty much hard-coded.
So, we need to tie this nav link generation with the forums defined in the Thread
model and the user roles (i.e. only link to forums the current role has permission to read).
We need to generate these forum pages (keep the forum routes intact? '/forum' = general, '/forum/community' = community manager, '/forum/admin' = admin? Cool URIs don't change and all that), using a forum type from thread and user access levels.
There's mention of forum_index
in places, though not in any way which leads to new forums being made available. In templates/i/comment_rs/forum.tx
:
<: if $forum_index { :>
<: include "forum/nav.tx" { current_page => 'general' } :>
<: } else { :>
<: include "forum/nav.tx" { current_page => 'other' } :>
<: } :>
Which is stashed in the context in lib/DDGC/Web/Controller/Forum.pm
:
sub index : Chained('userbase') PathPart('') Args(0) {
my ( $self, $c ) = @_;
$c->bc_index;
$self->set_grouped_comments($c,'index',$c->d->forum->comments_grouped_threads);
$c->stash->{forum_index} = 1;
}