AxKit-App-TABOO

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- Ensure no entities in Textile output
	- Can control where the article redirects to.
	  


0.32	2005-08-14 
	- Long time coming... Has been so many things to attend to...
	- Mainly about writing articles to DB.
	  * Numerous things with how files are written.
	  * store is replaced by store_required for now.
	  * Supports both upload and textarea entry.
	- Now works only behind a reverse proxy (will change).
	- Language data objects and XSP.
	- New SVN repository
	- Documentation cleanups and linewraps.
	- Plurals will check if limit is actually given.
	- 0.32 because it is released on my 32. birthday! :-)
	
	
0.21	2005-05-01 02:30
	- Eliminated the need for BasicAuth by setting credential_0 

htdocs/articles/submit.xsp  view on Meta::CPAN

      <lang:get-languages/>
      <ct:value><val:insert name="code"/></ct:value>
    </ct:control>
    <ct:control name="primcat">
      <ct:title><i18n:insert>primcat</i18n:insert></ct:title>
      <ct:descr><i18n:insert>primcat-descr</i18n:insert></ct:descr>
      <cat:get-categories type="categ"/>
      <ct:value><val:insert name="primcat"/></ct:value>
    </ct:control>
    <ct:control name="upfile" type="file" element="input">
      <ct:title><i18n:insert>article-file-upload</i18n:insert></ct:title>
      <ct:descr><i18n:insert>article-file-upload-descr</i18n:insert></ct:descr>
      <ct:value><val:insert name="upfile"/></ct:value>
    </ct:control>
    <ct:control name="filename" type="text" element="input" maxlength="30">
      <ct:title><i18n:insert>article-filename</i18n:insert></ct:title>
      <ct:descr><i18n:insert>article-filename-descr</i18n:insert></ct:descr>
      <ct:value><val:insert name="filename"/></ct:value>
    </ct:control>
    <ct:control name="text" element="textarea" rows="22" cols="60">
      <ct:title><i18n:insert>article-textstring</i18n:insert></ct:title>
      <ct:descr>

htdocs/i18n.en.xml  view on Meta::CPAN

  <text id="submit-story-menu"> Submit Story </text>
  <text id="submit-article-menu"> Submit article </text>
  <text id="article-descr"> The title of the article </text>
  <text id="article-title"> Title </text>
  <text id="comment-descr"> A title for the comment </text>
  <text id="comment-title"> Title </text>

  <text id="article-description-descr"> A description of the contents of the article. This description will usually occur outside of context and must therefore give meaning only along with the title. Max 254 characters. </text>
  <text id="article-description"> Description </text>

  <text id="article-file-upload-descr"> You may here upload a file to the server by using this field or write in a text and a short name underneath. </text>
  <text id="article-file-upload"> File upload </text>
  <text id="article-filename-descr"> Even if you do not upload a file you will still have to give a name for the article. This will be used in the address etc and must be only lowercase letters and numbers and no spaces. You may concatenate several w...
+  <text id="article-filename"> Article name </text>
+  <text id="article-textstring-descr"> The text of the article itself. </text>
+  <text id="article-textstring"> Article text </text>

  <text id="comment"> comment </text>
  <text id="comments"> Comments </text>
  <text id="comments-verb"> comments </text>
  <text id="you-respond-to"> You respond to this comment: </text>
  <text id="reply-to-this"> Reply to this </text>
  <text id="thread-below"> Thread below </text>

htdocs/i18n.en.xml  view on Meta::CPAN

  <text id="new-password"> New Password </text>
  <text id="register"> Register </text>

  <text id="suggested-user-exists"> User name is allready in use or is invalid! </text>
  <text id="suggested-user-stored"> User information was successfully stored! </text>

  <text id="suggested-cat-exists"> The category name is allready in use! </text>
  <text id="suggested-cat-stored"> Category information was stored! </text>
  <text id="problem-occured"> Problems occured </text>
  <text id="unknown-problem"> A problem with unknown cause </text>
  <text id="either-upload-or-filename"> You must either upload a file, or write a short name and the article text in the text field.</text>
  <text id="nosave-problem"> The articles was not saved as expected. You may try with a different name or contact webmaster</text>



  <text id="listing-everything"> Listing all stories </text>
  <text id="list-noun"> list </text>
  <text id="overview"> Overview </text>
  <text id="article-no-comments"> Article without comments </text>
  <text id="edit"> Edit </text>
  <text id="send"> Send </text>

