소스 검색

ffho-config-mode-site-select: update package to use toolbox of ffho-site-select

Karsten Böddeker 8 년 전
부모
커밋
a79cc4282c
1개의 변경된 파일4개의 추가작업 그리고 17개의 파일을 삭제
  1. 4 17
      ffho/ffho-config-mode-site-select/files/lib/gluon/config-mode/wizard/0200-site-select.lua

+ 4 - 17
ffho/ffho-config-mode-site-select/files/lib/gluon/config-mode/wizard/0200-site-select.lua

@@ -1,24 +1,13 @@
 local cbi = require "luci.cbi"
 local i18n = require "luci.i18n"
-local uci = luci.model.uci.cursor()
+local uci = require('luci.model.uci').cursor()
 local default = require 'gluon.site_config'
-local json =  require 'luci.json'
+local tools = require 'gluon.site_generate'
 
 local M = {}
 
-function get_config(file)
-  local f = io.open(file)
-  if f then
-    local config = json.decode(f:read('*a'))
-    f:close()
-    return config
-  end
-  return nil
-end
-
-
 function M.section(form)
-  local sites = get_config('/lib/gluon/site-select/sites.json')
+  local sites = tools.get_config('/lib/gluon/site-select/sites.json')
 
   local msg = i18n.translate('gluon-config-mode:site-select')
   local s = form:section(cbi.SimpleSection, nil, msg)
@@ -42,9 +31,7 @@ end
 
 function M.handle(data)
   if data.community ~= uci:get('currentsite', 'current', 'name') then
-    uci:set('currentsite', 'current', 'name', data.community)
-    uci:save('currentsite')
-    uci:commit('currentsite')
+    tools.set_site_code(data.community)
   end
 
   if data.community ~= default.site_code then