Introduction
This Webapplication manages Code Snippets in GIT and saves the context (Name, Description, Tags) in a SQLITE database.
Features:
- Add Code Snippets to a GIT repository
- Delete Code Snippets from a GIT Repository
- Edit Code Snippets in a GIT repository
- Assign Tags to Code Snippets
- Search for Code Snippets
- User Authentication against a database
- Filter Snippets for Languages
- Use a Tagcloud to filter by tags
- Preview Snippets before adding/editing
See Bugs/Issues at the bottom of this document for known problems.
Installation
This webapplication runs best with
- Rails 3.0.7
- Ruby 1.9.2p290
To load and save Code Snippets via GIT, a local GIT repository must exist. There are three ways:
a.) Clone an existing svn repository with http_auth and without svn usernames:
E:\>mkdir svn_git_clone
E:\>cd svn_git_clone
E:\svn_git_clone>git init
E:\svn_git_clone>git svn clone --no-metadata --username xyz https://www.svn.com/snippets-path/ // xyz is the http_auth username
E:\svn_git_clone\snippets-path is then your new GIT repo
If you also want to import the svn user or import the trunk/branch/tag directory structure checkout http://www.zdnet.de/magazin/41500079/so-laesst-sich-ein-subversion-projektarchiv-zu-git-konvertieren.htm
Or b.) Get a copy of an existing GIT repository
E:\>mkdir svn_git_clone
E:\>cd svn_git_clone
E:\svn_git_clone>git clone git://github.com/grebre/codesnippets.git
E:\svn_git_clone\codesnippets is then your new GIT repo path
Or c.) Create a new and empty GIT repository
E:\>mkdir svn_git_clone
E:\>cd svn_git_clone
E:\svn_git_clone>git init
Set the Git Repository in the WebApp
After the local git repository exists, set it in app/helpers/snippets_helper.rb:
def getRepo
Dir.chdir("C:\\svn_git_clone\\codesnippets") // change the path
repo = Grit::Repo.new('.')
end
def getGitBase
Dir.chdir("C:\\svn_git_clone\\codesnippets") // change the path
Git::init('.')
end
The development.sqlite3 has set the snippet paths from the Git repository at https://github.com/grebre/codesnippets
Administration User
In the provided development.sqlite3 database there's an existing administration user:
Username: admin@test.com
Password: testtest
Known Bugs and Issues
- There's no file and git exception handling right now. For example if the repopath starts with a '/' there will be an unhandled error.
- (Fixed) If you want to update the code snippet, but haven' changed the code --> git error because it wants to commit, but nothing changed
- Right now, every user in the db can manage code snippets.
- If the git directory does not exist yet, there will be an error
- If the file exists in git, but no code snippet in the db has it set in the repopath, it will be overwritten
- CodeRay formats every code with ruby syntax highlighting and not language dependent
- if you edit the code snippet and set a new filename, the old file will not be deleted
- Tag List on edit/add snippet is not perfect: you cannot add a tag as long as there is a result (if a tag 'Java' exists and you want a new Tag 'Ja' its not possible)
- Filter for 2 or more selected languages at the same time does not work
- Filter checkbox will not be remembered after filter action
- In Add and Edit: after preview, the Tags will not be remembered for creation. this will cause an validation error (presence of language tag must be true).
- If an Tag with space is added, the link to filter it will seperate the word at the space and make n-time links
- If you click Preview in the edit mode, the code-part will not be loaded in the text-area. If you click submit afterwards, it will update the code snippet with empty content!
- In Add/Edit Snippets after preview: if the language exists and is inserted in the input-field, all tags added below with non-existing names get strange names.
- (Fixed) Encoding problem: umlaute are not working at the moment.