-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from adnjoo/blog
blog
- Loading branch information
Showing
8 changed files
with
136 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# app/controllers/blog_controller.rb | ||
class BlogController < ApplicationController | ||
require "redcarpet" | ||
require "front_matter_parser" | ||
|
||
def index | ||
markdown_files = available_posts | ||
|
||
@posts = markdown_files.map do |file| | ||
parsed = parse_markdown_file(file) | ||
|
||
{ | ||
title: parsed.front_matter["title"], | ||
slug: File.basename(file, ".md"), | ||
summary: parsed.front_matter["summary"] || parsed.content[0..200], | ||
date: parsed.front_matter["date"]&.to_s | ||
} | ||
end | ||
end | ||
|
||
def show | ||
slug = sanitize_slug(params[:slug]) | ||
file_path = available_posts.find { |file| File.basename(file, ".md") == slug } | ||
|
||
if file_path.present? | ||
parsed = parse_markdown_file(file_path) | ||
|
||
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML) | ||
@post = markdown.render(parsed.content) | ||
else | ||
redirect_to blog_path, alert: "Post not found." | ||
end | ||
end | ||
|
||
private | ||
|
||
def parse_markdown_file(file) | ||
FrontMatterParser::Parser.parse_file(file) | ||
end | ||
|
||
def sanitize_slug(slug) | ||
slug.gsub(/[^0-9a-z\-_]/i, "") | ||
end | ||
|
||
def available_posts | ||
Dir.glob(Rails.root.join("app", "views", "posts", "*.md")) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<div class="max-w-4xl mx-auto py-12"> | ||
<h1 class="text-5xl font-extrabold mb-12 text-center tracking-widest text-black border-b-4 border-black"> | ||
Blog | ||
</h1> | ||
|
||
<div class="space-y-8"> | ||
<% @posts.each do |post| %> | ||
<div class="p-6 bg-gray-100 border-4 border-black shadow-none hover:shadow-xl hover:translate-x-1 hover:translate-y-1 transition-all duration-300"> | ||
<h2 class="text-3xl font-bold text-black"> | ||
<%= link_to post[:title], blog_post_path(post[:slug]), class: "hover:underline" %> | ||
</h2> | ||
|
||
<p class="text-lg font-mono text-gray-800 mt-4 leading-relaxed"> | ||
<%= post[:date] || "No date available." %> | ||
</p> | ||
|
||
<p class="text-md font-mono text-gray-600 mt-2"> | ||
<%= post[:summary] || "No summary available." %> | ||
</p> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="my-container"> | ||
<article class="p-2 shadow-none"> | ||
<p class="text-sm font-mono text-gray-600 mb-6"> | ||
<%= @post_date %> | ||
</p> | ||
|
||
<div class="prose"> | ||
<%= @post.html_safe %> | ||
</div> | ||
</article> | ||
|
||
<div class="mt-12"> | ||
<%= link_to 'Back to blog', blog_path, class: "text-black font-bold underline hover:no-underline transition-all duration-300" %> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
|
||
title: "Introducing DuelTasks: Gamify Your Productivity!" | ||
summary: "DuelTasks turns to-do lists into exciting challenges to boost your motivation and accountability!" | ||
date: "2024-10-22" | ||
|
||
--- | ||
|
||
# Introducing DuelTasks: Gamify Your Productivity! | ||
|
||
Tired of boring to-do lists? [**DuelTasks**](/) transforms task management with a fun, competitive twist to keep you motivated! | ||
|
||
## What is DuelTasks? | ||
|
||
DuelTasks is a gamified productivity app where tasks become challenges. Set a deadline, choose a challenger, and stay accountable with real stakes—fail to complete the task, and you pay a penalty! | ||
|
||
## Key Features | ||
|
||
- **Challenging Tasks**: Turn any task into a duel—win or pay up! | ||
- **Real Rewards**: Set monetary penalties for uncompleted tasks with seamless Stripe integration. | ||
- **Leaderboards**: Track progress, earn rewards, and stay motivated. | ||
- **Multiplayer To-Dos**: Collaborate or challenge others to complete tasks together. | ||
|
||
## Why It Works | ||
|
||
Gamification taps into your competitive side, making tasks more engaging and harder to ignore. DuelTasks' penalty system adds accountability to keep you on track. | ||
|
||
## Get Started | ||
|
||
Turn tasks into fun challenges. [Sign up for DuelTasks](/users/sign_in) and start winning today! | ||
|
||
--- | ||
|
||
Stay competitive and get things done with DuelTasks! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters