Skip to content

Commit

Permalink
Fragment cache the about and welcome pages (about page only gets expi…
Browse files Browse the repository at this point in the history
…red on restart).
  • Loading branch information
kkuchta committed Feb 26, 2012
1 parent 3036541 commit 96ffee2
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 103 deletions.
2 changes: 2 additions & 0 deletions app/controllers/bits_controller.rb
Expand Up @@ -82,6 +82,7 @@ def create
respond_to do |format|
if @bit.save
expire_fragment( :action => 'index' )
expire_fragment( controller: 'welcome', action: 'index' )
format.html { redirect_to @bit, notice: 'Bit was successfully created.' }
format.json { render json: @bit, status: :created, location: @bit }
else
Expand All @@ -102,6 +103,7 @@ def update
if @bit.update_attributes(params[:bit])
expire_fragment( :action => 'index' )
expire_fragment( action: 'show', id: params[:id] )
expire_fragment( controller: 'welcome', action: 'index' )
format.html { redirect_to @bit, notice: 'Bit was successfully updated.' }
format.json { head :no_content }
else
Expand Down
1 change: 0 additions & 1 deletion app/controllers/welcome_controller.rb
@@ -1,5 +1,4 @@
class WelcomeController < ApplicationController
caches_page :index, :about
def index
@top = Bit.plusminus_tally.first()
@new = Bit.order('created_at DESC').first()
Expand Down
105 changes: 53 additions & 52 deletions app/views/welcome/about.html.haml
@@ -1,55 +1,56 @@
%section
.page-header
%h1 About
%h2
What's this all about?
%p
Vim is powerful text-editor, designed to be very user-friendly, so long as you're a pro-user. Short but obtuse key-combos, unintuitive (to most) editing, and arcane configuration. With experience, though, it can be an excellent tool.
%p
%h2
What's a vimbit?
%p
The main way you configure Vim is with a .vimrc file. The configuration, though, is a language of it's own. The combinations are endless, and the level of customization you can achieve is one of the strengths of the Vim editor. A Vimbit is a line or small set of lines that, when put into a vimrc file, perform a certain task: remapping the escape key to something more convenient, limiting line lenght to 80 characters, setting a key combination to toggle whitespace visiblity, etc.
%h2
Show me one.
%p
Sample Vimbit (credit to
%a{href:'http://stevelosh.com/blog/2010/09/coming-home-to-vim/'} Steve Losh
) to make the oft-typed colon slightly quicker:
.bit.example.row
.span8
%h3
Remap ; to :
%span.email
%i kevin@example.com
posted this on
Febuary 19, 2011
%p
%pre.prettyprint.linenums="nnoremap ; : \nvnoremap ; :"
%p
The colon is used so frequently that it seems silly not to make it a single key on the home row. Don't map : back to ;, as it breaks a bunch of plugins.
%p
%a.label.label-info.tag{href: '#'} remapping
%a.label.label-info.tag{href: '#'} common-keys
%h2 What's this site?
%p
The state of the art for finding vimbits seems to be to crawl well-known Vim-ers' public vimrcs on github, or watch for "vimrc" threads on /r/vim, or follow vim-related twitter accounts. There are plenty of vim resources out there, but most focus on Vim as a whole- the basic commands, the modes of use, plugins, colorschemes, and configuration. Vimbits is here to focus entirely on that last one- the content of your vimrc.
%p
%a{href:'/bits/new'} Share
your favorite vimbits.
%a{href:'/bits?sort=new'} Find
cool new ones.
%a{href:'/bits?sort=top'} Check
out the top few and see what you think!
%h2 Who made this?
%a{href:'http://kevinkuchta.com'} Kevin Kuchta
built it in early 2012. He maintains and runs it as well.
%h2 I want to help/complain/contact you!
If you have a quick question, hit me up on
%a{href:'http://twitter.com/kkuchta'} Twitter.
If you have an issue with the site, open up a ticket on the
%a{href:'https://github.com/kkuchta/Vimbits'} Vimbits Github.
That's also the place to go if you want to contribute a fix, correct spellingmistake, etc.
- cache do
%section
.page-header
%h1 About
%h2
What's this all about?
%p
Vim is powerful text-editor, designed to be very user-friendly, so long as you're a pro-user. Short but obtuse key-combos, unintuitive (to most) editing, and arcane configuration. With experience, though, it can be an excellent tool.
%p
%h2
What's a vimbit?
%p
The main way you configure Vim is with a .vimrc file. The configuration, though, is a language of it's own. The combinations are endless, and the level of customization you can achieve is one of the strengths of the Vim editor. A Vimbit is a line or small set of lines that, when put into a vimrc file, perform a certain task: remapping the escape key to something more convenient, limiting line lenght to 80 characters, setting a key combination to toggle whitespace visiblity, etc.
%h2
Show me one.
%p
Sample Vimbit (credit to
%a{href:'http://stevelosh.com/blog/2010/09/coming-home-to-vim/'} Steve Losh
) to make the oft-typed colon slightly quicker:
.bit.example.row
.span8
%h3
Remap ; to :
%span.email
%i kevin@example.com
posted this on
Febuary 19, 2011
%p
%pre.prettyprint.linenums="nnoremap ; : \nvnoremap ; :"
%p
The colon is used so frequently that it seems silly not to make it a single key on the home row. Don't map : back to ;, as it breaks a bunch of plugins.
%p
%a.label.label-info.tag{href: '#'} remapping
%a.label.label-info.tag{href: '#'} common-keys
%h2 What's this site?
%p
The state of the art for finding vimbits seems to be to crawl well-known Vim-ers' public vimrcs on github, or watch for "vimrc" threads on /r/vim, or follow vim-related twitter accounts. There are plenty of vim resources out there, but most focus on Vim as a whole- the basic commands, the modes of use, plugins, colorschemes, and configuration. Vimbits is here to focus entirely on that last one- the content of your vimrc.
%p
%a{href:'/bits/new'} Share
your favorite vimbits.
%a{href:'/bits?sort=new'} Find
cool new ones.
%a{href:'/bits?sort=top'} Check
out the top few and see what you think!
%h2 Who made this?
%a{href:'http://kevinkuchta.com'} Kevin Kuchta
built it in early 2012. He maintains and runs it as well.
%h2 I want to help/complain/contact you!
If you have a quick question, hit me up on
%a{href:'http://twitter.com/kkuchta'} Twitter.
If you have an issue with the site, open up a ticket on the
%a{href:'https://github.com/kkuchta/Vimbits'} Vimbits Github.
That's also the place to go if you want to contribute a fix, correct spellingmistake, etc.



