2020*/
2121
2222public class Spice.Services.Fetcher {
23- private const string TEMPLATES_URL = " https://spice-up-dev .azurewebsites.net/api/get-templates " ;
23+ private const string TEMPLATES_URL = " https://spice-up-prod .azurewebsites.net/api/" ;
2424 private const int64 CACHE_LIFE = 43200 ; // 1/2 a day
25- public const int CURRENT_VERSION = 1 ;
25+ public const string CURRENT_VERSION = " 2 " ;
2626
2727 private File cache_file;
2828 private string cache = " " ;
@@ -32,7 +32,7 @@ public class Spice.Services.Fetcher {
3232 cache_file = File . new_for_path (Environment . get_tmp_dir () + " /com.github.philip-scott.spice-up.cache.json" );
3333 }
3434
35- public void fetch () {
35+ public void fetch_templates () {
3636 var now = new DateTime .now_utc (). to_unix ();
3737
3838 var settigns = Spice . Services . Settings . get_instance ();
@@ -44,7 +44,7 @@ public class Spice.Services.Fetcher {
4444 debug (" Getting templates from server\n " );
4545 new Thread<void* > (" fetch-templates" , () = > {
4646 var session = new Soup .Session ();
47- var message = new Soup .Message (" GET" , TEMPLATES_URL );
47+ var message = new Soup .Message (" GET" , TEMPLATES_URL + " get-templates " );
4848
4949 session. send_message (message);
5050
@@ -56,6 +56,7 @@ public class Spice.Services.Fetcher {
5656 mutex. lock ();
5757
5858 cache = data. str;
59+
5960 if (cache != " " ) {
6061 save_to_cache (cache);
6162 settigns. last_fetch = now. to_string ();
@@ -70,6 +71,20 @@ public class Spice.Services.Fetcher {
7071 }
7172 }
7273
74+ public static string get_template_data (string template ) {
75+ var session = new Soup .Session ();
76+ var message = new Soup .Message (" GET" , TEMPLATES_URL + template);
77+
78+ session. send_message (message);
79+
80+ var data = new StringBuilder ();
81+ foreach (var c in message. response_body. data) {
82+ data. append (" %c " . printf (c));
83+ }
84+
85+ return data. str;
86+ }
87+
7388 public string get_data () {
7489 mutex. lock ();
7590 if (cache == " " && cache_file. query_exists ()) {
0 commit comments