As was foretold, we've added advertisements to the forums! If you have questions, or if you encounter any bugs, please visit this thread: https://forums.penny-arcade.com/discussion/240191/forum-advertisement-faq-and-reports-thread/
Options

PHP News systems... I.e. PA's.

MichichaelMichichael Registered User regular
edited September 2008 in Help / Advice Forum
Ok... I've been banging my head against the wall trying to figure this out because I am not a php guru at all. I do active directory scripting, not php and haven't had the time to learn it.. I just want a straight answer.

Is there a php news archive solution available to the general public like what is used on Penny Arcade and other webcomics? And if so.... what is it!

The only thing I keep hearing is wordpress, but that's a full blog thing that replaces your website. I've already designed what I want my website to look like and blue boxes isn't in the equation.

All I want is some php script that I plug into my website, and it pulls the data from a database, which has a browsable archive, keeps pasts posts, allows me to make a news post, etc.

Adding comments etc... yeah that's all optional. I just want a news system that works, and I'm not asking the right questions of the Oracle (google).

Any ideas, or suggestions? Thanks.

-Michichael Folf-sunè
Michichael on

Posts

  • Options
    wasted pixelswasted pixels Registered User regular
    edited September 2008
    There are a couple of scripts like that, I guess. Thank me later. ;)

    (And ignore the link to PHP-Nuke, I have no idea how that could be mistaken for a news system. Or a CMS. Or useful.)

    wasted pixels on
  • Options
    MichichaelMichichael Registered User regular
    edited September 2008
    Thank, I'll poke around it. Dunno how that didn't show up in my searches...

    Michichael on
    -Michichael Folf-sunè
  • Options
    powersspowerss Registered User regular
    edited September 2008
    Back in the day, before good content management systems, I used something called Newspro.

    It should do what you want.

    powerss on
  • Options
    wasted pixelswasted pixels Registered User regular
    edited September 2008
    Oh man, NewsPro, that brings back some memories, man. It looks exactly the same as I remember it back in the day. Remember when finding a host that actually supported CGI was every webmaster's biggest challenge? Then once you found one, of course you got banned for running three instances of UBB. Good times.

    Anyway, NewsPro is A) flat-file based (poor performance), B) Perl-based (not compatible with many modern hosts), and C) seven years out from the latest update (very old). But man, what an awesome script for its time.

    wasted pixels on
  • Options
    LegionnairedLegionnaired Registered User regular
    edited September 2008
    The new PA site is actually running Ruby on Rails with memcached, just FYI.

    There was a podcast about it in the rails world a little while back.

    Building a comic site like PA would take about 15 minutes in rails. I should do a tutorial, break away from this endless string of blog tutorials...

    Sorry, I know that's tangental to your question, but you asked about PA, so....

    Legionnaired on
  • Options
    MichichaelMichichael Registered User regular
    edited September 2008
    The new PA site is actually running Ruby on Rails with memcached, just FYI.

    There was a podcast about it in the rails world a little while back.

    Building a comic site like PA would take about 15 minutes in rails. I should do a tutorial, break away from this endless string of blog tutorials...

    Sorry, I know that's tangental to your question, but you asked about PA, so....

    Really? I've poked around a bit of Ruby since the latest penetration testing framework we use has an interface built on it, but haven't taken a look at actual web design around it. My current website is all PHP, since it was the easiest thing I could pull outta my ass but it's only use of PHP is to pull rss feeds from livejournal.

    Michichael on
    -Michichael Folf-sunè
  • Options
    LegionnairedLegionnaired Registered User regular
    edited September 2008
    Michichael wrote: »
    The new PA site is actually running Ruby on Rails with memcached, just FYI.

    There was a podcast about it in the rails world a little while back.

    Building a comic site like PA would take about 15 minutes in rails. I should do a tutorial, break away from this endless string of blog tutorials...

    Sorry, I know that's tangental to your question, but you asked about PA, so....

    Really? I've poked around a bit of Ruby since the latest penetration testing framework we use has an interface built on it, but haven't taken a look at actual web design around it. My current website is all PHP, since it was the easiest thing I could pull outta my ass but it's only use of PHP is to pull rss feeds from livejournal.

    Metasploit? Cool.

    Yeah, Rails rocks.

    The News Post
    Along with the slick new visuals the guts of the site also got a huge upgrade. Penny Arcade right now represents one of the largest implementations of "rails" on the intertron. I went and looked at a website about rails and then I got a headache. From what I gathered it’s either some kind of cutting edge programming language, or a way to liquefy a man’s brain inside his skull. I'm told that it means the site looks better and loads faster regardless of whatever hippy web browser you decide to use. Fuck M$!

    Basically though, for serving mostly static content its probably not the best tool for the job. What you CAN do, however, is get a decent CMS and then use rails for all of the fun dynamic bits. Radiant interfaces well with Rails, so I've been told, but I've never actually used it. I'm going to need to.

    Basically, here's all you'd do to get a webcomic app going in Rails...
    rails my_webcomic -d mysql
    cd my_webcomic
    # Which sets up a project called my_webcomic, using a mysql adapter
    vim config/database.yml
    # Opens up the database configuration. Set that up.
    script/generate scaffold Post author_id:integer title:string body:text
    # Download the restful authentication plugin...
    script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
    script/generate authenticated Author Session
    # Which will give you an authenticated Author framework
    rm public/index.html
    # Because we don't want our visitors to see the welcome to rails page.
    

    Add the following line to webcomic/app/models/author.rb:
    has_many :posts
    

    Add the following line to webcomic/app/models/post.rb
    belongs_to :author
    

    Add the following line to webcomic/app/controllers/posts_controller.rb:
    before_filter :authorized?, :except => :index
    

    And then modify the authenticated? method in lib/authenticated_system.rb:
    def authenticated?
      ["list", "of", "authorized", "logins"].include? current_author.login
    end
    

    You've just made what is effectively a blog where only logged in and authorized users can CRUD news posts. In what, 10 lines?

    You're going to want the author to be linked automagically to their new posts, so add this to app/views/posts/new.html.erb (erb stands for embedded ruby - there are other better templating languages out there beyond the scope of this post):
    # above f.submit create, add the following line:
    
    
        <&#37;= f.hidden_field :author_id, current_author.id%>
    

    Now, posts will automatically be tied to their user when they are made. And, so that others can see who wrote it, in app/views/posts/index.html.erb, change:
    h post.author_id
    

    to:
    <img src='#{post.author.avatar_url}'/> + post.author.login
    

    Also, make it not a table based layout, because we're not in the 90's anymore. Thanks for sucky scaffolding, Rails.

    You're also going to want a 'comic' model, but that deals with uploading, and it's 2 AM here so I'm beat. Protip: uploading is cake.

    You'll also want to modify the @posts = query in app/controllers/posts_controller.rb's index method to be something like:
    recent_comics = Comic.all(
          :order_by => "created_on DESC",
          :limit => 2
        )
    @posts = Post.find(:all, 
      :conditions => ["created_on > ?", 
         recent_comics[1].created_on
       ]
    )
    @posts = Post.find(:all, 
      :conditions => ["created_on > ?", 
         recent_comics[0].created_on
       ]
    ) if @posts.empty?
    

    I leave it as an exercise to the reader to figure out exactly what that does, but as a hint, it'll work exactly the same as PA's front site does.
    It will always display news, and if there is news since the last comic it'll only display the news since the last comic. Cool, huh?

    From here, the only thing you have to do is style your views to get the desired look, and then lock down new account creation once you have all of your authors covered so you don't end up getting spammed or DoSed with new authorship requests... After, of course, you set up uploading for author avatars and comics, neither of which should be hard.

    But that's basically the entire inner workings of the site in 20 minutes and maybe 20 lines of code... I'm going to bed.

    OH, and 3 queries per page load (2 for the news posts and 1 for the inevitable comic view) sounds like a lot, but running memcached properly means that all of that data will be in memory all the time, so your app will howl like a banshee from the maw of hell. Bonus points running Ruby Enterprise Edition, which trims some of the fat off of the traditional ruby interpreter.

    Legionnaired on
  • Options
    RohaqRohaq UKRegistered User regular
    edited September 2008
    I'm still a fan of Wordpress: Yes, it's a full system with its own themes, but you can write your own themes, and it's ten times easier to write a custom theme based on your current design than it is to try and insert a premade system into your current site without breaking shit. Plus you have the added support of continuous security updates and function expansion via plugins.

    Plus you can then use the Comicpress plugin to organise your comic navigation and archiving.

    Rohaq on
  • Options
    MichichaelMichichael Registered User regular
    edited September 2008
    Legion - Wow, that's a great deal of coding. Very impressive.

    Unfortunately I spent all of last night getting phpnews working >.<!

    It actually doesn't look half bad. Had some help using javascript to round off corners of the text floats. =)

    Michichael on
    -Michichael Folf-sunè
Sign In or Register to comment.