101 changes: 51 additions & 50 deletions app/views/welcome/index.html.haml
@@ -1,53 +1,54 @@
.row
.span12
%header.hero-unit
%h1 Vimbits
%p A vimbit is a snippet of a .vimrc. Share you coolest trick, mapping, setting, or custom command for the Vim editor. Find new bits and vote up the best ones.
%p
%em :set awesome=on
- if @top and @new
.row
.span6
%h3
%a.btn.btn-primary{href: '/bits?sort=top' } Top:
%a{href: url_for(@top)}=@top.title
%p
%pre.prettyprint.linenums= limit_string @top.code
.span6
%h3
%a.btn.btn-primary{href: '/bits?sort=new' } Newest:
%a{href:url_for(@new)}=@new.title
%p
%pre.prettyprint.linenums= limit_string @new.code
.blog
- cache do
.row
.span12
.page-header
%h2
Vimbits is open
%code 2/26/12
by KKuchta
%p
Vimbits is an upvote-downvote site for vimrc tricks.
%p
After my first few months in the vimverse, I got a little disheartened that the best way to find new ideas for vim customization seemed to be by crawling through other developers' vimrcs. Don't get me wrong- that was useful and educational, but I've found that by now, 99% of any given vimrc I've already seen.
%p Vimbits aims to break these down into discrete units that can be tagged, categorized, voted on and ranked. A newish vim user should be able to skim the 'Top' list and populate their vimrc from there.
%p
Some ideas for after launch:
%ul
%li
Some system to mark vimbits as 'obvious' (eg,
%code syntax on
or
%code set hidden
).
These can be enshrined somewhere visible, but removed from the main 'top' page.
%li
Sections for plugins and/or colorschemes
%li
Lots of UI improvements
%li
Ajaxify some stuff (mostly the index page)
%li
Full text searching
%header.hero-unit
%h1 Vimbits
%p A vimbit is a snippet of a .vimrc. Share you coolest trick, mapping, setting, or custom command for the Vim editor. Find new bits and vote up the best ones.
%p
%em :set awesome=on
- if @top and @new
.row
.span6
%h3
%a.btn.btn-primary{href: '/bits?sort=top' } Top:
%a{href: url_for(@top)}=@top.title
%p
%pre.prettyprint.linenums= limit_string @top.code
.span6
%h3
%a.btn.btn-primary{href: '/bits?sort=new' } Newest:
%a{href:url_for(@new)}=@new.title
%p
%pre.prettyprint.linenums= limit_string @new.code
.blog
.row
.span12
.page-header
%h2
Vimbits is open
%code 2/26/12
by KKuchta
%p
Vimbits is an upvote-downvote site for vimrc tricks.
%p
After my first few months in the vimverse, I got a little disheartened that the best way to find new ideas for vim customization seemed to be by crawling through other developers' vimrcs. Don't get me wrong- that was useful and educational, but I've found that by now, 99% of any given vimrc I've already seen.
%p Vimbits aims to break these down into discrete units that can be tagged, categorized, voted on and ranked. A newish vim user should be able to skim the 'Top' list and populate their vimrc from there.
%p
Some ideas for after launch:
%ul
%li
Some system to mark vimbits as 'obvious' (eg,
%code syntax on
or
%code set hidden
).
These can be enshrined somewhere visible, but removed from the main 'top' page.
%li
Sections for plugins and/or colorschemes
%li
Lots of UI improvements
%li
Ajaxify some stuff (mostly the index page)
%li
Full text searching

0 comments on commit 96ffee2

Please sign in to comment.