htdocs/i18n.nb.xml  view on Meta::CPAN

  <text id="comment-stored"> Kommentar lagret og lagt til </text>
  <text id="submit-story-menu"> Send inn sak </text>
  <text id="submit-article-menu"> Send inn artikkel </text>
  <text id="article-descr"> Overskriften til artikkelen </text>
  <text id="article-title"> Tittel </text>
  <text id="comment-descr"> Overskriften til kommentaren </text>
  <text id="comment-title"> Tittel </text>
  <text id="article-description-descr"> En beskrivelse av innholdet i artikkelen. Denne beskrivelsen vil gjerne opptre utenfor kontekst, og må derfor gi mening kun sammen med tittelen. Maks 254 tegn. </text>
  <text id="article-description"> Beskrivelse </text>

  <text id="article-file-upload-descr"> Du kan enten sende en fil til serveren ved å bruke dette feltet, eller skrive inn tekst og et kort navn under. </text>
  <text id="article-file-upload"> Opplasting av fil </text>
  <text id="article-filename-descr"> Hvis du ikke laster opp en fil må du likevel gi et navn for artikkelen som vil brukes i blant annet adressen, og skal være bare små bokstaver og tall men ingen mellomrom. Den kan være sammensatt av flere ord. ...
  <text id="article-filename"> Saksnavn </text>
  <text id="article-textstring-descr"> Selve teksten til artikkelen kan skrives inn i feltet under. </text>
  <text id="article-textstring"> Artikkel-tekst </text>

  <text id="comment"> kommentar </text>
  <text id="comments"> Kommentarer </text>
  <text id="comments-verb"> kommenterer </text>
  <text id="you-respond-to"> Du svarer på denne kommentaren: </text>
  <text id="reply-to-this"> Svar på denne </text>

htdocs/i18n.nb.xml  view on Meta::CPAN

  <text id="new-password"> Nytt passord </text>
  <text id="register"> Registrer </text>

  <text id="suggested-user-exists"> Brukernavnet er allerede i bruk eller er ugyldig! </text>
  <text id="suggested-user-stored"> Brukerinformasjonen ble lagret! </text>

  <text id="suggested-cat-exists"> Kategorinavnet er allerede i bruk! </text>
  <text id="suggested-cat-stored"> Kategori-informasjonen ble lagret! </text>
  <text id="problem-occured"> Problemer oppsto </text>
  <text id="unknown-problem"> Et problem med ukjent årsak </text>
  <text id="either-upload-or-filename"> Du må enten gi et kort filnavn sammen med tekst i tekstfeltet eller laste opp en fil</text>
  <text id="nosave-problem"> Artikkelen ble ikke lagret som forventet. Du kan prøve å gi den et annen navn eller kontakte webmaster</text>


  <text id="listing-everything"> Lister opp alle saker </text>
  <text id="list-noun"> liste </text>
  <text id="overview"> Oversikt </text>
  <text id="article-no-comments"> Artikkel uten kommentarer </text>
  <text id="edit"> Rediger </text>
  <text id="send"> Send </text>
  <text id="search"> Søk </text>

htdocs/transforms/articles/xhtml/submit.xsl  view on Meta::CPAN

		      </xsl:when>
		      <xsl:when test=". = 'code'">
			<xsl:value-of select="i18n:include('language')"/>
			<xsl:value-of select="i18n:include('missing')"/>
		      </xsl:when>
		      <xsl:when test=". = 'text'">
			<xsl:value-of select="i18n:include('article-textstring')"/>
			<xsl:value-of select="i18n:include('missing')"/>
		      </xsl:when>
		      <xsl:when test=". = 'filename' or . = 'upfile'">
			<xsl:value-of select="i18n:include('either-upload-or-filename')"/>
			
		      </xsl:when>
		      <xsl:when test=". = 'nosave'">
			<xsl:value-of select="i18n:include('nosave-problem')"/>
		      </xsl:when>
		      <xsl:otherwise>
			<xsl:value-of select="i18n:include('unknown-problem')"/>
		      </xsl:otherwise>
		    </xsl:choose>
		    <xsl:text>.</xsl:text>

lib/AxKit/App/TABOO/XSP/Article.pm  view on Meta::CPAN

  my $file = shift;
  $file =~ tr#A-Za-z0-9+#_#cd; # Replace any non-base64 with underscores
  return substr($file, 0, 29); # Return the 30 first chars.
}

