Initial Commit

This commit is contained in:
Nemo 2023-06-06 14:43:12 +05:30
commit b0430e51ff
14 changed files with 559 additions and 0 deletions

54
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,54 @@
# Based on https://github.com/actions/starter-workflows/blob/main/pages/jekyll.yml
name: publish
on:
push:
branches:
- main
schedule:
# 9th minute of every hour
- cron: '09 * * * *'
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Ruby
uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
with:
ruby-version: '3.0' # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Setup Pages
id: pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
# Outputs to the './_site' directory by default
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
env:
JEKYLL_ENV: production
- name: Upload artifact
# Automatically uploads an artifact from the './_site' directory by default
uses: actions/upload-pages-artifact@v1
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
vendor

25
404.html Normal file
View File

@ -0,0 +1,25 @@
---
permalink: /404.html
layout: default
---
<style type="text/css" media="screen">
.container {
margin: 10px auto;
max-width: 600px;
text-align: center;
}
h1 {
margin: 30px 0;
font-size: 4em;
line-height: 1;
letter-spacing: -1px;
}
</style>
<div class="container">
<h1>404</h1>
<p><strong>Page not found :(</strong></p>
<p>The requested page could not be found.</p>
</div>

35
Gemfile Normal file
View File

@ -0,0 +1,35 @@
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 4.3.2"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.5"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.12"
end
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
platforms :mingw, :x64_mingw, :mswin, :jruby do
gem "tzinfo", ">= 1", "< 3"
gem "tzinfo-data"
end
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :platforms => [:mingw, :x64_mingw, :mswin]
# Lock `http_parser.rb` gem to `v0.6.x` on JRuby builds since newer versions of the gem
# do not have a Java counterpart.
gem "http_parser.rb", "~> 0.6.0", :platforms => [:jruby]
gem "sanitize", "~> 6.0"

92
Gemfile.lock Normal file
View File

@ -0,0 +1,92 @@
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.4)
public_suffix (>= 2.0.2, < 6.0)
colorator (1.1.0)
concurrent-ruby (1.2.2)
crass (1.0.6)
em-websocket (0.5.3)
eventmachine (>= 0.12.9)
http_parser.rb (~> 0)
eventmachine (1.2.7)
ffi (1.15.5)
forwardable-extended (2.6.0)
google-protobuf (3.23.2-x86_64-linux)
http_parser.rb (0.8.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
jekyll (4.3.2)
addressable (~> 2.4)
colorator (~> 1.0)
em-websocket (~> 0.5)
i18n (~> 1.0)
jekyll-sass-converter (>= 2.0, < 4.0)
jekyll-watch (~> 2.0)
kramdown (~> 2.3, >= 2.3.1)
kramdown-parser-gfm (~> 1.0)
liquid (~> 4.0)
mercenary (>= 0.3.6, < 0.5)
pathutil (~> 0.9)
rouge (>= 3.0, < 5.0)
safe_yaml (~> 1.0)
terminal-table (>= 1.8, < 4.0)
webrick (~> 1.7)
jekyll-feed (0.17.0)
jekyll (>= 3.7, < 5.0)
jekyll-sass-converter (3.0.0)
sass-embedded (~> 1.54)
jekyll-seo-tag (2.8.0)
jekyll (>= 3.8, < 5.0)
jekyll-watch (2.2.1)
listen (~> 3.0)
kramdown (2.4.0)
rexml
kramdown-parser-gfm (1.1.0)
kramdown (~> 2.0)
liquid (4.0.4)
listen (3.8.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
mercenary (0.4.0)
minima (2.5.1)
jekyll (>= 3.5, < 5.0)
jekyll-feed (~> 0.9)
jekyll-seo-tag (~> 2.1)
nokogiri (1.15.2-x86_64-linux)
racc (~> 1.4)
pathutil (0.16.2)
forwardable-extended (~> 2.6)
public_suffix (5.0.1)
racc (1.6.2)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
rexml (3.2.5)
rouge (4.1.2)
safe_yaml (1.0.5)
sanitize (6.0.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
sass-embedded (1.62.1-x86_64-linux-gnu)
google-protobuf (~> 3.21)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
unicode-display_width (2.4.2)
webrick (1.8.1)
PLATFORMS
x86_64-linux
DEPENDENCIES
http_parser.rb (~> 0.6.0)
jekyll (~> 4.3.2)
jekyll-feed (~> 0.12)
minima (~> 2.5)
sanitize (~> 6.0)
tzinfo (>= 1, < 3)
tzinfo-data
wdm (~> 0.1.1)
BUNDLED WITH
2.4.12

27
_config.yml Normal file
View File

@ -0,0 +1,27 @@
title: "Beatroot News: Text-only"
description: >- # this means to ignore newlines until "baseurl:"
A plain-text version of Beatroot News.
baseurl: ""
url: "https://news.captnemo.in"
plugins:
- jekyll-feed
# Exclude from processing.
# The following items will not be processed, by default.
# Any item listed under the `exclude:` key here will be automatically added to
# the internal "default list".
#
# Excluded items can be processed by explicitly listing the directories or
# their entries' file path in the `include:` list.
#
# exclude:
# - .sass-cache/
# - .jekyll-cache/
# - gemfiles/
# - Gemfile
# - Gemfile.lock
# - node_modules/
# - vendor/bundle/
# - vendor/cache/
# - vendor/gems/
# - vendor/ruby/

101
_includes/header.html Normal file
View File

@ -0,0 +1,101 @@
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width">
<link id="favicon" rel="shortcut icon" type="image/png" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAASCAYAAABb0P4QAAAABHNCSVQICAgIfAhkiAAAAapJREFUOI2t0s9rz3EcB/DH67OvkcZMWmm+OZFSqw0HOVCuc3Bw4A9wWHJ2XLkoSjnsssIFuXFQSthlEYZWc2Bl8jN2wXfYbJ+Xg63W2GLfPa+v3o+e73qGOTlqx2p0pnJPiI4U28hWNBEovxEfiBcpn4QcWGFysNdwbdYIOGR74zqN+5NjRGfQGqKwSFImPmEoFWenNN25qP9H9NhXeedrd8qTIdYuhiyCfyFOtVlzumGLloPJmUK0LAWDECvJHTWTI5UQR7B+qdgctDnl4QK7QkS9ICLYWSQblwEDyYYCDcsIThQYXy4wxGhBXJ3ZVF35beTdolBewYf6MWOlvFFMaB5Ieb3ehrg5rXmg4anRqZ3aHqfcHbT5zwmlLHE/VY6fNzDWAIPe1zq0PQjlVlRR/Ms2U/7EvRDdfR49Z85knnj3sV31VmH6O9EeYvUiUAafyXOp8USfhyOztz9a9FC81lElDhR0YW+IVTNQDf3BndLUtU2GXvVQzn2/4Ld6KN7q6MIFYh1eBqcrJi71Gh7HX6dWWQh8o31ziG5yhLxdmr5cNfRsfqP5+QUUM5oqKKZNVAAAAABJRU5ErkJggg==">
<style>
body {
display: block;
padding: 0px 20px;
max-width: 550px;
margin: 0 auto;
font-family: -apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif;
}
.full-version-link {
margin-left: 15px;
}
.slug-line {
font-size: 1.1rem;
margin-bottom: 15px;
}
.hr-line {
position: relative;
height: 4px;
background: #660033;
}
.story-title {
line-height: 2rem;
font-size: 1.5rem;
margin: 0;
}
.topic-heading {
line-height: 2rem;
font-size: 1.5rem;
}
.topic-container>ul {
padding: 0;
line-height: 1.4rem;
}
.topic-container li {
display: block;
padding-bottom: 15px;
}
.topic-container {
margin-top: 20px;
}
.topic-list {
display: inline-block;
}
.topic-date {
margin: 20px 0;
font-style: italic;
}
.paragraphs-container {
line-height: 1.5rem;
}
.button:link,
.button:visited {
background-color: white;
color: black;
border: 2px solid black;
padding: 4px 8px;
text-align: center;
text-decoration: none;
display: inline-block;
}
.button:hover,
.button:active {
background-color: black;
color: white;
}
.lower-nav-container {
margin-top: 40px;
}
.lower-nav-container li {
margin-left: 0;
display: inline;
padding-right: 20px;
}
h6 {
text-transform: uppercase;
}
.details-content {
font-size: smaller;
border: 1px dashed;
border-radius: 3px;
}
</style>

21
_layouts/article.html Normal file
View File

@ -0,0 +1,21 @@
---
layout: default
---
<article>
<div class="story-container">
<p class="slug-line">
<a class="slug-link" href="/">Beatroot</a> &gt;
<a class="slug-link" href="/{{page.topics.first}}/">{{page.topics.first | capitalize}}</a>
</p>
<div class="story-head">
<h1 class="story-title">{{page.title}}</h1>
<p>{{page.sources | join: " "}}</p>
<p>{{page.date | date: "%A, %b, %e, %Y"}}</p>
</div>
<div class="hr-line"></div>
<div class="paragraphs-container">
{{content}}
</div>
</div>
</article>

44
_layouts/default.html Normal file
View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>{{page.title}}</title>
{% include header.html %}
</head>
<body>
<header>
<p>Text-Only
<a class="full-version-link button" href="https://apps.apple.com/in/app/beatroot-news/id1618735924">iOS</a>
<a class="full-version-link button" href="https://play.google.com/store/apps/details?id=com.beatrootnews.app">Android</a>
<a class="full-version-link button" href="https://app.beatrootnews.com/">Mobile Web</a>
</p>
</header>
<main>
{{content}}
</main>
<div class="hr-line"></div>
<nav>
<p>Topics</p>
<ul>
{% for topic in site.topics %}
<li class="topic-list"><a href="/{{ topic}}/">{{topic | capitalize}}</a> /</li>
{% endfor %}
</ul>
</nav>
<footer>
<nav class="lower-nav-container">
<li><a href="https://home.beatrootnews.com/contact">Contact Beatroot News</a></li>
<li><a href="https://home.beatrootnews.com/about">About Beatroot News</a></li>
<li><a href="https://home.beatrootnews.com/terms">Privacy policy and Terms</a></li>
<li><a href="/about/">About Text-Only Beatroot News</a></li>
</nav>
<p>&copy; Beatroot News</p>
</footer>
</body>
</html>

24
_layouts/topic.html Normal file
View File

@ -0,0 +1,24 @@
---
layout: default
---
<p class="slug-line">
<a class="slug-link" href="/">Beatroot</a> &gt; {{page.title | capitalize}}
</p>
<div class="topic-container">
<h1 class="topic-heading">{{page.title | capitalize}}</h1>
<div class="hr-line"></div>
<p class="topic-date">{{site.time | date: "%A, %b, %e, %Y"}}</p>
<ul>
{% for post in site.pages %}
{% if post.topics contains page.topic %}
<li>
<details>
<summary>{{post.title | trim}} <a class="topic-title" href="{{post.url}}">🔗</a>
{% if post.sources contains "PTI" %}<span title="Syndicated News">📡</span>{%endif%}
</summary>
<div class="details-content">{{post.content}}</div>
</li>
{%endif%}
{% endfor %}
</ul>
</div>

92
_plugins/fetch_posts.rb Normal file
View File

@ -0,0 +1,92 @@
# frozen_string_literal: true
require 'sanitize'
require 'uri'
require 'net/http'
require 'set'
require 'date'
class PageWithoutAFile < Jekyll::Page
def read_yaml(*)
@data ||= {}
end
end
class BeatrootNews < Jekyll::Generator
safe true
priority :high
SOURCE_URL = "https://beatrootnews.com/api.php/article?page%5Blimit%5D=60&sort=-publishing_date"
# Make a request to SOURCE_URL, and return the parsed JSON
def get_content
uri = URI.parse(SOURCE_URL)
response = Net::HTTP.get_response(uri)
JSON.parse(response.body)['data']
end
# Main plugin action, called by Jekyll-core
def generate(site)
@site = site
topics = Set.new
get_content.each do |article|
page = make_page(article['attributes']['modules'])
if page
site.pages << page
page['topics'].each { |t| topics.add(t) }
end
end
topics.each do |topic|
@site.pages << make_topic_page(topic)
end
site.config['topics'] = topics.to_a
end
private
def make_topic_page(topic)
PageWithoutAFile.new(@site, __dir__, topic, "index.html").tap do |file|
file.data.merge!(
'title' => topic.capitalize,
'layout' => 'topic',
'topic' => topic,
'permalink' => "/#{topic}/",
)
file.output
end
end
# Generates contents for a file
def timestamp(ts)
d = Time.at(ts.to_i).to_datetime
d.new_offset("+0530")
end
def make_page(article)
return nil if article['topic'].nil?
n = DateTime.new
now = DateTime.new(n.year, n.month, n.day, 23, 59, 59, "+0530")
PageWithoutAFile.new(@site, __dir__, article['id'], "index.html").tap do |file|
html = article['body_json']['blocks'].map{ |t| t['data']['text']}.join(" ")
topics = article['topic'].map { |topic| topic.split('-').first }
if article['trigger_warning']
html = "<p><b>#{article['trigger_warning_text']}</b></p>" + html
end
file.content = Sanitize.fragment(html, Sanitize::Config::RELAXED)
date = timestamp(article['updated_on'])
file.data.merge!(
'sources' => article['sources'],
"date" => date,
"title" => article['title'],
"layout" => 'article',
"topics" => topics,
"days_ago" => (now - date).floor
)
file.output
end
end
end

17
about.md Normal file
View File

@ -0,0 +1,17 @@
---
layout: article
title: About This Site
---
This site is a text-only minimal version of [Beatroot News](https://app.beatrootnews.com/), a new news app by Freemedia Interactive Private Limited.
It is maintained by [Nemo](https://github.com/captn3m0), and is meant as a minimal news website that you can check once a day.
This text-only version is unaffiliated with Beatroot News or Freemedia Interactive Private Limited. The content is updated once every hour.
## Curation Notes
- The [home-page](/) only includes un-syndicated articles.
- Only articles from today and yesterday are shown.
- The design is based on [NPR's](http://text.npr.org/) text-only website.
- Trigger Warnings are shown in bold, prefixed to the article text.

BIN
favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 B

26
index.html Normal file
View File

@ -0,0 +1,26 @@
---
title: "Beatroot News: Text-only"
layout: default
---
<p></p>
<div class="topic-container">
<h1 class="topic-heading">{{page.title}}</h1>
<div class="hr-line"></div>
<p class="topic-date">{{site.time | date: "%A, %b, %e, %Y"}}</p>
{% for topic in site.topics %}
<h3><a href="/{{topic}}/">{{topic | capitalize}}</a></h3>
<ul>
{% for post in site.pages %}
{% if post.topics and post.days_ago < 2 and post.topics.first == topic %}
{% unless post.sources contains "PTI" %}
<details><summary>{{post.title | trim}}</summary>
<div class="details-content">{{post.content}}</div>
</details>
{% endunless %}
{%endif%}
{% endfor %}
</ul>
{% endfor %}
</div>