Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
RFC: time-frame story tagging New Code
By sleeper22 , Section Wishlist []
Posted on Wed Aug 28, 2002 at 12:00:00 PM PST
My immediate motivation: a "Book of the month" box

I'd like to add time-frame assignment to stories -- ie each story can optionally have date values for fields that i'll call feature_start and feature_end.

When a story has values for one or both of these fields, and the current time is in that timeframe, then we can say that the story is currently featured.

One use would be a box called features that takes a section name and displays summaries for the currently featured stories in that section. E.g. A section entitled "Jean's Wine of the Week" might have a a few featured stories at any one time, although authorized users could submit future stories before they become current.

The preferred sort order of featured stories should be feature_start DESC, time DESC (the latter being the time of posting).

The story-listing function for the section OP should be changed to allow this sort order. This could be triggered possibly by a property of the sections, and/or by a cgi param like "sort=feature_start"

When using featured stories, the story summary should probably be customized for featured stories, so that it indicates the dates of the time period.

Further, there could be a Var to "hide featured stories while they are out of date" which would make the search and section OPs skip these stories. This could even be specified on a per-story level on the submit/edit story page, but that may be overdoing it!

here's proposed logic for testing whether a story is currently featured:

$feature_start	|| $feature_end and
!$feature_start || $now >= $feature_start and 
!$feature_end	|| $now lt;= $feature_end

So i propose to change

  1. submit story page: to include a line "Featured during [pulldown boxes: M D Y - M D Y]"
  2. alter the stories table to add fields feature_start(date), feature_end(date)
  3. section op: to support different sort order, and skip outdated stories if desired
  4. search op: to likewise skip these stories
< 0.9 upgrade (possible issue) | scoop licensing? >

Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Login
Make a new account
Username:
Password:

Related Links
· More on New Code
· Also by sleeper22

Story Views
  18 Scoop users have viewed this story.

Display: Sort:
RFC: time-frame story tagging | 2 comments (2 topical, 0 hidden)
ok i've implemented this (none / 0) (#1)
by sleeper22 on Fri Sep 06, 2002 at 05:42:14 AM PST

This feature i described above now works. I have a box that displayes currently featured stories from one or more sections. These sections, such as "Terri's book of the month" are most useful when they autopost and are restricted to a particular group.

I first had to add two fields of type "date" to the stories table.

There's also a new perm "features_stories".
So you only see the input boxes on the submitstory page when you have this perm.

if anyone wants to see the boxes i made just ask.

And here's the diff with the current cvs Admin/AdminStories.pm

--- AdminStories.orig    Tue Sep  3 20:53:47 2002
+++ AdminStories.features    Tue Sep  3 20:55:29 2002
@@ -480,6 +480,17 @@
     my $section = $S->{DBH}->quote($params{section});
     my $q_sid = $S->{DBH}->quote($sid);

+
+    my ($feature_start,$feature_end);
+    if ($params{feature} && $S->have_perm('feature_stories')) {
+        $feature_start = $S->{DBH}->quote("$params{starty}-$params{startm}-$params{startd}");
+        $feature_end   = $S->{DBH}->quote("$params{endy}-$params{endm}-$params{endd}");
+        warn "featured story during $feature_start - $feature_end" if $DEBUG;
+    } else {
+        $feature_start = $feature_end = 'NULL';
+    }
+
+
     my $time = $params{time};
     if ($params{timeupdate} eq 'now' || $time eq '') {
             $time = $currtime;
@@ -499,7 +510,9 @@
              writestatus=$params{writestatus},
              section=$section,
              displaystatus=$params{displaystatus},
-             commentstatus=$params{commentstatus}|,
+             commentstatus=$params{commentstatus},
+             feature_start=$feature_start,
+             feature_end=$feature_end|,
             WHERE => qq|sid = $q_sid|});

         $S->run_hook('story_update', $sid);
@@ -524,8 +537,8 @@
         ($rv, $sth) = $S->db_insert({
             DEBUG => 0,
             INTO => 'stories',
-            COLS => 'sid, tid, aid, title, dept, time, introtext, bodytext, writestatus, section, displaystatus, commentstatus',
-            VALUES => qq|"$sid", "$params{tid}", "$params{aid}", $title, $dept, "$time", $introtext, $bodytext, $params{writestatus}, $section, $params{displaystatus}, $params{commentstatus}|});
+            COLS => 'sid, tid, aid, title, dept, time, introtext, bodytext, writestatus, section, displaystatus, commentstatus, feature_start, feature_end',
+            VALUES => qq|"$sid", "$params{tid}", "$params{aid}", $title, $dept, "$time", $introtext, $bodytext, $params{writestatus}, $section, $params{displaystatus}, $params{commentstatus}, $feature_start, $feature_end|});

         $S->run_hook('story_new', $sid);
     }
