Skip to content

Instantly share code, notes, and snippets.

@TiagoTi
TiagoTi / gist:5a3232cadaa4b558ac4dbd5903f1d31a
Created March 17, 2020 07:21 — forked from romainl/gist:9970697
How to use Tim Pope's Pathogen

How to use Tim Pope’s Pathogen

I’ll assume you are on Linux or Mac OSX. For Windows, replace ~/.vim/ with $HOME\vimfiles\ and forward slashes with backward slashes.

The idea

Vim plugins can be single scripts or collections of specialized scripts that you are supposed to put in “standard” locations under your ~/.vim/ directory. Syntax scripts go into ~/.vim/syntax/, plugin scripts go into ~/.vim/plugin, documentation goes into ~/.vim/doc/ and so on. That design can lead to a messy config where it quickly becomes hard to manage your plugins.

This is not the place to explain the technicalities behind Pathogen but the basic concept is quite straightforward: each plugin lives in its own directory under ~/.vim/bundle/, where each directory simulates the standard structure of your ~/.vim/ directory.

require 'sinatra'
require 'warden'
class YourApp < Sinatra::Application
get "/" do
erb 'index'.to_sym
end
get "/protected_pages" do
Warden::Manager.serialize_into_session{|user| user.id }
Warden::Manager.serialize_from_session{|id| User.get(id) }
Warden::Manager.before_failure do |env,opts|
# Sinatra is very sensitive to the request method
# since authentication could fail on any type of method, we need
# to set it for the failure app so it is routed to the correct block
env['REQUEST_METHOD'] = "POST"
end

Useful commands

last_response
    .body

last_request
    .path
    .url
    .session

.cookies