Update source: pull from git

This commit is contained in:
chris2tof 2011-08-23 15:01:22 +08:00
parent 4f38074932
commit 2842001a3b
7 changed files with 35 additions and 7 deletions

View File

@ -13,6 +13,8 @@ class Site
field :school
field :department
field :up_to_date, :type => Boolean
def generate_keys
private_key = OpenSSL::PKey::RSA.generate(2048)
self.public_key = private_key.public_key.to_s

View File

@ -0,0 +1,7 @@
<% if @site && @site.registered? %>
<%= t('admin.registered') %>
<% else %>
<%= link_to 'register', "http://#{APP_CONFIG['store_ip']}/user/sites/register?" +
{:site => {:school => @site.school, :department => @site.department}}.to_query,
:target => '_blank' %>
<% end %>

View File

@ -0,0 +1,5 @@
<% if @site.up_to_date %>
<%= t('admin.up_to_date') %>
<% else %>
<%= link_to t(:update), site_update_path %>
<% end %>

View File

@ -1,7 +1,3 @@
<% if @site && @site.registered? %>
registered
<% else %>
<%= link_to 'register', "http://#{APP_CONFIG['store_ip']}/user/sites/register?" +
{:site => {:school => @site.school, :department => @site.department}}.to_query,
:target => '_blank' %>
<% end %>
<%= render 'registration' %>
<%= render 'update' %>

View File

@ -40,6 +40,7 @@ en:
data: Data
delete_language: Delete language
description: Description
design: Design
disable_language: Disable language
editing_home: Editing homepage
editing_layout: Editing layout
@ -85,11 +86,14 @@ en:
orig_upload_file: Original filename
position: Position
published?: Published?
purchase: Purchase
info: Information
registered: Registered
role: Role
title: Title
translation: Translation
type: Type
up_to_date: Up-do-date
update_error_link: Error when updating link.
update_error_page: Error when updating page.
update_success_content: Content was successfully updated.

View File

@ -5,6 +5,7 @@ PrototypeR4::Application.routes.draw do
# routes for sinatra app
match '/site/set_registered', :to => CentralServerExchangeApp
match '/site/public_key', :to => CentralServerExchangeApp
match '/site/update', :to => GithubApp
match '/purchase/design', :to => CentralServerExchangeApp
# routes for admin

13
lib/github_app.rb Normal file
View File

@ -0,0 +1,13 @@
class GithubApp < Sinatra::Base
before do
@site = Site.first
end
get '/site/update' do
updated = system('git pull')
@site.update_attribute(:up_to_date, true) if updated
redirect "admin/sites?updated=#{updated}"
end
end