@@ -668,6 +681,11 @@
     $story_data->{title} = $S->comment_text($story_data->{title});
     $story_data->{title} =~ s/"/&quot;/g;

+
+    if ( $S->have_perm('feature_stories') ) {
+                $content .= '<TR><TD>&#37;&#37;norm_font&#37;&#37;' . $S->feature_inputs($story_data) . '&#37;&#37;norm_font_end&#37;&#37;</TD></TR>';
+        }
+
     $content .= qq|
         <TR>
             <TD>&#37;&#37;norm_font&#37;&#37;
@@ -1799,4 +1817,84 @@
     return 1;
 }

+sub datepart_select {
+    my ($S,$name,$unit,$default) = @_;
+    my ($first,$last,@label);
+    my $content = '';
+    
+    if ($unit eq 'month') {
+    $first = 1;
+    $last = 12;
+    if ($S->{UI}->{BLOCKS}->{months_label}) {
+        @label = split(/,?\s*\n/, $S->{UI}->{BLOCKS}->{months_label});
+    } else {
+        @label = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
+    }
+  
+    } elsif ($unit eq 'day') {
+    $first = 1;
+    $last = 31;
+
+    } elsif ($unit eq 'year') {
+      ## how many years ahead to offer
+    $first = '2000';
+    $last  = $default? $default + 3 : $first;
+
+    } else {
+    warn "Invalid args to datepart_select function" if $DEBUG;
+    return;
+    }
+
+    foreach my $num ($first..$last) { ## each day, month, or year
+    my $label = @label? $label[$num-1] : $num;
+    $content .= qq|<option value="$num"|;
+    $content .= ' selected="selected"' if ($num == $default);
+    $content .= qq|>$label</option>|;
+    }
+    return qq|<select name="$name" size="1">$content</select>|;
+}
+
+
+sub feature_inputs {
+    ## make a checkbox and selects to control start and end dates
+    my ($S,$story_data) = @_;
+    my $c;
+
+    ## default to today...
+
+    my ($d_now,$m_now,$y_now) = (localtime)[3,4,5];
+    $m_now ++;
+    $y_now += 1900;
+
+    foreach (qw(start end)) {
+    ## split each date field into 3 parts
+    if ($story_data->{"feature_$_"} =~ /^(\d\d\d\d)\-(\d\d)\-(\d\d)$/) {
+        my ($y,$m,$d) = ($1,$2,$3);
+        ( $story_data->{"${_}y"} = $y ) =~ s/^0//;
+        ( $story_data->{"${_}m"} = $m ) =~ s/^0//;
+        ( $story_data->{"${_}d"} = $d ) =~ s/^0//;
+    }
+    }
+
+    my $checked = $story_data->{feature}? 'checked="checked"' : '';
+
+    $c .= qq|<input type="checkbox" name="feature" value="1"$checked />
+    Feature story from |;
+       
+    $c .= $S->datepart_select('startm','month',
+                  $story_data->{startm}||$m_now).' ';
+    $c .= $S->datepart_select('startd','day',  
+                  $story_data->{startd}||$d_now).' ';
+    $c .= $S->datepart_select('starty','year',  
+                  $story_data->{starty}||$y_now);
+    $c .= ' to ';
+    $c .= $S->datepart_select('endm',  'month',
+                  $story_data->{endm}  ||$m_now).' ';
+    $c .= $S->datepart_select('endd',  'day',  
+                  $story_data->{endd}  ||$d_now).' ';
+    $c .= $S->datepart_select('endy',  'year',  
+                  $story_data->{endy}  ||$y_now);
+    return $c;
+}
+
 1;
--
babelguides.com <<world literature in translation>>



edu (none / 0) (#2)
by Murray on Wed Jan 20, 2016 at 02:26:13 AM PST

Time frame tagging and assignments or stories are always very important and necessary for all the people. The professional essay help can be very important and necessary for all the people. They can earn a lot of important things from the people.



RFC: time-frame story tagging | 2 comments (2 topical, 0 hidden)
Display: Sort:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search