sub _write_file {
    my %args = @_;
    my $fh = new IO::File;
    my $filename = $args{filename};
    my $ext = $args{extension} || 'txt';
    if ($args{upload}) {
	($filename, $ext) = $args{upload}->filename =~ m/^(.*)\.(\w*)$/;
    }
    $filename = _sanatize_filename($filename);
    my $i = 0;
    while (-e $args{docroot} ."/articles/content/$args{primcat}/$filename/$filename.$ext") { # Append an incrementing number if the file exists
	$i++;
	if ($i == 1) {
	    $filename .= '-' . $i;
	} else {
	    $filename =~ s/-\d+$/-$i/;
	}

lib/AxKit/App/TABOO/XSP/Article.pm  view on Meta::CPAN

    my $lookupfile = $args{docroot} ."/articles/content/$args{primcat}/$filename/";
    my $dir;
    foreach my $name (split('/', $lookupfile)) { # Make sure all dirs exist
	$dir .= $name . '/';
	unless (-d $dir) {
	    mkdir ($dir, 0775) || die "Failed to create directory " . $dir;
	}
    }
    $lookupfile .= "$filename.$ext";
    if ($fh->open("> " . $lookupfile)) {
	if ($args{upload}) {
	    my $uploadedfh = $args{upload}->fh;
	    while (<$uploadedfh>) {
		print $fh $_;
	    }
	} else {
	    die "Error saving string to filename $filename.$ext" unless (($filename) && ($args{text}));
	    print $fh $args{text};
	}
	$fh->close;
    } else { die "Failed to open file at $lookupfile for writing"  }
    return $filename;
}

package AxKit::App::TABOO::XSP::Article::Handlers;

=head1 Tag Reference


=head2 C<E<lt>store-required/E<gt>>

This tag will check and store the data from the required fields. It
will check for either uploaded files, and the MIME types of that, or
take plain text and save it to a local file. It doesn't do many
security checks yet.

If the save was successful, it will redirect to C</articles/edit>, so
that the submitter can continue editing of non-required fields. To
control where it redirects to, you should supply an attribute or child
element C<redirect> containing the URL of the page to redirect to and
C<retval>, with the HTTP return value. The latter defaults to 302.

If something went wrong, the tag will return a nodelist

lib/AxKit/App/TABOO/XSP/Article.pm  view on Meta::CPAN

      foreach my $required (qw(text filename upfile)) {
	  unless ($cgi->param($required)) {
	      push(@errors, $required);
	  }
      }
  }

  unless (@errors) { # OK, so far, so good
      my %args = map { $_ => $cgi->param($_) } $cgi->param;
      
      my $upload = $cgi->upload;
      if ($upload->size > 0) {
	  $args{'filename'} = AxKit::App::TABOO::XSP::Article::_write_file(upload=>$upload, primcat => $args{'primcat'}, docroot=>$r->document_root);
	  $args{'mimetype'} = $upload->type;
      } else {
	  $args{'filename'} = AxKit::App::TABOO::XSP::Article::_write_file(filename=>$args{'filename'}, text=>$args{'text'}, primcat => $args{'primcat'}, docroot=>$r->document_root);
	  $args{'mimetype'} = 'text/plain';
      }
      # TODO: Security sanity checks.
      $args{'authorok'} = 1; # Is assumed for now
      unless ($args{'date'}) {
	  my $timestamp = localtime;
	  $args{'date'} = $timestamp->datetime;
      }

lib/AxKit/App/TABOO/XSP/Article.pm  view on Meta::CPAN

  } else { 
    AxKit::Debug(9, "Things that went wrong: " . join(' ', @errors));
  }
  @errors;
EOC
}

sub this_article : struct attribOrChild(primcat) {
  return << 'EOC'
  my %args = map { $_ => $cgi->param($_) } $cgi->param;
  my $upload =  $cgi->upload;

  my $lookupurl = AxKit::App::TABOO::XSP::Article::_write_file($upload, $attr_primcat, $r->document_root);
  $args{'format'} = $upload->type;
  # TODO: Security sanity checks.

  unless ($args{'date'}) {
      my $timestamp = localtime;
      $args{'date'} = $timestamp->datetime;
  }

  $args{'authorids'} = [$args{'authorid'}]; # Has to change to support more authors
  my $article = AxKit::App::TABOO::Data::Article->new();
  $article->populate(\%args);



( run in 1.846 second using v1.01-cache-2.11-cpan-b16cb0d3907 )