Skip to content

Commit b4d110e

Browse files
committed
Merge branch 'publify_debugging_lab'
2 parents f32293b + 65d09b5 commit b4d110e

File tree

7 files changed

+108
-111
lines changed

7 files changed

+108
-111
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ group :development, :test do
8383
gem 'rspec-rails', '~> 3.4.0'
8484
gem 'simplecov', require: false
8585
gem 'pry-rails'
86+
gem 'ffaker'
8687
end
8788

8889
group :development do

README.md

Lines changed: 64 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
# Publify
1+
# Rails Legacy App
22

3-
**The Ruby on Rails publishing software formerly known as Typo**
3+
In this lab you will dive into a mature rails application and attempt to fix some reported bugs. This lab will stretch your debugging skills and your ability to navigate a large rails project. We encourage you to tackle it in pairs.
44

5-
### Download
5+
> This Rails application has been intentionally broken!
66
7-
You can download the latest
8-
Publify [stable release (8.2.0)](https://github.com/publify/publify/archive/v8.2.0.tar.gz)
9-
or [clone the Publify repository](https://github.com/publify/publify.git).
10-
11-
[![Build Status](https://travis-ci.org/publify/publify.png?branch=master)](https://travis-ci.org/publify/publify)
12-
[![Code Climate](https://codeclimate.com/github/publify/publify.png)](https://codeclimate.com/github/publify/publify)
13-
[![Dependency Status](https://gemnasium.com/publify/publify.png)](https://gemnasium.com/publify/publify)
14-
15-
## What's Publify?
7+
### What's Publify?
8+
You will be forking & cloning an open source (MIT LICENSE) blogging platform called Publify.
169

1710
Publify is a simple but full featured web publishing software. It's built
1811
around a blogging engine and a small message system connected to Twitter.
@@ -23,7 +16,11 @@ site, and Publish On your Own Site, Syndicate Everywhere.
2316
Publify has been around since 2004 and is the oldest Ruby on Rails open source
2417
project alive.
2518

26-
## Features
19+
[![Build Status](https://travis-ci.org/publify/publify.png?branch=master)](https://travis-ci.org/publify/publify)
20+
[![Code Climate](https://codeclimate.com/github/publify/publify.png)](https://codeclimate.com/github/publify/publify)
21+
[![Dependency Status](https://gemnasium.com/publify/publify.png)](https://gemnasium.com/publify/publify)
22+
23+
#### Features
2724

2825
- A classic multi user blogging engine
2926
- Short messages with a Twitter connection
@@ -35,126 +32,93 @@ project alive.
3532
German, Danish, Norwegian, Japanese, Hebrew, Simplified Chinese, Mexican
3633
Spanish, Italian, Lithuanian, Dutch, Polish, Romanian…
3734

38-
## Demo site
39-
40-
You can [give Publify a try](http://demo.publify.co)
41-
42-
The login / password [to the admin](http://demo.publify.co/admin)
43-
are:
35+
#### Resources
4436

45-
- Administrator: admin / admin
46-
- Publisher: publish / publish
47-
48-
The demo is reset every 2 hours.
37+
- [Publify Repo](https://github.com/publify/publify/issues)
38+
- [Publify blog](http://blog.publify.co)
39+
- [Publify on Twitter](https://twitter.com/getpublify)
40+
- IRC: \#publify on irc.freenode.net
4941

50-
## Install Publify locally
42+
## Getting Started: Installing Publify Locally
5143

5244
To install Publify you need the following:
5345

5446
- Ruby 2.0, 2.1 or 2.2
5547
- Ruby On Rails 4.2.0
5648
- A database engine, MySQL, PgSQL or SQLite3
49+
5750
- A compatible JavaScript installation for asset compilation. See [the execjs
5851
readme](https://github.com/sstephenson/execjs#readme) for details.
59-
- ImageMagick (used by mini_magick).
52+
- ImageMagick
6053

61-
1. Unzip Publify archive
62-
2. Rename database.yml.yourEngine as database.yml
63-
3. Edit database.yml to add your database name, login and password.
54+
#### Setup ImageMagick Dependency
55+
Make sure that you have ImageMagick installed (used by mini_magick).
6456

57+
Check for imagemagick:
6558
```bash
66-
$ bundle install
67-
$ rake db:setup
68-
$ rake db:migrate
69-
$ rake db:seed
70-
$ rake assets:precompile
71-
$ rails server
72-
```
73-
74-
You can now launch you browser and access 127.0.0.1:3000.
75-
76-
## Install Publify on Heroku
77-
78-
In order to install Publify on Heroku, you’ll need to do some minor tweaks.
79-
80-
### Storage
81-
82-
You need to setup Amazon S3 storage to be able to upload files on your
83-
blog. Set Heroku config vars.
84-
85-
```yaml
86-
heroku config:set provider=AWS
87-
aws_access_key_id=YOUR_AWS_ACCESS_KEY_ID
88-
aws_secret_access_key=YOUR_AWS_SECRET_ACCESS_KEY
89-
aws_bucket=YOUR_AWS_BUCKET_NAME
59+
$ which convert
60+
# /path/to/bin/convert
9061
```
9162

92-
To generate the Gemfile.lock, run:
63+
Install it if it's missing (this can take a few minutes):
9364
```bash
94-
HEROKU=true bundle install
65+
$ brew update
66+
$ brew link
67+
$ brew install imagemagick
9568
```
9669

97-
Remove Gemfile.lock from .gitignore and commit it.
98-
99-
Add the HEROKU config variable to your Heroku instance:
70+
#### Setup Rails Application
71+
Fork & Clone the Publify repo:
10072

10173
```bash
102-
heroku config:set HEROKU=true
74+
$ bundle install
75+
$ rake db:setup
76+
$ rake db:migrate
77+
$ rails server
10378
```
10479

105-
Push the repository to Heroku.
106-
107-
When deploying for the first time, Heroku will automatically add a Database
108-
plugin to your instance and links it to the application. After the first
109-
deployment, don't forget to run the database migration and seed.
80+
You can now launch you browser and access 127.0.0.1:3000.
11081

111-
```bash
112-
heroku run rake db:migrate db:seed
113-
```
82+
You will be prompted to supply a blog title and email:
11483

115-
If application error has occurred after migration, you need to restart Heroku server.
84+
You will be signed in and issued a username and password:
11685

86+
#### Seed your blog with posts & tags
11787
```bash
118-
heroku restart
88+
$ rake db:seed
89+
# => Seeded 24 articles...
11990
```
12091

121-
## Resources
122-
123-
- [Sidebar Plugins](https://github.com/publify/publify/wiki/Sidebar-plugins)
124-
- [In page Plugins](https://github.com/publify/publify/wiki/In-Page-Plugins)
125-
- [**Report a bug**](https://github.com/publify/publify/issues)
126-
- [**Frequently Asked Questions**](https://github.com/publify/publify/wiki/frequently-asked-questions)
127-
- [Publify blog](http://blog.publify.co)
128-
- [Publify on Twitter](https://twitter.com/getpublify)
129-
- IRC: \#publify on irc.freenode.net
130-
131-
### Maintainers
92+
#### Look around!
93+
* Go to the `/admin` backend and poke around (it's similar to wordpress).
94+
* Create your first blog post!
13295

133-
This is a list of Publify maintainers. If you have committed, please add
134-
your name and contact details to the list.
96+
##The Bugs
97+
The following issues have been added to the main github repo. Please fix each bug on its own branch (e.g. `fix_sidebar_styles`). When you're finished, create a pull request from your fork back to the main repo.
13598

136-
**Frédéric de Villamil** <[email protected]>
137-
blog: http://t37.net
138-
irc: neuro`
99+
> Make sure to reference the issue you are resolving!
139100
140-
**Matijs van Zuijlen**
141-
blog: http://www.matijs.net/blog/
142-
irc: matijs
101+
####Issue \#1: Inconsistent Sidebar Styles
102+
* All titles in the sidebar should have `monospace` style font
103+
* All bullets should be circles.
143104

144-
**Thomas Lecavelier**
145-
blog: http://blog.ookook.fr/
146-
irc: ook
105+
<img width="221" alt="sidebar styles" src="https://cloud.githubusercontent.com/assets/1489337/12761855/80fe8e7c-c9a1-11e5-9070-6113b8e9b419.png">
147106

148-
**Yannick François**
149-
blog: http://elsif.fr
150-
irc: yaf
107+
####Issue \#2: Top Month Always Empty (Archive Sidebar)
108+
* When I click on the top-most month in the Archive Sidebar it says "No posts found...".
109+
* When I create a post in the _current month_ (e.g. February) it displays a link in the sidebar for _next month_ (e.g. March), and says "No posts found..."
151110

152-
And [many more cool people who’ve one day or another contributed to
153-
Publify](https://github.com/publify/publify/graphs/contributors).
111+
####Issue \#3: Months sorted incorrectly (Archive Sidebar)
112+
The sort order of months in the Archive Sidebar is off, with January 2015 appearing directly above December 2015:
154113

155-
**Original Author: Tobias Luetke**
156-
blog: http://blog.leetsoft.com/
157-
irc: xal
114+
<img width="249" alt="archive sidebar sort order" src="https://cloud.githubusercontent.com/assets/1489337/12761829/698e56fa-c9a1-11e5-8d90-04ed28aa7a09.png">
158115

159-
Enjoy,
160-
The Publify team
116+
## Helpful Hints
117+
* Use **Rubber Duck Debugging** -- Make sure you understand the issue!
118+
* Use frequent **Sanity Checks**
119+
- What are you testing / what are you expecting?
120+
* **Follow the trail**
121+
- How do you work backwards from the view to the server?
122+
- How do you find specific files in your rails application?
123+
- How do you find specific keywords or method calls?
124+
* Sometimes you need to **resart the server** if the views you are working with are being cached.

app/assets/stylesheets/user-styles.css

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ img.right {
2424
}
2525

2626
.status {
27-
background: #fff;
27+
background: #fff;
2828
margin: -8px; padding: 8px;
29-
}
29+
}
30+
31+
#sidebar .sidebar-title {
32+
font-family: monospace;
33+
}
34+
35+
#sidebar .sidebar-body li {
36+
list-style-type: circle;
37+
}

app/controllers/setup_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def update_or_create_first_post_with_user(user)
5252
allow_pings: 1,
5353
published: 1,
5454
permalink: 'hello-world',
55-
tags: [Tag.first],
55+
tags: [Tag.create(name: 'general', display_name: 'General')],
5656
user: user)
5757
end
5858
end

db/seeds.rb

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@
66
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
77
# Mayor.create(name: 'Daley', city: cities.first)
88

9-
blog = Blog.first || Blog.create!
109

11-
tag = blog.tags.first || Tag.create!(name: 'general', display_name: 'General', blog_id: blog.id)
10+
blog = Blog.first || Blog.create!
1211

1312
unless blog.sidebars.any?
1413
PageSidebar.create!(active_position: 0, staged_position: 0, blog_id: blog.id)
@@ -46,3 +45,28 @@
4645
unless File.directory?("#{::Rails.root.to_s}/public/files")
4746
Dir.mkdir("#{::Rails.root.to_s}/public/files")
4847
end
48+
49+
#### Seed Fake Blog Posts
50+
if User.first # ensures publify was setup & admin created
51+
52+
seed_date = Date.today
53+
seed_tags = ["happy", "coding", "debugging", "pry", "grep", "wdi", "legacy code"]
54+
article_qty = 24
55+
user = User.first
56+
57+
Blog.first.articles.destroy_all
58+
article_qty.times do
59+
blog.articles.create do |article|
60+
article.title = FFaker::Company.catch_phrase
61+
article.body = FFaker::HipsterIpsum.paragraph(rand(1..3))
62+
seed_date -= 30
63+
article.published_at = seed_date
64+
article.published = true
65+
article.user = user
66+
article.keywords = seed_tags.sample(rand(1..4)).join(",")
67+
end
68+
end
69+
70+
p "Seeded #{article_qty} articles"
71+
72+
end

lib/archives_sidebar/app/views/archives_sidebar/_content.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<% unless sidebar.archives.blank? %>
2-
<h3 class="sidebar-title"><%= sidebar.title %></h3>
3-
<div class="sidebar-body">
2+
<h3 class="sidebar_title"><%= sidebar.title %></h3>
3+
<div class="sidebar_body">
44
<ul id="archives">
55
<% sidebar.archives.each do |month| %>
66
<% counter = sidebar.show_count ? "<em>(#{month[:article_count]})</em>" : "" %>
77
<li>
8-
<%= link_to"#{month[:name]} #{counter}".html_safe, articles_by_month_path(month[:year], "%02i" % month[:month]) %>
8+
<%= link_to"#{month[:name]} #{counter}".html_safe, articles_by_month_path( month[:year], "%02i" % (month[:month]+1) ) %>
99
</li>
1010
<% end %>
1111
</ul>

lib/archives_sidebar/lib/archives_sidebar.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ArchivesSidebar < Sidebar
22
description 'Displays links to monthly archives'
33
setting :title, 'Archives'
44
setting :show_count, true, label: 'Show article counts', input_type: :checkbox
5-
setting :count, 10, label: 'Number of Months'
5+
setting :count, 12, label: 'Number of Months'
66

77
attr_accessor :archives
88

@@ -30,11 +30,11 @@ def parse_request(_contents, _params)
3030
article_counts = Content.find_by_sql(["select count(*) as count, #{date_func} from contents where type='Article' and published = ? and published_at < ? group by year,month order by year desc,month desc limit ? ", true, Time.now, count.to_i])
3131

3232
@archives = article_counts.map do |entry|
33-
month = entry.month.to_i
33+
month = (entry.month.to_i%12)+1
3434
year = entry.year.to_i
3535
{
3636
name: I18n.l(Date.new(year, month), format: '%B %Y'),
37-
month: month,
37+
month: month - 1,
3838
year: year,
3939
article_count: entry.count
4040
}

0 commit comments

Comments
 (0)