Code Monkey home page Code Monkey logo

silverstripe-hackernews's Introduction

Silverstripe HackerNews - A Tech News Slider

News scrolling banner (animated) for Silverstripe CMS. The extension can automatically fetch tech news/posts by using Y Combinator's Hacker News API.

Working demo on iloveunix.com at site's footer.

Requirements

Installation

Composer

composer require minimalic/silverstripe-hackernews

Rebuild DB

Rebuild DB by appending dev/build?flush=all to your website's URL or by using shell:

vendor/bin/sake dev/build "flush=all"

Fetch Hacker News

Fetch first news by appending dev/tasks/FetchHackerNewsTask to your website's URL or by using shell (from website's root directory):

vendor/bin/sake dev/tasks/FetchHackerNewsTask

or (if sake is not available):

php vendor/silverstripe/framework/cli-script.php dev/tasks/FetchHackerNewsTask

Bootstrap extension (optional)

Bootstrap (CSS library) isn't required, but this extension is using Bootstrap's markups for templating. Own Bootstrap implementation can be used as well as extensions like silverstripe-bootloader:

composer require minimalic/silverstripe-bootloader

Usage

Simply put $HackerNews inside your template, for example Footer.ss:

<div class="container-fluid g-0 f-hacker-news">
    $HackerNews
</div>

Configuration

Configuration options (e.g. app/_config/hackernews.yml):

minimalic\HackerNews\Tasks\FetchHackerNewsTask:
  posts_to_load: 40
  email_message_enable: true
  email_message_nightly: true
  email_message_from:
    [email protected]: 'Server Name'
  email_message_to:
    [email protected]: 'My Name'

minimalic\HackerNews\HackerNewsBanner:
  banner_speed: 60

Automatic daily news fetch

Set up cronjob (shell, as web user):

crontab -e

To fetch news every 6 hours starting at 0:42 local server time type in:

42 */6 * * * ~/mywebsite/vendor/bin/sake dev/tasks/FetchHackerNewsTask

(the ~/mywebsite/ is a relative path from your web user starting point - you can also use an absolute path like /var/www/mywebsite/)

Contribution

To compile SCSS to CSS install sass, nodemon and postcss by using npm and run (developing only, shell):

cd vendor/minimalic/silverstripe-hackernews/client/src/
npm run-script watch

License

See License

Copyright (c) 2024, minimalic.com - Sebastian Finke All rights reserved.

silverstripe-hackernews's People

Contributors

minimalic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.