Skip to content

Commit

Permalink
Add rss_max_items_outgoing var for a sitewide default of the maximum
Browse files Browse the repository at this point in the history
number of items (stories, etc.) written into an RSS/Atom/etc. feed.
Fix misnamed variables in open_backend.pl.  And rename a poorly named
var too.
  • Loading branch information
jamiemccarthy committed Nov 16, 2005
1 parent 6038e56 commit 2b59b37
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
3 changes: 2 additions & 1 deletion Slash/DB/Static/MySQL/MySQL.pm
Expand Up @@ -79,6 +79,7 @@ sub showQueryCount {
sub getBackendStories {
my($self, $options) = @_;

my $limit = $options->{limit} || 10;
my $topic = $options->{topic} || getCurrentStatic('mainpage_nexus_tid');

my $select = "stories.stoid AS stoid, sid, title, stories.tid AS tid, primaryskid, time,
Expand All @@ -91,7 +92,7 @@ sub getBackendStories {
AND stories.stoid = story_topics_rendered.stoid
AND story_topics_rendered.tid=$topic";

my $other = "ORDER BY time DESC LIMIT 10";
my $other = "ORDER BY time DESC LIMIT $limit";

my $returnable = $self->sqlSelectAllHashrefArray($select, $from, $where, $other);

Expand Down
2 changes: 1 addition & 1 deletion plugins/Admin/admin.pl
Expand Up @@ -667,7 +667,7 @@ sub blockEdit {
$blockform_flag = 1 if ((! $form->{blockdelete_confirm} && $bid) || $form->{blocknew});

my $title = getTitle('blockEdit-title', { bid => $bid }, 1);
$blockref->{items} ||= $constants->{max_items};
$blockref->{items} ||= $constants->{rss_max_items_incoming};

slashDisplay('blockEdit', {
bid => $bid,
Expand Down
4 changes: 2 additions & 2 deletions sbin/portald
Expand Up @@ -144,13 +144,13 @@ sub setblock {

#################################################################
sub getRDF {
#gets an RDF file, and formats it as a /. block
#gets an RDF file, and formats it as a Slash block

my($bid, $url, $other) = @_;
my $rss = new XML::RSS;
my $template_name = $slashdb->getBlock($bid, 'rss_template');
my $items ||= $slashdb->getBlock($bid, 'items');
$items ||= $constants->{max_items};
$items ||= $constants->{rss_max_items_incoming};
$template_name ||= $constants->{default_rss_template};

my $d;
Expand Down
5 changes: 3 additions & 2 deletions sql/mysql/defaults.sql
Expand Up @@ -929,7 +929,6 @@ INSERT INTO vars (name, value, description) VALUES ('max_discussions_allowed','3
INSERT INTO vars (name, value, description) VALUES ('max_discussions_unusedfk','10','How many unused formkeys are permitted');
INSERT INTO vars (name, value, description) VALUES ('max_expiry_comm','250','Largest value for comment expiry trigger.');
INSERT INTO vars (name, value, description) VALUES ('max_expiry_days','365','Largest value for duration expiry trigger.');
INSERT INTO vars (name, value, description) VALUES ('max_items','15','max number of rss items by default');
INSERT INTO vars (name, value, description) VALUES ('max_login_allowed', '10', 'How many forms a user can submit');
INSERT INTO vars (name, value, description) VALUES ('max_submission_size','32000','max size of submission before warning message is displayed');
INSERT INTO vars (name, value, description) VALUES ('max_submissions_allowed','20','maximum number of submissions per timeframe allowed');
Expand Down Expand Up @@ -997,7 +996,9 @@ INSERT INTO vars (name, value, description) VALUES ('returnto_passwd',CONCAT('ch
INSERT INTO vars (name, value, description) VALUES ('rootdir','//www.example.com','Base URL of site; used for creating on-site links that need protocol-inspecific URL (so site can be used via HTTP and HTTPS at the same time)');
INSERT INTO vars (name, value, description) VALUES ('rss_allow_index', '0', 'Allow RSS feeds to be served from index.pl (1 = admins, 2 = subscribers, 3 = all logged-in users)');
INSERT INTO vars (name, value, description) VALUES ('rss_expire_days','7','Number of days till we blank the data from the database (the signatures still stick around though)');
INSERT INTO vars (name, value, description) VALUES ('rss_store','0','Should we be saving incomming submissions for rss');
INSERT INTO vars (name, value, description) VALUES ('rss_max_items_incoming','15','Max number of rss items shown in a slashbox, by default');
INSERT INTO vars (name, value, description) VALUES ('rss_max_items_outgoing','15','Max number of rss items emitted in an rss/rdf/atom feed');
INSERT INTO vars (name, value, description) VALUES ('rss_store','0','Should we be saving incoming submissions for rss');
INSERT INTO vars (name, value, description) VALUES ('run_ads','0','Should we be running ads?');
INSERT INTO vars (name, value, description) VALUES ('runtask_verbosity','3','How much information runtask should write to slashd.log: 0-3 or empty string to use slashd_verbosity');
INSERT INTO vars (name, value, description) VALUES ('sbindir','/usr/local/slash/sbin','Where are the sbin scripts kept');
Expand Down
5 changes: 5 additions & 0 deletions sql/mysql/upgrades
Expand Up @@ -3477,3 +3477,8 @@ UPDATE vars SET value = 'T_2_5_0_88' WHERE name = 'cvs_tag_currentcode';

# SLASHDOT LAST UPDATED HERE

UPDATE vars SET description='Should we be saving incoming submissions for rss' WHERE name='rss_store';
UPDATE vars SET name='rss_max_items_incoming', description='Max number of rss items shown in a slashbox, by default' WHERE name='max_items';
INSERT INTO vars (name, value, description) VALUES ('rss_max_items_outgoing','10','Max number of rss items emitted in an
rss/rdf/atom feed');

15 changes: 8 additions & 7 deletions themes/slashcode/tasks/open_backend.pl
Expand Up @@ -17,9 +17,10 @@
$task{$me}{code} = sub {
my($virtual_user, $constants, $slashdb, $user, $info, $gSkin) = @_;

my $backupdb = getObject('Slash::DB', { db_type => 'reader' });
my $reader = getObject('Slash::DB', { db_type => 'reader' });
my $max_items = $constants->{rss_max_items_outgoing} || 10;

my $stories = $backupdb->getBackendStories;
my $stories = $reader->getBackendStories({ limit => $max_items });
if ($stories && @$stories) {
newxml(@_, undef, $stories);
newrdf(@_, undef, $stories);
Expand All @@ -31,7 +32,7 @@
for my $skid (keys %$skins) {
my $name = $skins->{$skid}{name};
my $nexus = $skins->{$skid}{nexus};
$stories = $backupdb->getBackendStories({ topic => $nexus });
$stories = $reader->getBackendStories({ limit => $max_items, topic => $nexus });
if ($stories && @$stories) {
newxml(@_, $name, $stories);
newrdf(@_, $name, $stories);
Expand All @@ -53,14 +54,14 @@ sub fudge {
}

sub _do_rss {
my($virtual_user, $constants, $backupdb, $user, $info, $gSkin,
my($virtual_user, $constants, $slashdb, $user, $info, $gSkin,
$name, $stories, $version, $type) = @_;

$type ||= 'rss';

my $file = sitename2filename($name);
my $skin = {};
$skin = $backupdb->getSkin($name) if $name;
$skin = $slashdb->getSkin($name) if $name;
my $link = ($skin->{url} || $gSkin->{absolutedir}) . '/';
my $title = $constants->{sitename};
$title = "$title: $skin->{title}" if $skin->{skid} != $constants->{mainpage_skid};
Expand Down Expand Up @@ -90,7 +91,7 @@ sub _do_rss {
sub newatom { _do_rss(@_, '1.0', 'atom') } # Atom 1.0

sub newxml {
my($virtual_user, $constants, $backupdb, $user, $info, $gSkin,
my($virtual_user, $constants, $slashdb, $user, $info, $gSkin,
$name, $stories) = @_;

my $x = <<EOT;
Expand All @@ -101,7 +102,7 @@ sub newxml {

for my $story (@$stories) {
my @str = (xmlencode($story->{title}), xmlencode($story->{dept}));
my $author = $backupdb->getAuthor($story->{uid}, 'nickname');
my $author = $slashdb->getAuthor($story->{uid}, 'nickname');
$x.= <<EOT;
<story>
<title>$str[0]</title>
Expand Down

0 comments on commit 2b59b37

Please sign in to comment.