Просмотр исходного кода

Merge branch 'Blog' into BaseProject

Iñigo Valentin 9 лет назад
Родитель
Сommit
83a9f77fc4
54 измененных файлов с 3004 добавлено и 130 удалено
  1. 49 1
      app.xcodeproj/project.pbxproj
  2. 3 0
      app/AppDelegate.swift
  3. 6 0
      app/Assets.xcassets/Social/Contents.json
  4. 23 0
      app/Assets.xcassets/Social/Facebook.imageset/Contents.json
  5. BIN
      app/Assets.xcassets/Social/Facebook.imageset/social_facebook-1.png
  6. BIN
      app/Assets.xcassets/Social/Facebook.imageset/social_facebook-2.png
  7. BIN
      app/Assets.xcassets/Social/Facebook.imageset/social_facebook.png
  8. 23 0
      app/Assets.xcassets/Social/GooglePlus.imageset/Contents.json
  9. BIN
      app/Assets.xcassets/Social/GooglePlus.imageset/social_googleplus-1.png
  10. BIN
      app/Assets.xcassets/Social/GooglePlus.imageset/social_googleplus-2.png
  11. BIN
      app/Assets.xcassets/Social/GooglePlus.imageset/social_googleplus.png
  12. 23 0
      app/Assets.xcassets/Social/Instagram.imageset/Contents.json
  13. BIN
      app/Assets.xcassets/Social/Instagram.imageset/social_instagram-1.png
  14. BIN
      app/Assets.xcassets/Social/Instagram.imageset/social_instagram-2.png
  15. BIN
      app/Assets.xcassets/Social/Instagram.imageset/social_instagram.png
  16. 23 0
      app/Assets.xcassets/Social/Mail.imageset/Contents.json
  17. BIN
      app/Assets.xcassets/Social/Mail.imageset/social_mail-1.png
  18. BIN
      app/Assets.xcassets/Social/Mail.imageset/social_mail-2.png
  19. BIN
      app/Assets.xcassets/Social/Mail.imageset/social_mail.png
  20. 23 0
      app/Assets.xcassets/Social/Phone.imageset/Contents.json
  21. BIN
      app/Assets.xcassets/Social/Phone.imageset/social_phone-1.png
  22. BIN
      app/Assets.xcassets/Social/Phone.imageset/social_phone-2.png
  23. BIN
      app/Assets.xcassets/Social/Phone.imageset/social_phone.png
  24. 23 0
      app/Assets.xcassets/Social/Twitter.imageset/Contents.json
  25. BIN
      app/Assets.xcassets/Social/Twitter.imageset/social_twitter-1.png
  26. BIN
      app/Assets.xcassets/Social/Twitter.imageset/social_twitter-2.png
  27. BIN
      app/Assets.xcassets/Social/Twitter.imageset/social_twitter.png
  28. 23 0
      app/Assets.xcassets/Social/Whatsapp.imageset/Contents.json
  29. BIN
      app/Assets.xcassets/Social/Whatsapp.imageset/social_whatsapp-1.png
  30. BIN
      app/Assets.xcassets/Social/Whatsapp.imageset/social_whatsapp-2.png
  31. BIN
      app/Assets.xcassets/Social/Whatsapp.imageset/social_whatsapp.png
  32. 23 0
      app/Assets.xcassets/Social/Youtube.imageset/Contents.json
  33. BIN
      app/Assets.xcassets/Social/Youtube.imageset/social_youtube-1.png
  34. BIN
      app/Assets.xcassets/Social/Youtube.imageset/social_youtube-2.png
  35. BIN
      app/Assets.xcassets/Social/Youtube.imageset/social_youtube.png
  36. 223 7
      app/Base.lproj/Main.storyboard
  37. 203 0
      app/BlogView.swift
  38. 61 0
      app/BlogView.xib
  39. 169 5
      app/HomeView.swift
  40. 17 17
      app/HomeView.xib
  41. 158 0
      app/PostViewController.swift
  42. 130 0
      app/RowBlog.swift
  43. 113 0
      app/RowBlog.xib
  44. 120 0
      app/RowHomeBlog.swift
  45. 111 0
      app/RowHomeBlog.xib
  46. 118 0
      app/RowHomeFutureActivities.swift
  47. 111 0
      app/RowHomeFutureActivities.xib
  48. 151 0
      app/RowHomeSocial.swift
  49. 155 0
      app/RowHomeSocial.xib
  50. 830 95
      app/Sync.swift
  51. 42 0
      app/UIApplcation.swift
  52. 16 0
      app/UIView.swift
  53. 32 4
      app/ViewController.swift
  54. 2 1
      app/app.xcdatamodeld/app.xcdatamodel/contents

+ 49 - 1
app.xcodeproj/project.pbxproj

@@ -7,6 +7,10 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		93075C6A1E59CAB000396389 /* BlogView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93075C691E59CAB000396389 /* BlogView.xib */; };
+		93075C6C1E59CB6B00396389 /* BlogView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93075C6B1E59CB6B00396389 /* BlogView.swift */; };
+		93075C701E59D04A00396389 /* RowBlog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93075C6F1E59D04A00396389 /* RowBlog.swift */; };
+		93075C721E59D06900396389 /* RowBlog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93075C711E59D06900396389 /* RowBlog.xib */; };
 		931AA5891E1AFF8C003A2290 /* String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 931AA5881E1AFF8C003A2290 /* String.swift */; };
 		931AA58B1E1DA911003A2290 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 931AA58A1E1DA910003A2290 /* CoreData.framework */; };
 		931AA5AE1E218D0E003A2290 /* Entry.xib in Resources */ = {isa = PBXBuildFile; fileRef = 931AA5AD1E218D0D003A2290 /* Entry.xib */; };
@@ -14,6 +18,7 @@
 		93294FF81E336FA000FDAF50 /* Entry.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93294FF71E336FA000FDAF50 /* Entry.swift */; };
 		93294FFA1E337D0D00FDAF50 /* RowHomePastActivities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93294FF91E337D0D00FDAF50 /* RowHomePastActivities.swift */; };
 		935892D01E493C2300E1CD5F /* UIImageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935892CF1E493C2300E1CD5F /* UIImageView.swift */; };
+		937EA02D1E5B8B5300D0893A /* UIApplcation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 937EA02C1E5B8B5300D0893A /* UIApplcation.swift */; };
 		93B408031D9ED44C000FBC99 /* MenuCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93B408021D9ED44C000FBC99 /* MenuCollectionViewCell.swift */; };
 		93B84B9A1D9C31AB006C0F67 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93B84B991D9C31AB006C0F67 /* AppDelegate.swift */; };
 		93B84B9C1D9C31AB006C0F67 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93B84B9B1D9C31AB006C0F67 /* ViewController.swift */; };
@@ -21,6 +26,13 @@
 		93B84BA21D9C31AB006C0F67 /* app.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 93B84BA01D9C31AB006C0F67 /* app.xcdatamodeld */; };
 		93B84BA41D9C31AB006C0F67 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 93B84BA31D9C31AB006C0F67 /* Assets.xcassets */; };
 		93B84BA71D9C31AB006C0F67 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 93B84BA51D9C31AB006C0F67 /* LaunchScreen.storyboard */; };
+		93BAD2EE1E585578009DF853 /* RowHomeBlog.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93BAD2ED1E585578009DF853 /* RowHomeBlog.xib */; };
+		93BAD2F01E585662009DF853 /* RowHomeBlog.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BAD2EF1E585662009DF853 /* RowHomeBlog.swift */; };
+		93BAD2F21E585E88009DF853 /* RowHomeFutureActivities.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93BAD2F11E585E88009DF853 /* RowHomeFutureActivities.xib */; };
+		93BAD2F41E585EE6009DF853 /* RowHomeFutureActivities.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BAD2F31E585EE6009DF853 /* RowHomeFutureActivities.swift */; };
+		93BAD2F61E586310009DF853 /* RowHomeSocial.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93BAD2F51E586310009DF853 /* RowHomeSocial.xib */; };
+		93BAD2F81E586741009DF853 /* RowHomeSocial.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BAD2F71E586741009DF853 /* RowHomeSocial.swift */; };
+		93BEB6D21E7E878300C68DE5 /* PostViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93BEB6D11E7E878300C68DE5 /* PostViewController.swift */; };
 		93D9EA601DE271E700089002 /* Section.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93D9EA5F1DE271E700089002 /* Section.xib */; };
 		93D9EA641DE273FD00089002 /* Section.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D9EA631DE273FD00089002 /* Section.swift */; };
 		93D9EA681DE342AC00089002 /* UIView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D9EA671DE342AC00089002 /* UIView.swift */; };
@@ -31,6 +43,10 @@
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
+		93075C691E59CAB000396389 /* BlogView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BlogView.xib; sourceTree = "<group>"; };
+		93075C6B1E59CB6B00396389 /* BlogView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BlogView.swift; sourceTree = "<group>"; };
+		93075C6F1E59D04A00396389 /* RowBlog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowBlog.swift; sourceTree = "<group>"; };
+		93075C711E59D06900396389 /* RowBlog.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowBlog.xib; sourceTree = "<group>"; };
 		931AA5881E1AFF8C003A2290 /* String.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = String.swift; sourceTree = "<group>"; };
 		931AA58A1E1DA910003A2290 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
 		931AA5AD1E218D0D003A2290 /* Entry.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = Entry.xib; sourceTree = "<group>"; };
@@ -38,6 +54,7 @@
 		93294FF71E336FA000FDAF50 /* Entry.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Entry.swift; sourceTree = "<group>"; };
 		93294FF91E337D0D00FDAF50 /* RowHomePastActivities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomePastActivities.swift; sourceTree = "<group>"; };
 		935892CF1E493C2300E1CD5F /* UIImageView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIImageView.swift; sourceTree = "<group>"; };
+		937EA02C1E5B8B5300D0893A /* UIApplcation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIApplcation.swift; sourceTree = "<group>"; };
 		93B408021D9ED44C000FBC99 /* MenuCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = MenuCollectionViewCell.swift; path = ../MenuCollectionViewCell.swift; sourceTree = "<group>"; };
 		93B84B961D9C31AB006C0F67 /* app.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = app.app; sourceTree = BUILT_PRODUCTS_DIR; };
 		93B84B991D9C31AB006C0F67 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -47,6 +64,13 @@
 		93B84BA31D9C31AB006C0F67 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
 		93B84BA61D9C31AB006C0F67 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
 		93B84BA81D9C31AB006C0F67 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
+		93BAD2ED1E585578009DF853 /* RowHomeBlog.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowHomeBlog.xib; sourceTree = "<group>"; };
+		93BAD2EF1E585662009DF853 /* RowHomeBlog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomeBlog.swift; sourceTree = "<group>"; };
+		93BAD2F11E585E88009DF853 /* RowHomeFutureActivities.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowHomeFutureActivities.xib; sourceTree = "<group>"; };
+		93BAD2F31E585EE6009DF853 /* RowHomeFutureActivities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomeFutureActivities.swift; sourceTree = "<group>"; };
+		93BAD2F51E586310009DF853 /* RowHomeSocial.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowHomeSocial.xib; sourceTree = "<group>"; };
+		93BAD2F71E586741009DF853 /* RowHomeSocial.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowHomeSocial.swift; sourceTree = "<group>"; };
+		93BEB6D11E7E878300C68DE5 /* PostViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PostViewController.swift; sourceTree = "<group>"; };
 		93D9EA5F1DE271E700089002 /* Section.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = Section.xib; path = ../Section.xib; sourceTree = "<group>"; };
 		93D9EA631DE273FD00089002 /* Section.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Section.swift; sourceTree = "<group>"; };
 		93D9EA671DE342AC00089002 /* UIView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIView.swift; sourceTree = "<group>"; };
@@ -101,14 +125,26 @@
 				93D9EA631DE273FD00089002 /* Section.swift */,
 				931AA5AD1E218D0D003A2290 /* Entry.xib */,
 				93294FF71E336FA000FDAF50 /* Entry.swift */,
-				93D9EA6B1DE3498500089002 /* HomeView.xib */,
 				93D9EA691DE3491100089002 /* HomeView.swift */,
+				93D9EA6B1DE3498500089002 /* HomeView.xib */,
 				93D9EA751DE3ACBB00089002 /* Sync.swift */,
 				931AA5AF1E219006003A2290 /* RowHomePastActivities.xib */,
 				93294FF91E337D0D00FDAF50 /* RowHomePastActivities.swift */,
+				93BAD2ED1E585578009DF853 /* RowHomeBlog.xib */,
+				93BAD2EF1E585662009DF853 /* RowHomeBlog.swift */,
 				931AA5881E1AFF8C003A2290 /* String.swift */,
 				93D9EA671DE342AC00089002 /* UIView.swift */,
 				935892CF1E493C2300E1CD5F /* UIImageView.swift */,
+				93075C691E59CAB000396389 /* BlogView.xib */,
+				93075C6B1E59CB6B00396389 /* BlogView.swift */,
+				93075C6F1E59D04A00396389 /* RowBlog.swift */,
+				93075C711E59D06900396389 /* RowBlog.xib */,
+				93BAD2F11E585E88009DF853 /* RowHomeFutureActivities.xib */,
+				93BAD2F31E585EE6009DF853 /* RowHomeFutureActivities.swift */,
+				93BAD2F51E586310009DF853 /* RowHomeSocial.xib */,
+				93BAD2F71E586741009DF853 /* RowHomeSocial.swift */,
+				93BEB6D11E7E878300C68DE5 /* PostViewController.swift */,
+				937EA02C1E5B8B5300D0893A /* UIApplcation.swift */,
 			);
 			path = app;
 			sourceTree = "<group>";
@@ -183,10 +219,15 @@
 			buildActionMask = 2147483647;
 			files = (
 				931AA5AE1E218D0E003A2290 /* Entry.xib in Resources */,
+				93075C721E59D06900396389 /* RowBlog.xib in Resources */,
 				93B84BA71D9C31AB006C0F67 /* LaunchScreen.storyboard in Resources */,
+				93BAD2F61E586310009DF853 /* RowHomeSocial.xib in Resources */,
+				93BAD2F21E585E88009DF853 /* RowHomeFutureActivities.xib in Resources */,
 				931AA5B01E219006003A2290 /* RowHomePastActivities.xib in Resources */,
 				93D9EA601DE271E700089002 /* Section.xib in Resources */,
+				93075C6A1E59CAB000396389 /* BlogView.xib in Resources */,
 				93B84BA41D9C31AB006C0F67 /* Assets.xcassets in Resources */,
+				93BAD2EE1E585578009DF853 /* RowHomeBlog.xib in Resources */,
 				93B84B9F1D9C31AB006C0F67 /* Main.storyboard in Resources */,
 				93D9EA6C1DE3498500089002 /* HomeView.xib in Resources */,
 			);
@@ -200,16 +241,23 @@
 			buildActionMask = 2147483647;
 			files = (
 				93294FF81E336FA000FDAF50 /* Entry.swift in Sources */,
+				937EA02D1E5B8B5300D0893A /* UIApplcation.swift in Sources */,
 				93D9EA641DE273FD00089002 /* Section.swift in Sources */,
 				93D9EA6A1DE3491100089002 /* HomeView.swift in Sources */,
+				93BEB6D21E7E878300C68DE5 /* PostViewController.swift in Sources */,
+				93BAD2F81E586741009DF853 /* RowHomeSocial.swift in Sources */,
+				93BAD2F01E585662009DF853 /* RowHomeBlog.swift in Sources */,
 				93294FFA1E337D0D00FDAF50 /* RowHomePastActivities.swift in Sources */,
 				935892D01E493C2300E1CD5F /* UIImageView.swift in Sources */,
 				93D9EA761DE3ACBB00089002 /* Sync.swift in Sources */,
+				93BAD2F41E585EE6009DF853 /* RowHomeFutureActivities.swift in Sources */,
 				931AA5891E1AFF8C003A2290 /* String.swift in Sources */,
 				93B84B9C1D9C31AB006C0F67 /* ViewController.swift in Sources */,
+				93075C6C1E59CB6B00396389 /* BlogView.swift in Sources */,
 				93B84B9A1D9C31AB006C0F67 /* AppDelegate.swift in Sources */,
 				93B84BA21D9C31AB006C0F67 /* app.xcdatamodeld in Sources */,
 				93D9EA681DE342AC00089002 /* UIView.swift in Sources */,
+				93075C701E59D04A00396389 /* RowBlog.swift in Sources */,
 				93B408031D9ED44C000FBC99 /* MenuCollectionViewCell.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

+ 3 - 0
app/AppDelegate.swift

@@ -25,6 +25,8 @@ import CoreData
 class AppDelegate: UIResponder, UIApplicationDelegate {
 
 	var window: UIWindow?
+	
+	var controller: ViewController?
 
 	
 
@@ -120,5 +122,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
 			}
 		}
 	}
+	
 }
 

+ 6 - 0
app/Assets.xcassets/Social/Contents.json

@@ -0,0 +1,6 @@
+{
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

+ 23 - 0
app/Assets.xcassets/Social/Facebook.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_facebook.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_facebook-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_facebook-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Facebook.imageset/social_facebook-1.png


BIN
app/Assets.xcassets/Social/Facebook.imageset/social_facebook-2.png


BIN
app/Assets.xcassets/Social/Facebook.imageset/social_facebook.png


+ 23 - 0
app/Assets.xcassets/Social/GooglePlus.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_googleplus.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_googleplus-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_googleplus-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/GooglePlus.imageset/social_googleplus-1.png


BIN
app/Assets.xcassets/Social/GooglePlus.imageset/social_googleplus-2.png


BIN
app/Assets.xcassets/Social/GooglePlus.imageset/social_googleplus.png


+ 23 - 0
app/Assets.xcassets/Social/Instagram.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_instagram.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_instagram-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_instagram-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Instagram.imageset/social_instagram-1.png


BIN
app/Assets.xcassets/Social/Instagram.imageset/social_instagram-2.png


BIN
app/Assets.xcassets/Social/Instagram.imageset/social_instagram.png


+ 23 - 0
app/Assets.xcassets/Social/Mail.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_mail.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_mail-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_mail-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Mail.imageset/social_mail-1.png


BIN
app/Assets.xcassets/Social/Mail.imageset/social_mail-2.png


BIN
app/Assets.xcassets/Social/Mail.imageset/social_mail.png


+ 23 - 0
app/Assets.xcassets/Social/Phone.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_phone.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_phone-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_phone-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Phone.imageset/social_phone-1.png


BIN
app/Assets.xcassets/Social/Phone.imageset/social_phone-2.png


BIN
app/Assets.xcassets/Social/Phone.imageset/social_phone.png


+ 23 - 0
app/Assets.xcassets/Social/Twitter.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_twitter.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_twitter-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_twitter-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Twitter.imageset/social_twitter-1.png


BIN
app/Assets.xcassets/Social/Twitter.imageset/social_twitter-2.png


BIN
app/Assets.xcassets/Social/Twitter.imageset/social_twitter.png


+ 23 - 0
app/Assets.xcassets/Social/Whatsapp.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_whatsapp.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_whatsapp-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_whatsapp-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Whatsapp.imageset/social_whatsapp-1.png


BIN
app/Assets.xcassets/Social/Whatsapp.imageset/social_whatsapp-2.png


BIN
app/Assets.xcassets/Social/Whatsapp.imageset/social_whatsapp.png


+ 23 - 0
app/Assets.xcassets/Social/Youtube.imageset/Contents.json

@@ -0,0 +1,23 @@
+{
+  "images" : [
+    {
+      "idiom" : "universal",
+      "filename" : "social_youtube.png",
+      "scale" : "1x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_youtube-1.png",
+      "scale" : "2x"
+    },
+    {
+      "idiom" : "universal",
+      "filename" : "social_youtube-2.png",
+      "scale" : "3x"
+    }
+  ],
+  "info" : {
+    "version" : 1,
+    "author" : "xcode"
+  }
+}

BIN
app/Assets.xcassets/Social/Youtube.imageset/social_youtube-1.png


BIN
app/Assets.xcassets/Social/Youtube.imageset/social_youtube-2.png


BIN
app/Assets.xcassets/Social/Youtube.imageset/social_youtube.png


+ 223 - 7
app/Base.lproj/Main.storyboard

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
     <device id="retina4_0" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -7,6 +7,7 @@
         <deployment identifier="iOS"/>
         <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
         <capability name="Constraints to layout margins" minToolsVersion="6.0"/>
+        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <scenes>
@@ -23,10 +24,10 @@
                 <placeholder placeholderIdentifier="IBFirstResponder" id="utt-1m-pei" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
         </scene>
-        <!--Gasteizko Margolariak-->
+        <!--GMViewController-->
         <scene sceneID="tne-QT-ifu">
             <objects>
-                <viewController title="Gasteizko Margolariak" id="BYZ-38-t0r" customClass="ViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
+                <viewController storyboardIdentifier="GMViewController" title="Gasteizko Margolariak" useStoryboardIdentifierAsRestorationIdentifier="YES" id="BYZ-38-t0r" userLabel="GMViewController" customClass="ViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="y3c-jy-aDJ"/>
                         <viewControllerLayoutGuide type="bottom" id="wfy-db-euE"/>
@@ -63,7 +64,7 @@
                                 </collectionViewFlowLayout>
                                 <cells>
                                     <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="cell" id="a4j-DF-epb" customClass="MenuCollectionViewCell" customModule="app" customModuleProvider="target">
-                                        <rect key="frame" x="0.0" y="-2.5" width="100" height="50"/>
+                                        <rect key="frame" x="0.0" y="-3" width="100" height="50"/>
                                         <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
                                         <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
                                             <rect key="frame" x="0.0" y="0.0" width="100" height="50"/>
@@ -184,6 +185,7 @@
                         <outlet property="containerViewHome" destination="FfD-xR-Ufj" id="EtF-qz-vWE"/>
                         <outlet property="containerViewLablanca" destination="nhy-Gy-cgq" id="bBa-2W-hjf"/>
                         <outlet property="containerViewLocation" destination="T4H-Rn-I4y" id="EFa-Km-WuR"/>
+                        <segue destination="UkS-wI-Yhx" kind="show" identifier="SeguePost" id="gs2-jd-cPW"/>
                     </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
@@ -270,15 +272,15 @@
                         <viewControllerLayoutGuide type="top" id="yir-Ne-huf"/>
                         <viewControllerLayoutGuide type="bottom" id="126-8G-plw"/>
                     </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="c4t-ul-w0Z">
+                    <view key="view" contentMode="scaleToFill" id="c4t-ul-w0Z" customClass="BlogView" customModule="app" customModuleProvider="target">
                         <rect key="frame" x="0.0" y="0.0" width="320" height="458"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
-                        <color key="backgroundColor" red="1" green="0.33842284866451022" blue="0.42972784824945376" alpha="1" colorSpace="calibratedRGB"/>
+                        <color key="backgroundColor" red="0.70980392156862748" green="0.82745098039215681" blue="0.89803921568627454" alpha="1" colorSpace="calibratedRGB"/>
                     </view>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="iDB-bY-1MG" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>
-            <point key="canvasLocation" x="1643" y="1803"/>
+            <point key="canvasLocation" x="2081" y="2157"/>
         </scene>
         <!--Gallery-->
         <scene sceneID="Uqp-if-ZuD">
@@ -298,5 +300,219 @@
             </objects>
             <point key="canvasLocation" x="1509" y="576"/>
         </scene>
+        <!--Post-->
+        <scene sceneID="zgg-Cx-j75">
+            <objects>
+                <viewController title="Post" id="UkS-wI-Yhx" customClass="PostViewController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
+                    <layoutGuides>
+                        <viewControllerLayoutGuide type="top" id="yy6-d2-MRo"/>
+                        <viewControllerLayoutGuide type="bottom" id="IxZ-up-5UO"/>
+                    </layoutGuides>
+                    <view key="view" autoresizesSubviews="NO" contentMode="scaleToFill" id="mCJ-K1-jG1" userLabel="Container">
+                        <rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
+                        <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+                        <subviews>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="arX-Be-0iS" userLabel="Toolbar">
+                                <rect key="frame" x="0.0" y="20" width="320" height="30"/>
+                                <subviews>
+                                    <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="029-px-JqL">
+                                        <rect key="frame" x="0.0" y="0.0" width="48" height="30"/>
+                                        <fontDescription key="fontDescription" type="boldSystem" pointSize="15"/>
+                                        <state key="normal" title="&lt;">
+                                            <color key="titleColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                        </state>
+                                    </button>
+                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Gasteizko Margolariak" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="BIE-D1-hCZ">
+                                        <rect key="frame" x="48" y="-0.5" width="224" height="30"/>
+                                        <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
+                                        <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                        <nil key="highlightedColor"/>
+                                    </label>
+                                </subviews>
+                                <color key="backgroundColor" red="0.0" green="0.47843137250000001" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                <constraints>
+                                    <constraint firstItem="BIE-D1-hCZ" firstAttribute="height" secondItem="arX-Be-0iS" secondAttribute="height" id="6Ck-IY-1CK"/>
+                                    <constraint firstItem="029-px-JqL" firstAttribute="centerY" secondItem="arX-Be-0iS" secondAttribute="centerY" id="Es5-Zm-aQk"/>
+                                    <constraint firstItem="BIE-D1-hCZ" firstAttribute="centerY" secondItem="arX-Be-0iS" secondAttribute="centerY" id="PkD-5w-aPZ"/>
+                                    <constraint firstItem="029-px-JqL" firstAttribute="height" secondItem="arX-Be-0iS" secondAttribute="height" id="RTL-TJ-15M"/>
+                                    <constraint firstItem="BIE-D1-hCZ" firstAttribute="width" secondItem="arX-Be-0iS" secondAttribute="width" multiplier="0.7" id="UOQ-6G-qoP"/>
+                                    <constraint firstItem="029-px-JqL" firstAttribute="width" secondItem="arX-Be-0iS" secondAttribute="width" multiplier="0.15" id="VYu-Jc-ahB"/>
+                                    <constraint firstItem="029-px-JqL" firstAttribute="leading" secondItem="arX-Be-0iS" secondAttribute="leading" id="o0K-dB-meB"/>
+                                    <constraint firstItem="BIE-D1-hCZ" firstAttribute="centerX" secondItem="arX-Be-0iS" secondAttribute="centerX" id="zrK-6B-Gff"/>
+                                </constraints>
+                            </view>
+                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jx5-wy-ab4">
+                                <rect key="frame" x="0.0" y="50" width="320" height="518"/>
+                                <subviews>
+                                    <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" bounces="NO" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="14b-YG-Iyb">
+                                        <rect key="frame" x="0.0" y="0.0" width="320" height="518"/>
+                                        <subviews>
+                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="yIU-b9-Dc5" userLabel="Section">
+                                                <rect key="frame" x="10" y="10" width="300" height="995"/>
+                                                <subviews>
+                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" restorationIdentifier="Title" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tRk-Ti-VOu" userLabel="Title">
+                                                        <rect key="frame" x="0.0" y="0.0" width="300" height="30"/>
+                                                        <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                        <constraints>
+                                                            <constraint firstAttribute="height" constant="30" id="pTS-D5-LUl"/>
+                                                        </constraints>
+                                                        <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
+                                                        <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                        <nil key="highlightedColor"/>
+                                                    </label>
+                                                    <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="bSp-Sd-3qA" userLabel="Content">
+                                                        <rect key="frame" x="0.0" y="30" width="300" height="965"/>
+                                                        <subviews>
+                                                            <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="7t9-eQ-KC7" userLabel="Post">
+                                                                <rect key="frame" x="8" y="8" width="284" height="949"/>
+                                                                <subviews>
+                                                                    <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="u3M-mi-Tyn" userLabel="Image">
+                                                                        <rect key="frame" x="0.0" y="10" width="284" height="71"/>
+                                                                        <constraints>
+                                                                            <constraint firstAttribute="height" constant="71" id="fQp-wR-eLU"/>
+                                                                        </constraints>
+                                                                    </imageView>
+                                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Text" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2i2-HF-HyI" userLabel="Text">
+                                                                        <rect key="frame" x="14" y="91" width="256" height="826"/>
+                                                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                                        <nil key="textColor"/>
+                                                                        <nil key="highlightedColor"/>
+                                                                    </label>
+                                                                    <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="tAc-xa-mg2" userLabel="Separator">
+                                                                        <rect key="frame" x="14" y="917" width="256" height="2"/>
+                                                                        <color key="backgroundColor" white="0.33333333333333331" alpha="1" colorSpace="calibratedWhite"/>
+                                                                        <constraints>
+                                                                            <constraint firstAttribute="height" constant="2" id="TTW-wU-fHT"/>
+                                                                        </constraints>
+                                                                    </view>
+                                                                    <label opaque="NO" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="254" text="Date" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pX4-mq-dj0" userLabel="Date">
+                                                                        <rect key="frame" x="14" y="929" width="256" height="20"/>
+                                                                        <constraints>
+                                                                            <constraint firstAttribute="height" constant="20" id="Qos-eG-WmY"/>
+                                                                        </constraints>
+                                                                        <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                                                        <nil key="textColor"/>
+                                                                        <nil key="highlightedColor"/>
+                                                                    </label>
+                                                                </subviews>
+                                                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                                                <constraints>
+                                                                    <constraint firstItem="u3M-mi-Tyn" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" id="4ZF-fF-btB"/>
+                                                                    <constraint firstItem="tAc-xa-mg2" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="Bf4-vV-UnB"/>
+                                                                    <constraint firstItem="pX4-mq-dj0" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" multiplier="0.9" id="Dqr-hS-PV9"/>
+                                                                    <constraint firstItem="2i2-HF-HyI" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="Hoe-4Q-YTi"/>
+                                                                    <constraint firstItem="pX4-mq-dj0" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="U33-D3-0dG"/>
+                                                                    <constraint firstItem="2i2-HF-HyI" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" multiplier="0.9" id="dcP-of-FdV"/>
+                                                                    <constraint firstItem="2i2-HF-HyI" firstAttribute="top" secondItem="u3M-mi-Tyn" secondAttribute="bottom" constant="10" id="enp-lt-dAC"/>
+                                                                    <constraint firstItem="u3M-mi-Tyn" firstAttribute="centerX" secondItem="7t9-eQ-KC7" secondAttribute="centerX" id="gd8-xG-NLo"/>
+                                                                    <constraint firstItem="tAc-xa-mg2" firstAttribute="width" secondItem="7t9-eQ-KC7" secondAttribute="width" multiplier="0.9" id="h9c-Tr-HaL"/>
+                                                                    <constraint firstItem="u3M-mi-Tyn" firstAttribute="top" secondItem="7t9-eQ-KC7" secondAttribute="top" constant="10" id="ilB-HA-43E"/>
+                                                                    <constraint firstAttribute="bottom" secondItem="pX4-mq-dj0" secondAttribute="bottom" id="j3Q-f8-ncG"/>
+                                                                    <constraint firstItem="tAc-xa-mg2" firstAttribute="top" secondItem="2i2-HF-HyI" secondAttribute="bottom" id="sQe-ZF-dDj"/>
+                                                                    <constraint firstItem="pX4-mq-dj0" firstAttribute="top" secondItem="tAc-xa-mg2" secondAttribute="bottom" constant="10" id="y6S-1C-uEC"/>
+                                                                </constraints>
+                                                                <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                                                <userDefinedRuntimeAttributes>
+                                                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                                        <color key="value" red="0.42745098040000001" green="0.41176470590000003" blue="0.56470588239999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                                        <real key="value" value="1"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                    <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                                        <real key="value" value="3"/>
+                                                                    </userDefinedRuntimeAttribute>
+                                                                </userDefinedRuntimeAttributes>
+                                                            </view>
+                                                        </subviews>
+                                                        <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                        <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                                    </stackView>
+                                                </subviews>
+                                                <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                                                <constraints>
+                                                    <constraint firstItem="bSp-Sd-3qA" firstAttribute="width" secondItem="yIU-b9-Dc5" secondAttribute="width" id="48B-MC-FiI"/>
+                                                    <constraint firstItem="tRk-Ti-VOu" firstAttribute="width" secondItem="yIU-b9-Dc5" secondAttribute="width" id="8hp-PL-zs2"/>
+                                                    <constraint firstAttribute="bottom" secondItem="bSp-Sd-3qA" secondAttribute="bottom" id="AmB-6T-H8u"/>
+                                                    <constraint firstItem="tRk-Ti-VOu" firstAttribute="centerX" secondItem="yIU-b9-Dc5" secondAttribute="centerX" id="GLO-lV-zKm"/>
+                                                    <constraint firstItem="tRk-Ti-VOu" firstAttribute="top" secondItem="yIU-b9-Dc5" secondAttribute="top" id="kvI-es-Bmu"/>
+                                                    <constraint firstItem="bSp-Sd-3qA" firstAttribute="centerX" secondItem="yIU-b9-Dc5" secondAttribute="centerX" id="obg-Sv-CD5"/>
+                                                    <constraint firstItem="bSp-Sd-3qA" firstAttribute="top" secondItem="tRk-Ti-VOu" secondAttribute="bottom" id="wkt-kn-ZPO"/>
+                                                </constraints>
+                                                <edgeInsets key="layoutMargins" top="10" left="10" bottom="10" right="10"/>
+                                                <userDefinedRuntimeAttributes>
+                                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                                        <color key="value" red="0.0" green="0.0" blue="0.066666666669999999" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                                    </userDefinedRuntimeAttribute>
+                                                    <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                        <real key="value" value="1"/>
+                                                    </userDefinedRuntimeAttribute>
+                                                    <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                                        <real key="value" value="8"/>
+                                                    </userDefinedRuntimeAttribute>
+                                                </userDefinedRuntimeAttributes>
+                                            </view>
+                                        </subviews>
+                                        <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                        <constraints>
+                                            <constraint firstItem="yIU-b9-Dc5" firstAttribute="top" secondItem="14b-YG-Iyb" secondAttribute="top" constant="10" id="56X-pA-LLg"/>
+                                            <constraint firstItem="yIU-b9-Dc5" firstAttribute="trailing" secondItem="14b-YG-Iyb" secondAttribute="trailing" constant="10" id="8Xl-m3-1Xk"/>
+                                            <constraint firstItem="yIU-b9-Dc5" firstAttribute="centerX" secondItem="14b-YG-Iyb" secondAttribute="centerX" id="8oz-7C-ZSn"/>
+                                            <constraint firstAttribute="bottom" secondItem="yIU-b9-Dc5" secondAttribute="bottom" constant="10" id="BC1-pI-UDI"/>
+                                            <constraint firstItem="yIU-b9-Dc5" firstAttribute="leading" secondItem="14b-YG-Iyb" secondAttribute="leading" constant="10" id="SDQ-gY-p6d"/>
+                                        </constraints>
+                                        <edgeInsets key="layoutMargins" top="10" left="10" bottom="10" right="10"/>
+                                        <userDefinedRuntimeAttributes>
+                                            <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                                <real key="value" value="0.0"/>
+                                            </userDefinedRuntimeAttribute>
+                                        </userDefinedRuntimeAttributes>
+                                    </scrollView>
+                                </subviews>
+                                <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+                                <constraints>
+                                    <constraint firstItem="14b-YG-Iyb" firstAttribute="top" secondItem="jx5-wy-ab4" secondAttribute="top" id="H0N-Z2-1N1"/>
+                                    <constraint firstItem="14b-YG-Iyb" firstAttribute="width" secondItem="jx5-wy-ab4" secondAttribute="width" id="UPZ-Yz-bgJ"/>
+                                    <constraint firstAttribute="bottom" secondItem="14b-YG-Iyb" secondAttribute="bottom" id="ht1-9m-ecR"/>
+                                    <constraint firstItem="14b-YG-Iyb" firstAttribute="centerX" secondItem="jx5-wy-ab4" secondAttribute="centerX" id="tgi-xm-huK"/>
+                                </constraints>
+                                <userDefinedRuntimeAttributes>
+                                    <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                        <color key="value" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                    </userDefinedRuntimeAttribute>
+                                </userDefinedRuntimeAttributes>
+                            </view>
+                        </subviews>
+                        <color key="backgroundColor" red="0.70980392160000005" green="0.82745098039999998" blue="0.8980392157" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                        <constraints>
+                            <constraint firstItem="jx5-wy-ab4" firstAttribute="centerX" secondItem="mCJ-K1-jG1" secondAttribute="centerX" id="5lE-sn-JIj"/>
+                            <constraint firstItem="arX-Be-0iS" firstAttribute="top" secondItem="yy6-d2-MRo" secondAttribute="bottom" id="SYd-o2-Nm3"/>
+                            <constraint firstItem="jx5-wy-ab4" firstAttribute="top" secondItem="arX-Be-0iS" secondAttribute="bottom" id="i80-pQ-ZU9"/>
+                            <constraint firstItem="arX-Be-0iS" firstAttribute="centerX" secondItem="mCJ-K1-jG1" secondAttribute="centerX" id="jAL-9l-RFi"/>
+                            <constraint firstItem="jx5-wy-ab4" firstAttribute="width" secondItem="mCJ-K1-jG1" secondAttribute="width" id="lZY-vh-Ap2"/>
+                            <constraint firstItem="arX-Be-0iS" firstAttribute="width" secondItem="mCJ-K1-jG1" secondAttribute="width" id="r1S-WW-h1K"/>
+                            <constraint firstAttribute="bottom" secondItem="jx5-wy-ab4" secondAttribute="bottom" id="xI7-lL-Xhw"/>
+                        </constraints>
+                        <userDefinedRuntimeAttributes>
+                            <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                <real key="value" value="0.0"/>
+                            </userDefinedRuntimeAttribute>
+                        </userDefinedRuntimeAttributes>
+                    </view>
+                    <connections>
+                        <outlet property="barButton" destination="029-px-JqL" id="48Y-ht-xLk"/>
+                        <outlet property="barTitle" destination="BIE-D1-hCZ" id="Fwf-72-Zfe"/>
+                        <outlet property="postImage" destination="u3M-mi-Tyn" id="usY-gh-LBn"/>
+                        <outlet property="postText" destination="2i2-HF-HyI" id="Mmz-c2-N6D"/>
+                        <outlet property="postTitle" destination="tRk-Ti-VOu" id="7kU-Dg-MLX"/>
+                    </connections>
+                </viewController>
+                <placeholder placeholderIdentifier="IBFirstResponder" id="r4n-Sk-nt4" userLabel="First Responder" sceneMemberID="firstResponder"/>
+            </objects>
+            <point key="canvasLocation" x="-728" y="1744"/>
+        </scene>
     </scenes>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
 </document>

+ 203 - 0
app/BlogView.swift

@@ -0,0 +1,203 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import Foundation
+import CoreData
+import UIKit
+/**
+Class to handle the home view.
+*/
+class BlogView: UIView {
+	
+	//var window:UIWindow?
+	
+	//The main scroll view.
+	@IBOutlet weak var scrollView: UIScrollView!
+	
+	//The container of the view.
+	@IBOutlet var container: UIView!
+	
+	//Each of the sections of the view.
+	@IBOutlet weak var section: Section!
+	
+	//var controller : ViewController
+	
+	var delegate: AppDelegate? = nil
+	
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+	/**
+	Run when the view is started.
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		
+		super.init(coder: aDecoder)
+		
+		print("BLOG:DEBUG: init.")
+		
+		//Load the contents of the HomeView.xib file.
+		Bundle.main.loadNibNamed("BlogView", owner: self, options: nil)
+		self.addSubview(container)
+		container.frame = self.bounds
+		section.setTitle(text: "Blog")
+		let parent = section.getContentStack()
+		
+		// Get viewController from StoryBoard
+		let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
+		let controller = storyboard.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
+		
+		// Show posts
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		self.delegate = appDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
+		let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
+		let sortDescriptors = [sortDescriptor]
+		fetchRequest.sortDescriptors = sortDescriptors
+		
+		do {
+			//go get the results
+			let searchResults = try context.fetch(fetchRequest)
+			
+			//I like to check the size of the returned results!
+			print ("BLOG:DEBUG: Total posts: \(searchResults.count)")
+			
+			var row : RowBlog
+			var count = 0
+			var id: Int
+			var title: String
+			var text: String
+			var image: String
+			
+			//You need to convert to NSManagedObject to use 'for' loops
+			for r in searchResults as [NSManagedObject] {
+				count = count + 1
+				//get the Key Value pairs (although there may be a better way to do that...
+				print("BLOG:DEBUG: Post perm: \(r.value(forKey: "permalink"))")
+				
+				
+				//Create a new row
+				row = RowBlog.init(s: "rowBlog\(count)", i: count)
+				id = r.value(forKey: "id")! as! Int
+				title = r.value(forKey: "title_\(lang)")! as! String
+				text = r.value(forKey: "text_\(lang)")! as! String
+				row.setTitle(text: title)
+				row.setText(text: text)
+				
+				// Get main image
+				image = ""
+				let imgFetchRequest: NSFetchRequest<Post_image> = Post_image.fetchRequest()
+				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
+				let imgSortDescriptors = [imgSortDescriptor]
+				imgFetchRequest.sortDescriptors = imgSortDescriptors
+				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
+				imgFetchRequest.fetchLimit = 1
+				do{
+					let imgSearchResults = try context.fetch(imgFetchRequest)
+					for imgR in imgSearchResults as [NSManagedObject]{
+						image = imgR.value(forKey: "image")! as! String
+						print ("BLOG:DEBUG: Image: \(image)")
+						row.setImage(filename: image)
+					}
+				} catch {
+					print("BLOG:ERROR: Error getting image for post \(id): \(error)")
+				}
+				
+				print("BLOG:DEBUG: Row height: \(row.frame.height)")
+				
+				parent.addArrangedSubview(row)
+				row.setNeedsLayout()
+				row.layoutIfNeeded()
+				
+				// TODO: Do this on the row didLoad method
+				// Set tap recognizer
+				//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
+				//row.isUserInteractionEnabled = true
+				//row.addGestureRecognizer(tapRecognizer)
+				
+				
+				
+			}
+		} catch {
+			print("BLOG:ERROR: Error with request: \(error)")
+		}
+		
+		//Always at the end: update scrollview
+		var h: Int = 0
+		for view in scrollView.subviews {
+			//contentRect = contentRect.union(view.frame);
+			h = h + Int(view.frame.height) + 30 //Why 30?
+			print("BLOG:DEBUG: curh: \(h)")
+		}
+		// TODO: Calculate at the end
+		self.scrollView.contentSize.height = 2500//CGFloat(h);
+		
+		// The view controller
+		//var viewController: ViewController  = self.window?.rootViewController as! ViewController
+		
+		
+		//let viewController = UIApplication.topViewController() as! ViewController
+		
+		//viewController.showPost(id: 4)
+		
+		//print("BLOG:DEBUG: Show post on load.")
+		//self.delegate?.controller?.showPost(id: 4)
+		
+		//controller.showPost(id: 4)
+		
+		
+		
+		
+		print("BLOG:DEBUG: Finished loading BlogView")
+	}
+	
+	/*func openPost(){//(_ sender:UITapGestureRecognizer? = nil){
+		print("BLOG:DEBUG: getting delegate and showing post.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPost(id: 4)
+		print("BLOG:DEBUG: Post should be shown.")
+	}
+	
+	func openPost(_ sender:UITapGestureRecognizer? = nil){
+		print("BLOG:DEBUG: getting delegate and showing post.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPost(id: 4)
+		print("BLOG:DEBUG: Post should be shown.")
+	}*/
+	
+	func getLanguage() -> String{
+		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
+		if(pre == "es" || pre == "en" || pre == "eu"){
+			return pre
+		}
+		else{
+			return "es"
+		}
+	}
+	
+	func setController(controller: ViewController){
+		
+		//self.controller = controller
+	}
+}

+ 61 - 0
app/BlogView.xib

@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16D32" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina3_5" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="BlogView" customModule="app">
+            <connections>
+                <outlet property="container" destination="iN0-l3-epB" id="Nzq-0W-kDj"/>
+                <outlet property="scrollView" destination="V2d-fd-cjO" id="0Px-EW-La0"/>
+                <outlet property="section" destination="xlt-p5-m6w" id="ITl-k7-X4B"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="Container">
+            <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="V2d-fd-cjO">
+                    <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+                    <subviews>
+                        <stackView contentMode="scaleToFill" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Iqa-PQ-TOo">
+                            <rect key="frame" x="0.0" y="0.0" width="320" height="2200"/>
+                            <subviews>
+                                <view autoresizesSubviews="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="xlt-p5-m6w" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="0.0" width="320" height="2200"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="2200" id="dig-UC-mt1" userLabel="height = 2200"/>
+                                    </constraints>
+                                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                </view>
+                            </subviews>
+                            <constraints>
+                                <constraint firstItem="xlt-p5-m6w" firstAttribute="top" secondItem="Iqa-PQ-TOo" secondAttribute="top" id="ARG-5x-hIU"/>
+                                <constraint firstAttribute="bottom" secondItem="xlt-p5-m6w" secondAttribute="bottom" id="EIU-Wo-4hn"/>
+                                <constraint firstAttribute="height" constant="2200" id="FSh-mk-71J"/>
+                            </constraints>
+                        </stackView>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="Iqa-PQ-TOo" firstAttribute="top" secondItem="V2d-fd-cjO" secondAttribute="top" id="JUm-Fl-IMw"/>
+                        <constraint firstAttribute="trailing" secondItem="Iqa-PQ-TOo" secondAttribute="trailing" id="NAr-lB-8Ty"/>
+                        <constraint firstItem="Iqa-PQ-TOo" firstAttribute="leading" secondItem="V2d-fd-cjO" secondAttribute="leading" id="wWa-rA-U3w"/>
+                        <constraint firstAttribute="bottom" secondItem="Iqa-PQ-TOo" secondAttribute="bottom" id="x0w-9j-39f"/>
+                    </constraints>
+                </scrollView>
+            </subviews>
+            <constraints>
+                <constraint firstItem="V2d-fd-cjO" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="JsC-UU-8eB"/>
+                <constraint firstItem="V2d-fd-cjO" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="bBb-zb-kBf"/>
+                <constraint firstItem="V2d-fd-cjO" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="ddT-DW-Knz"/>
+                <constraint firstItem="V2d-fd-cjO" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="kdV-ei-kvf"/>
+            </constraints>
+        </view>
+    </objects>
+</document>

+ 169 - 5
app/HomeView.swift

@@ -70,15 +70,21 @@ class HomeView: UIView {
 		
 		//Get info to populate sections
 		let moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		moc.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
 		let lang : String = getLanguage()
 		
 		//Populate sections
 		setUpPastActivities(context: moc, delegate: appDelegate, lang: lang, parent: pastActivitiesSection.getContentStack())
+		setUpBlog(context: moc, delegate: appDelegate, lang: lang, parent: blogSection.getContentStack())
+		setUpFutureActivities(context: moc, delegate: appDelegate, lang: lang, parent: futureActivitiesSection.getContentStack())
+		setUpSocial(parent: socialSection.getContentStack())
 		
 		
 		pastActivitiesSection.expandSection()
 		
+		
 		//Always at the end: update scrollview
 		var h: Int = 0
 		for view in scrollView.subviews {
@@ -87,7 +93,7 @@ class HomeView: UIView {
 			print("curh: \(h)")
 		}
 		// TODO: Calculate at the end
-		self.scrollView.contentSize.height = 1200// CGFloat(h);
+		self.scrollView.contentSize.height = 1300// CGFloat(h);
 	}
 	
 	func getLanguage() -> String{
@@ -100,15 +106,156 @@ class HomeView: UIView {
 		}
 	}
 	
+	func setUpFutureActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
+		
+		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
+		let sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
+		let sortDescriptors = [sortDescriptor]
+		fetchRequest.sortDescriptors = sortDescriptors
+		fetchRequest.predicate = NSPredicate(format: "date > %@", NSDate())
+		fetchRequest.fetchLimit = 2
+		
+		do {
+			//go get the results
+			let searchResults = try context.fetch(fetchRequest)
+			
+			//I like to check the size of the returned results!
+			print ("Activities: \(searchResults.count)")
+			
+			var row : RowHomePastActivities
+			var count = 0
+			var id: Int
+			var title: String
+			var text: String
+			var image: String
+			
+			//You need to convert to NSManagedObject to use 'for' loops
+			for r in searchResults as [NSManagedObject] {
+				count = count + 1
+				//get the Key Value pairs (although there may be a better way to do that...
+				print("Perm: \(r.value(forKey: "permalink"))")
+				
+				
+				//Create a new row
+				row = RowHomePastActivities.init(s: "rowHomeFutureActivities\(count)", i: count)
+				id = r.value(forKey: "id")! as! Int
+				title = r.value(forKey: "title_\(lang)")! as! String
+				text = r.value(forKey: "text_\(lang)")! as! String
+				print(title)
+				row.setTitle(text: title)
+				row.setText(text: text)
+				
+				// Get main image
+				image = ""
+				let imgFetchRequest: NSFetchRequest<Activity_image> = Activity_image.fetchRequest()
+				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
+				let imgSortDescriptors = [imgSortDescriptor]
+				imgFetchRequest.sortDescriptors = imgSortDescriptors
+				imgFetchRequest.predicate = NSPredicate(format: "activity == %i", id)
+				imgFetchRequest.fetchLimit = 1
+				do{
+					let imgSearchResults = try context.fetch(imgFetchRequest)
+					for imgR in imgSearchResults as [NSManagedObject]{
+						image = imgR.value(forKey: "image")! as! String
+						print ("IMAGE: \(image)")
+						row.setImage(filename: image)
+					}
+				} catch {
+					print("Error getting image for activity \(id): \(error)")
+				}
+				
+				print("Row height: \(row.frame.height)")
+				
+				parent.addArrangedSubview(row)
+				
+			}
+		} catch {
+			print("Error with request: \(error)")
+		}
+	}
+	
+	func setUpBlog(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
+		
+		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
+		let sortDescriptor = NSSortDescriptor(key: "dtime", ascending: false)
+		let sortDescriptors = [sortDescriptor]
+		fetchRequest.sortDescriptors = sortDescriptors
+		fetchRequest.fetchLimit = 2
+		
+		do {
+			//go get the results
+			let searchResults = try context.fetch(fetchRequest)
+			
+			//I like to check the size of the returned results!
+			print ("Post: \(searchResults.count)")
+			
+			var row : RowHomeBlog
+			var count = 0
+			var id: Int
+			var title: String
+			var text: String
+			var image: String
+			
+			//You need to convert to NSManagedObject to use 'for' loops
+			for r in searchResults as [NSManagedObject] {
+				count = count + 1
+				//get the Key Value pairs (although there may be a better way to do that...
+				print("Perm: \(r.value(forKey: "permalink"))")
+				
+				
+				//Create a new row
+				row = RowHomeBlog.init(s: "rowHomeBlog\(count)", i: count)
+				id = r.value(forKey: "id")! as! Int
+				title = r.value(forKey: "title_\(lang)")! as! String
+				text = r.value(forKey: "text_\(lang)")! as! String
+				
+				row.id = id
+				row.setTitle(text: title)
+				row.setText(text: text)
+				
+				// Get main image
+				image = ""
+				let imgFetchRequest: NSFetchRequest<Post_image> = Post_image.fetchRequest()
+				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
+				let imgSortDescriptors = [imgSortDescriptor]
+				imgFetchRequest.sortDescriptors = imgSortDescriptors
+				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
+				imgFetchRequest.fetchLimit = 1
+				do{
+					let imgSearchResults = try context.fetch(imgFetchRequest)
+					for imgR in imgSearchResults as [NSManagedObject]{
+						image = imgR.value(forKey: "image")! as! String
+						print ("IMAGE: \(image)")
+						row.setImage(filename: image)
+					}
+				} catch {
+					print("Error getting image for post \(id): \(error)")
+				}
+				
+				print("Row height: \(row.frame.height)")
+				
+				parent.addArrangedSubview(row)
+				
+				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
+				row.isUserInteractionEnabled = true
+				row.addGestureRecognizer(tapRecognizer)
+				
+			}
+		} catch {
+			print("Error with request: \(error)")
+		}
+	}
+	
 	func setUpPastActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 		
-		context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
+		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
 		let sortDescriptors = [sortDescriptor]
 		fetchRequest.sortDescriptors = sortDescriptors
-		//TODO Compare dates
-		//fetchRequest.predicate = NSPredicate(format: "date < %@", sysdate)
+		fetchRequest.predicate = NSPredicate(format: "date <= %@", NSDate())
 		fetchRequest.fetchLimit = 2
 		
 		do {
@@ -137,7 +284,8 @@ class HomeView: UIView {
 				id = r.value(forKey: "id")! as! Int
 				title = r.value(forKey: "title_\(lang)")! as! String
 				text = r.value(forKey: "text_\(lang)")! as! String
-				print(title)
+				
+				
 				row.setTitle(text: title)
 				row.setText(text: text)
 				
@@ -169,4 +317,20 @@ class HomeView: UIView {
 			print("Error with request: \(error)")
 		}
 	}
+	
+	func setUpSocial(parent : UIStackView){
+		print("SETING UP SOCIAL")
+		//Create a new row
+		var row : RowHomeSocial
+		row = RowHomeSocial.init(s: "rowHomeSocial", i: 0)
+		print("ROW CREATED")
+		parent.addArrangedSubview(row)
+	}
+	
+	func openPost(_ sender:UITapGestureRecognizer? = nil){
+		print("HOME:DEBUG: getting delegate and showing post.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showPost(id: (sender?.view as! RowHomeBlog).id)
+		print("HOME:DEBUG: Post should be shown.")
+	}
 }

+ 17 - 17
app/HomeView.xib

@@ -27,37 +27,37 @@
             <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Poy-ba-9jX">
+                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Poy-ba-9jX">
                     <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
                     <subviews>
-                        <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="gOz-rr-CeQ">
-                            <rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
+                        <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="gOz-rr-CeQ">
+                            <rect key="frame" x="0.0" y="0.0" width="320" height="780"/>
                             <subviews>
-                                <view autoresizesSubviews="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Ljm-NP-c4e" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="0.0"/>
+                                <view autoresizesSubviews="NO" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ljm-NP-c4e" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="0.0" width="320" height="50"/>
                                 </view>
-                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9nu-j1-wGI" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="0.0"/>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9nu-j1-wGI" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="60" width="320" height="50"/>
                                 </view>
-                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="FQo-nm-4Mo" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="0.0"/>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="FQo-nm-4Mo" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="120" width="320" height="50"/>
                                 </view>
-                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="uHa-Mu-U68" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="0.0"/>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="uHa-Mu-U68" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="180" width="320" height="50"/>
                                 </view>
-                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="v6A-Ya-esA" customClass="Section" customModule="app" customModuleProvider="target">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="10"/>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="v6A-Ya-esA" customClass="Section" customModule="app" customModuleProvider="target">
+                                    <rect key="frame" x="0.0" y="240" width="320" height="50"/>
                                 </view>
-                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fZk-r1-Tca" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="10" width="320" height="350"/>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fZk-r1-Tca" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="300" width="320" height="350"/>
                                     <userDefinedRuntimeAttributes>
                                         <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
                                             <real key="value" value="0.0"/>
                                         </userDefinedRuntimeAttribute>
                                     </userDefinedRuntimeAttributes>
                                 </view>
-                                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="dgk-s8-xje" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="360" width="320" height="120"/>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dgk-s8-xje" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="660" width="320" height="120"/>
                                 </view>
                             </subviews>
                             <color key="backgroundColor" red="1" green="1" blue="0.42787000868055558" alpha="1" colorSpace="calibratedRGB"/>

+ 158 - 0
app/PostViewController.swift

@@ -0,0 +1,158 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import UIKit
+import CoreData
+
+/**
+The view controller of the app.
+*/
+class PostViewController: UIViewController, UIGestureRecognizerDelegate {
+	
+
+	
+	@IBOutlet weak var barTitle: UILabel!
+	@IBOutlet weak var barButton: UIButton!
+	@IBOutlet weak var postText: UILabel!
+	@IBOutlet weak var postTitle: UILabel!
+	@IBOutlet weak var postImage: UIImageView!
+	var id: Int = -1
+	var delegate: AppDelegate?
+	
+	//Each of the sections of the app.
+	
+	var passId: Int = -1
+	
+	func getContext () -> NSManagedObjectContext {
+		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		//return appDelegate.persistentContainer.viewContext
+		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
+	}
+	
+	/**
+	Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		print("POSTCONTROLLER:LOG: viewDidLoad()")
+		
+		super.viewDidLoad()
+		self.loadPost(id: id)
+		
+		// Set button action
+		barButton.addTarget(self, action: #selector(self.back), for: .touchUpInside)
+	}
+	
+	//TODO implement all the logic for post loading here, including iboutlts
+	
+	
+	func back() {
+		print("POSTCONTROLLER:DEBUG: Back")
+		self.dismiss(animated: true, completion: nil)
+	}
+	
+	
+	/**
+	Dispose of any resources that can be recreated.
+	*/
+	override func didReceiveMemoryWarning() {
+		super.didReceiveMemoryWarning()
+	}
+	
+	public func loadPost(id: Int){
+		
+		print("POSTCONTROLLER:DEBUG: Loading post \(id)")
+		
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let lang : String = getLanguage()
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()
+		fetchRequest.predicate = NSPredicate(format: "id = %i", id)
+		
+		do {
+			//go get the results
+			let searchResults = try context.fetch(fetchRequest)
+			
+			var count = 0
+			var sTitle: String
+			var sText: String
+			var image: String
+			
+			//You need to convert to NSManagedObject to use 'for' loops
+			for r in searchResults as [NSManagedObject] {
+				count = count + 1
+				
+				sTitle = r.value(forKey: "title_\(lang)")! as! String
+				sText = r.value(forKey: "text_\(lang)")! as! String
+				postTitle.text = "  \(sTitle)"
+				postText.text = sText.stripHtml()
+				
+				// Get main image
+				image = ""
+				let imgFetchRequest: NSFetchRequest<Post_image> = Post_image.fetchRequest()
+				let imgSortDescriptor = NSSortDescriptor(key: "idx", ascending: true)
+				let imgSortDescriptors = [imgSortDescriptor]
+				imgFetchRequest.sortDescriptors = imgSortDescriptors
+				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
+				imgFetchRequest.fetchLimit = 1
+				//TODO get more images
+				do{
+					let imgSearchResults = try context.fetch(imgFetchRequest)
+					for imgR in imgSearchResults as [NSManagedObject]{
+						image = imgR.value(forKey: "image")! as! String
+						print ("POST:LOG: Image: \(image)")
+						//TODO set image
+						//row.setImage(filename: image)
+					}
+				} catch {
+					print("POST:ERROR: Error getting image for post \(id): \(error)")
+				}
+				
+			}
+		} catch {
+			print("POST:ERROR: Error with request: \(error)")
+		}
+		
+		//Always at the end: update scrollview
+		// TODOs
+		//var h: Int = 0
+		//for view in scrollView.subviews {
+			//contentRect = contentRect.union(view.frame);
+		//	h = h + Int(view.frame.height) + 30 //Why 30?
+		//}
+		//print("POST:DEBUG: Height: \(h)")
+		// TODO: Calculate at the end
+		//self.scrollView.contentSize.height = 4500//CGFloat(h);
+
+	}
+	
+	func getLanguage() -> String{
+		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
+		if(pre == "es" || pre == "en" || pre == "eu"){
+			return pre
+		}
+		else{
+			return "es"
+		}
+	}
+	
+}
+

+ 130 - 0
app/RowBlog.swift

@@ -0,0 +1,130 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import Foundation
+import UIKit
+
+/**
+Extension of UIView to be formatted as sections.
+*/
+@IBDesignable class RowBlog: UIView {
+	
+	//This view
+	var v: UIView!
+	
+	//The container.
+	@IBOutlet weak var container: UIView!
+	
+	//The entry
+	@IBOutlet weak var entry: UIView!
+
+	//The post title.
+	@IBOutlet weak var title: UILabel!
+	
+	//The post description.
+	@IBOutlet weak var descrip: UILabel!
+
+	//The post image.
+	@IBOutlet weak var image: UIImageView!
+	
+	/**
+	Default constructor
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+	}
+	
+	private func loadViewFromNib() {
+		let bundle = Bundle(for: type(of: self))
+		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
+	}
+	
+	/**
+	Default constructor.
+	:param: s Custom identifier
+	:param: i Custom identifier
+	*/
+	init(s: String, i: Int) {
+		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
+		loadViewFromNib()
+		v = self
+		v.frame = bounds
+		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		v.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = v.bounds
+		v.addSubview(container)
+		
+		// Set tap recognizer
+		/*print("ROW_BLOG:DEBUG: set tap recognizer")
+		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (self.openPost (_:)))
+		tapRecognizer.delegate = (UIApplication.shared.delegate as! AppDelegate).controller
+		addGestureRecognizer(tapRecognizer)*/
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+
+	
+	/**
+	Changes the title of the post. Decodes HTML.
+	:param: text The new title.
+	*/
+	func setTitle(text: String){
+		title.text = text.stripHtml()
+	}
+	
+	/**
+	Changes the description of the post. Decodes HTML.
+	:param: text The new text.
+	*/
+	func setText(text: String){
+		descrip.text = text.stripHtml()
+	}
+	
+	/**
+	Changes the image of the post.
+	If null or empty, the igage is hidden.
+	:param: path The new text.
+	*/
+	func setImage(filename: String){
+		if (filename == ""){
+			print("No image")
+			//TODO hide the imageview
+		}
+		else{
+			print("Set image \(filename)")
+			let path = "img/blog/thumb/\(filename)"
+			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+		}
+	}
+	
+	func openPost(_ sender:UITapGestureRecognizer? = nil){
+		print("ROW_BLOG:DEBUG: openpost")
+	}
+}

+ 113 - 0
app/RowBlog.xib

@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowBlog" customModule="app" customModuleProvider="target">
+            <connections>
+                <outlet property="container" destination="fIu-6X-Tsy" id="sdT-5k-azi"/>
+                <outlet property="descrip" destination="rzM-vF-gOY" id="uQp-Za-gam"/>
+                <outlet property="entry" destination="b17-mq-rbm" id="3Ac-n2-qLr"/>
+                <outlet property="image" destination="6hA-MD-OsD" id="VNd-1E-Ztc"/>
+                <outlet property="title" destination="WSL-LM-04R" id="qKn-Xk-cEN"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="yLg-4E-qlC" userLabel="RowBlog" customClass="RowBlog" customModule="app">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="fIu-6X-Tsy" userLabel="Container">
+                    <rect key="frame" x="0.0" y="273.5" width="375" height="120"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b17-mq-rbm" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="120"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="WSL-LM-04R" userLabel="Title">
+                                    <rect key="frame" x="10" y="10" width="335" height="22"/>
+                                    <fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+                                    <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="6hA-MD-OsD" userLabel="Image">
+                                    <rect key="frame" x="10" y="40" width="71" height="64"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="64" id="68z-jj-fIa"/>
+                                    </constraints>
+                                </imageView>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="rzM-vF-gOY" userLabel="Text">
+                                    <rect key="frame" x="97" y="40" width="248" height="21"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <nil key="textColor"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                            </subviews>
+                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                            <constraints>
+                                <constraint firstItem="WSL-LM-04R" firstAttribute="top" secondItem="b17-mq-rbm" secondAttribute="top" constant="10" id="4og-BI-wpQ"/>
+                                <constraint firstItem="6hA-MD-OsD" firstAttribute="width" secondItem="b17-mq-rbm" secondAttribute="width" multiplier="0.2" id="BYW-Hr-dje"/>
+                                <constraint firstItem="rzM-vF-gOY" firstAttribute="top" secondItem="b17-mq-rbm" secondAttribute="top" constant="40" id="O3L-O9-b6V"/>
+                                <constraint firstItem="6hA-MD-OsD" firstAttribute="leading" secondItem="b17-mq-rbm" secondAttribute="leading" constant="10" id="gNm-O7-qNU"/>
+                                <constraint firstItem="6hA-MD-OsD" firstAttribute="top" secondItem="b17-mq-rbm" secondAttribute="top" constant="40" id="mvQ-pc-ApL"/>
+                                <constraint firstAttribute="trailing" secondItem="WSL-LM-04R" secondAttribute="trailing" constant="10" id="pco-U6-EWQ"/>
+                                <constraint firstItem="WSL-LM-04R" firstAttribute="leading" secondItem="b17-mq-rbm" secondAttribute="leading" constant="10" id="trs-wK-NuZ"/>
+                                <constraint firstAttribute="trailing" secondItem="rzM-vF-gOY" secondAttribute="trailing" constant="10" id="vlK-IJ-OrY"/>
+                                <constraint firstItem="rzM-vF-gOY" firstAttribute="width" secondItem="b17-mq-rbm" secondAttribute="width" multiplier="0.7" id="ww4-WB-msV"/>
+                            </constraints>
+                            <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                            <userDefinedRuntimeAttributes>
+                                <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                    <color key="value" red="0.42745098040000001" green="0.41176470590000003" blue="0.56470588239999997" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                    <real key="value" value="1"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                    <real key="value" value="3"/>
+                                </userDefinedRuntimeAttribute>
+                            </userDefinedRuntimeAttributes>
+                        </view>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="b17-mq-rbm" firstAttribute="leading" secondItem="fIu-6X-Tsy" secondAttribute="leading" constant="10" id="09K-4S-bco"/>
+                        <constraint firstItem="b17-mq-rbm" firstAttribute="top" secondItem="fIu-6X-Tsy" secondAttribute="top" constant="10" id="DRs-NG-UKY"/>
+                        <constraint firstAttribute="trailing" secondItem="b17-mq-rbm" secondAttribute="trailing" constant="10" id="Qtu-G3-8IH"/>
+                        <constraint firstAttribute="height" constant="120" id="W85-Qc-MWb"/>
+                        <constraint firstItem="b17-mq-rbm" firstAttribute="bottom" secondItem="fIu-6X-Tsy" secondAttribute="bottom" constant="10" id="bcY-vf-soX"/>
+                    </constraints>
+                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                            <real key="value" value="0.0"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </view>
+            </subviews>
+            <constraints>
+                <constraint firstItem="fIu-6X-Tsy" firstAttribute="width" secondItem="yLg-4E-qlC" secondAttribute="width" id="6xh-OR-L3E"/>
+                <constraint firstItem="fIu-6X-Tsy" firstAttribute="centerX" secondItem="yLg-4E-qlC" secondAttribute="centerX" id="Rel-sh-SrL"/>
+                <constraint firstItem="fIu-6X-Tsy" firstAttribute="centerY" secondItem="yLg-4E-qlC" secondAttribute="centerY" id="X8l-Z5-R9M"/>
+            </constraints>
+            <nil key="simulatedStatusBarMetrics"/>
+            <userDefinedRuntimeAttributes>
+                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                    <real key="value" value="0.0"/>
+                </userDefinedRuntimeAttribute>
+            </userDefinedRuntimeAttributes>
+            <connections>
+                <outlet property="image" destination="6hA-MD-OsD" id="AvA-3b-lxb"/>
+            </connections>
+            <point key="canvasLocation" x="45.5" y="-43.5"/>
+        </view>
+    </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
+</document>

+ 120 - 0
app/RowHomeBlog.swift

@@ -0,0 +1,120 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import Foundation
+import UIKit
+
+/**
+Extension of UIView to be formatted as sections.
+*/
+@IBDesignable class RowHomeBlog: UIView {
+	
+	//This view
+	var v: UIView!
+	
+	var id: Int!
+	
+	//The container.
+	@IBOutlet weak var container: UIView!
+	
+	//The entry
+	@IBOutlet weak var entry: UIView!
+	
+	//The post title.
+	@IBOutlet weak var title: UILabel!
+	
+	//The post text.
+	@IBOutlet weak var descrip: UILabel!
+	
+	//The image.
+	@IBOutlet weak var image: UIImageView!
+	
+	/**
+	Default constructor
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+	}
+	
+	private func loadViewFromNib() {
+		let bundle = Bundle(for: type(of: self))
+		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
+	}
+	
+	/**
+	Default constructor.
+	:param: s Custom identifier
+	:param: i Custom identifier
+	*/
+	init(s: String, i: Int) {
+		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
+		loadViewFromNib()
+		v = self
+		v.frame = bounds
+		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		v.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = v.bounds
+		v.addSubview(container)
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+	/**
+	Changes the title of the post. Decodes HTML.
+	:param: text The new title.
+	*/
+	func setTitle(text: String){
+		title.text = text.stripHtml()
+	}
+	
+	/**
+	Changes the text of the text. Decodes HTML.
+	:param: text The new text.
+	*/
+	func setText(text: String){
+		descrip.text = text.stripHtml()
+	}
+	
+	/**
+	Changes the image of the activity.
+	If null or empty, the igage is hidden.
+	:param: path The new text.
+	*/
+	func setImage(filename: String){
+		if (filename == ""){
+			print("No image")
+			//TODO hide the imageview
+		}
+		else{
+			print("Set image \(filename)")
+			let path = "img/blog/thumb/\(filename)"
+			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+		}
+	}
+}

+ 111 - 0
app/RowHomeBlog.xib

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<device id="retina4_7" orientation="portrait">
+<adaptation id="fullscreen"/>
+</device>
+<dependencies>
+<deployment identifier="iOS"/>
+<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+</dependencies>
+<objects>
+<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeBlog" customModule="app">
+<connections>
+<outlet property="container" destination="2hI-rc-KPm" id="rWX-Vl-kOp"/>
+<outlet property="descrip" destination="f4E-5p-Bid" id="IF5-ck-qUL"/>
+<outlet property="entry" destination="wLM-VU-VYk" id="Gkq-yE-fdN"/>
+<outlet property="image" destination="WSe-uz-Uhz" id="iU4-jm-UzQ"/>
+<outlet property="title" destination="Bkz-DV-HVr" id="1ok-yI-Npt"/>
+</connections>
+</placeholder>
+<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+<view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomePastActivities" customClass="RowHomePastActivities" customModule="app">
+<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+<subviews>
+<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
+<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+<subviews>
+<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
+<rect key="frame" x="10" y="10" width="355" height="667"/>
+<subviews>
+<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bkz-DV-HVr" userLabel="Title">
+<rect key="frame" x="10" y="10" width="335" height="21.5"/>
+<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+<color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
+<nil key="highlightedColor"/>
+</label>
+<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
+<rect key="frame" x="10" y="40" width="89" height="64"/>
+<constraints>
+<constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
+</constraints>
+</imageView>
+<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
+<rect key="frame" x="98" y="40" width="214" height="64"/>
+<fontDescription key="fontDescription" type="system" pointSize="17"/>
+<nil key="textColor"/>
+<nil key="highlightedColor"/>
+</label>
+</subviews>
+<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+<constraints>
+<constraint firstItem="WSe-uz-Uhz" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.2" id="9Lz-WQ-1aS"/>
+<constraint firstItem="f4E-5p-Bid" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Emi-Ob-27Q"/>
+<constraint firstItem="Bkz-DV-HVr" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="LSz-FM-x2V"/>
+<constraint firstItem="f4E-5p-Bid" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.7" id="MdM-ps-4b8"/>
+<constraint firstAttribute="trailing" secondItem="Bkz-DV-HVr" secondAttribute="trailing" constant="10" id="MdM-yF-pmK"/>
+<constraint firstItem="WSe-uz-Uhz" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Pyf-oT-PQl"/>
+<constraint firstItem="WSe-uz-Uhz" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="YG6-eX-oTj"/>
+<constraint firstItem="Bkz-DV-HVr" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="10" id="mwG-d2-HQL"/>
+<constraint firstAttribute="trailing" secondItem="f4E-5p-Bid" secondAttribute="trailing" constant="10" id="svU-xx-LsR"/>
+</constraints>
+<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+<userDefinedRuntimeAttributes>
+<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+<color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+</userDefinedRuntimeAttribute>
+<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+<real key="value" value="1"/>
+</userDefinedRuntimeAttribute>
+<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+<real key="value" value="3"/>
+</userDefinedRuntimeAttribute>
+</userDefinedRuntimeAttributes>
+</view>
+</subviews>
+<constraints>
+<constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
+<constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
+<constraint firstAttribute="height" constant="120" id="PdT-5v-I0r"/>
+<constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
+<constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
+</constraints>
+<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+<userDefinedRuntimeAttributes>
+<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+<real key="value" value="0.0"/>
+</userDefinedRuntimeAttribute>
+</userDefinedRuntimeAttributes>
+</view>
+</subviews>
+<constraints>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="Kwy-25-YES"/>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="htS-q0-otF"/>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
+</constraints>
+<nil key="simulatedStatusBarMetrics"/>
+<userDefinedRuntimeAttributes>
+<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+<real key="value" value="0.0"/>
+</userDefinedRuntimeAttribute>
+</userDefinedRuntimeAttributes>
+<point key="canvasLocation" x="45.5" y="-43.5"/>
+</view>
+</objects>
+<resources>
+<image name="PhotoPlaceholder" width="170" height="108"/>
+</resources>
+</document>

+ 118 - 0
app/RowHomeFutureActivities.swift

@@ -0,0 +1,118 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import Foundation
+import UIKit
+
+/**
+Extension of UIView to be formatted as sections.
+*/
+@IBDesignable class RowHomeFutureActivities: UIView {
+	
+	//This view
+	var v: UIView!
+	
+	//The container.
+	@IBOutlet weak var container: UIView!
+	
+	//The entry
+	@IBOutlet weak var entry: UIView!
+	
+	//The activity title.
+	@IBOutlet weak var title: UILabel!
+	
+	//The activity description.
+	@IBOutlet weak var descrip: UILabel!
+	
+	//The activity image.
+	@IBOutlet weak var image: UIImageView!
+	
+	/**
+	Default constructor
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+	}
+	
+	private func loadViewFromNib() {
+		let bundle = Bundle(for: type(of: self))
+		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
+	}
+	
+	/**
+	Default constructor.
+	:param: s Custom identifier
+	:param: i Custom identifier
+	*/
+	init(s: String, i: Int) {
+		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
+		loadViewFromNib()
+		v = self
+		v.frame = bounds
+		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		v.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = v.bounds
+		v.addSubview(container)
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+	/**
+	Changes the title of the activity. Decodes HTML.
+	:param: text The new title.
+	*/
+	func setTitle(text: String){
+		title.text = text.stripHtml()
+	}
+	
+	/**
+	Changes the description of the activity. Decodes HTML.
+	:param: text The new text.
+	*/
+	func setText(text: String){
+		descrip.text = text.stripHtml()
+	}
+	
+	/**
+	Changes the image of the activity.
+	If null or empty, the igage is hidden.
+	:param: path The new text.
+	*/
+	func setImage(filename: String){
+		if (filename == ""){
+			print("No image")
+			//TODO hide the imageview
+		}
+		else{
+			print("Set image \(filename)")
+			let path = "img/actividades/thumb/\(filename)"
+			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+		}
+	}
+}

+ 111 - 0
app/RowHomeFutureActivities.xib

@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+<device id="retina4_7" orientation="portrait">
+<adaptation id="fullscreen"/>
+</device>
+<dependencies>
+<deployment identifier="iOS"/>
+<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+</dependencies>
+<objects>
+<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeFutureActivities" customModule="app">
+<connections>
+<outlet property="container" destination="2hI-rc-KPm" id="rWX-Vl-kOp"/>
+<outlet property="descrip" destination="f4E-5p-Bid" id="IF5-ck-qUL"/>
+<outlet property="entry" destination="wLM-VU-VYk" id="Gkq-yE-fdN"/>
+<outlet property="image" destination="WSe-uz-Uhz" id="iU4-jm-UzQ"/>
+<outlet property="title" destination="Bkz-DV-HVr" id="1ok-yI-Npt"/>
+</connections>
+</placeholder>
+<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+<view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomePastActivities" customClass="RowHomePastActivities" customModule="app">
+<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+<subviews>
+<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
+<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+<subviews>
+<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
+<rect key="frame" x="10" y="10" width="355" height="667"/>
+<subviews>
+<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Bkz-DV-HVr" userLabel="Title">
+<rect key="frame" x="10" y="10" width="335" height="21.5"/>
+<fontDescription key="fontDescription" type="boldSystem" pointSize="18"/>
+<color key="textColor" red="0.15294117647058825" green="0.33333333333333331" blue="0.45098039215686275" alpha="1" colorSpace="calibratedRGB"/>
+<nil key="highlightedColor"/>
+</label>
+<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="PhotoPlaceholder" translatesAutoresizingMaskIntoConstraints="NO" id="WSe-uz-Uhz" userLabel="Image">
+<rect key="frame" x="10" y="40" width="89" height="64"/>
+<constraints>
+<constraint firstAttribute="height" constant="64" id="EJ3-uo-Xp3"/>
+</constraints>
+</imageView>
+<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="f4E-5p-Bid" userLabel="Text">
+<rect key="frame" x="98" y="40" width="214" height="64"/>
+<fontDescription key="fontDescription" type="system" pointSize="17"/>
+<nil key="textColor"/>
+<nil key="highlightedColor"/>
+</label>
+</subviews>
+<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+<constraints>
+<constraint firstItem="WSe-uz-Uhz" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.2" id="9Lz-WQ-1aS"/>
+<constraint firstItem="f4E-5p-Bid" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Emi-Ob-27Q"/>
+<constraint firstItem="Bkz-DV-HVr" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="LSz-FM-x2V"/>
+<constraint firstItem="f4E-5p-Bid" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.7" id="MdM-ps-4b8"/>
+<constraint firstAttribute="trailing" secondItem="Bkz-DV-HVr" secondAttribute="trailing" constant="10" id="MdM-yF-pmK"/>
+<constraint firstItem="WSe-uz-Uhz" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="40" id="Pyf-oT-PQl"/>
+<constraint firstItem="WSe-uz-Uhz" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" constant="10" id="YG6-eX-oTj"/>
+<constraint firstItem="Bkz-DV-HVr" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" constant="10" id="mwG-d2-HQL"/>
+<constraint firstAttribute="trailing" secondItem="f4E-5p-Bid" secondAttribute="trailing" constant="10" id="svU-xx-LsR"/>
+</constraints>
+<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+<userDefinedRuntimeAttributes>
+<userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+<color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+</userDefinedRuntimeAttribute>
+<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+<real key="value" value="1"/>
+</userDefinedRuntimeAttribute>
+<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+<real key="value" value="3"/>
+</userDefinedRuntimeAttribute>
+</userDefinedRuntimeAttributes>
+</view>
+</subviews>
+<constraints>
+<constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
+<constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
+<constraint firstAttribute="height" constant="120" id="PdT-5v-I0r"/>
+<constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
+<constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
+</constraints>
+<edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+<userDefinedRuntimeAttributes>
+<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+<real key="value" value="0.0"/>
+</userDefinedRuntimeAttribute>
+</userDefinedRuntimeAttributes>
+</view>
+</subviews>
+<constraints>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="Kwy-25-YES"/>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="htS-q0-otF"/>
+<constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
+</constraints>
+<nil key="simulatedStatusBarMetrics"/>
+<userDefinedRuntimeAttributes>
+<userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+<real key="value" value="0.0"/>
+</userDefinedRuntimeAttribute>
+</userDefinedRuntimeAttributes>
+<point key="canvasLocation" x="45.5" y="-43.5"/>
+</view>
+</objects>
+<resources>
+<image name="PhotoPlaceholder" width="170" height="108"/>
+</resources>
+</document>

+ 151 - 0
app/RowHomeSocial.swift

@@ -0,0 +1,151 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import Foundation
+import UIKit
+
+/**
+Extension of UIView to be formatted as sections.
+*/
+@IBDesignable class RowHomeSocial: UIView {
+	
+	//This view
+	var v: UIView!
+	
+	//The container.
+	@IBOutlet weak var container: UIView!
+	
+	//The container.
+	@IBOutlet weak var entry: UIView!
+	
+	//The buttons
+	@IBOutlet weak var btnPhone: UIImageView!
+	@IBOutlet weak var btnMail: UIImageView!
+	@IBOutlet weak var btnWhatsapp: UIImageView!
+	@IBOutlet weak var btnFacebook: UIImageView!
+	@IBOutlet weak var btnTwitter: UIImageView!
+	@IBOutlet weak var btnGoogle: UIImageView!
+	@IBOutlet weak var btnYoutube: UIImageView!
+	@IBOutlet weak var btnInstagram: UIImageView!
+	
+	/**
+	Default constructor
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		super.init(coder: aDecoder)
+	}
+	
+	private func loadViewFromNib() {
+		print("LOADING NIB...")
+		let bundle = Bundle(for: type(of: self))
+		print("GOT BUNDLE...")
+		let nib = UINib(nibName: String(describing: type(of: self)), bundle: bundle)
+		print("NIB CREATED")
+		nib.instantiate(withOwner: self, options: nil).first as! UIView
+		print("NIB INSTANTIATED")
+	}
+	
+	/**
+	Default constructor.
+	:param: s Custom identifier
+	:param: i Custom identifier
+	*/
+	init(s: String, i: Int) {
+		super.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
+		loadViewFromNib()
+		v = self
+		v.frame = bounds
+		v.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		v.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = v.bounds
+		v.addSubview(container)
+		
+		// Set buttons up
+		let phoneTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapPhone))
+		btnPhone.isUserInteractionEnabled = true
+		btnPhone.addGestureRecognizer(phoneTapRecognizer)
+		let mailTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapMail))
+		btnMail.isUserInteractionEnabled = true
+		btnMail.addGestureRecognizer(mailTapRecognizer)
+		let whatsappTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapWhatsapp))
+		btnWhatsapp.isUserInteractionEnabled = true
+		btnWhatsapp.addGestureRecognizer(whatsappTapRecognizer)
+		let facebookTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapFacebook))
+		btnFacebook.isUserInteractionEnabled = true
+		btnFacebook.addGestureRecognizer(facebookTapRecognizer)
+		let twitterTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapTwitter))
+		btnTwitter.isUserInteractionEnabled = true
+		btnTwitter.addGestureRecognizer(twitterTapRecognizer)
+		let googleTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapGoogle))
+		btnGoogle.isUserInteractionEnabled = true
+		btnGoogle.addGestureRecognizer(googleTapRecognizer)
+		let youtubeTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapYoutube))
+		btnYoutube.isUserInteractionEnabled = true
+		btnYoutube.addGestureRecognizer(youtubeTapRecognizer)
+		let instagramTapRecognizer = UITapGestureRecognizer(target: self, action: #selector(didTapInstagram))
+		btnInstagram.isUserInteractionEnabled = true
+		btnInstagram.addGestureRecognizer(instagramTapRecognizer)
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+	func didTapPhone() {
+		UIApplication.shared.openURL(NSURL(string: "tel://+34637140371") as! URL)
+	}
+	
+	func didTapMail() {
+		UIApplication.shared.openURL(NSURL(string: "mailto:gasteizkomargolariak@gmail.com") as! URL)
+	}
+	
+	func didTapWhatsapp() {
+		//As of today, imposible
+		//UIApplication.shared.openURL(NSURL(string: "+34637140371") as! URL)
+	}
+	
+	func didTapFacebook() {
+		UIApplication.shared.openURL(NSURL(string: "http://facebook.com/gmargolariak") as! URL)
+	}
+	
+	func didTapTwitter() {
+		UIApplication.shared.openURL(NSURL(string: "http://twitter.com/gmargolariak") as! URL)
+	}
+	
+	func didTapGoogle() {
+		UIApplication.shared.openURL(NSURL(string: "https://plus.google.com/106661466029005469492") as! URL)
+	}
+	
+	func didTapYoutube() {
+		UIApplication.shared.openURL(NSURL(string: "https://www.youtube.com/user/GasteizkoMargolariak") as! URL)
+	}
+	
+	func didTapInstagram() {
+		UIApplication.shared.openURL(NSURL(string: "https://instagram.com/gmargolariak/") as! URL)
+	}
+	
+	
+}

+ 155 - 0
app/RowHomeSocial.xib

@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina4_7" orientation="portrait">
+        <adaptation id="fullscreen"/>
+    </device>
+    <dependencies>
+        <deployment identifier="iOS"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11757"/>
+        <capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
+        <capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
+        <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowHomeSocial" customModule="app">
+            <connections>
+                <outlet property="btnFacebook" destination="wP8-1o-Rrh" id="6uv-pC-Nta"/>
+                <outlet property="btnGoogle" destination="L4k-eK-pkc" id="DCM-a0-yah"/>
+                <outlet property="btnInstagram" destination="OlS-ga-Ngl" id="egF-6B-SQd"/>
+                <outlet property="btnMail" destination="5Xa-Sh-XrB" id="HCb-xY-VDs"/>
+                <outlet property="btnPhone" destination="512-B2-6nt" id="C2I-qn-kPa"/>
+                <outlet property="btnTwitter" destination="Ttk-Ce-1XP" id="JUs-rm-Q5M"/>
+                <outlet property="btnWhatsapp" destination="0jq-K4-utG" id="d7P-Md-D7b"/>
+                <outlet property="btnYoutube" destination="1qd-jG-4Bn" id="WVU-fK-qg1"/>
+                <outlet property="container" destination="2hI-rc-KPm" id="Qyi-RK-3V8"/>
+                <outlet property="entry" destination="wLM-VU-VYk" id="ebu-Wm-4By"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB" userLabel="RowHomeSocial" customClass="RowHomeSocial" customModule="app">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="2hI-rc-KPm" userLabel="Container">
+                    <rect key="frame" x="0.0" y="0.0" width="375" height="177.5"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wLM-VU-VYk" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="177.5"/>
+                            <subviews>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Phone" translatesAutoresizingMaskIntoConstraints="NO" id="512-B2-6nt">
+                                    <rect key="frame" x="0.0" y="0.0" width="89.5" height="89.5"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Mail" translatesAutoresizingMaskIntoConstraints="NO" id="5Xa-Sh-XrB" userLabel="Mail">
+                                    <rect key="frame" x="89.5" y="0.0" width="89" height="89.5"/>
+                                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Whatsapp" translatesAutoresizingMaskIntoConstraints="NO" id="0jq-K4-utG" userLabel="Whatsapp">
+                                    <rect key="frame" x="179" y="0.0" width="89" height="89"/>
+                                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Facebook" translatesAutoresizingMaskIntoConstraints="NO" id="wP8-1o-Rrh" userLabel="Facebook">
+                                    <rect key="frame" x="268" y="0.0" width="89" height="89"/>
+                                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Twitter" translatesAutoresizingMaskIntoConstraints="NO" id="Ttk-Ce-1XP">
+                                    <rect key="frame" x="0.0" y="90" width="89.5" height="89.5"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="GooglePlus" translatesAutoresizingMaskIntoConstraints="NO" id="L4k-eK-pkc">
+                                    <rect key="frame" x="90" y="90" width="89.5" height="89.5"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Youtube" translatesAutoresizingMaskIntoConstraints="NO" id="1qd-jG-4Bn">
+                                    <rect key="frame" x="179" y="89" width="89.5" height="89.5"/>
+                                </imageView>
+                                <imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" layoutMarginsFollowReadableWidth="YES" image="Instagram" translatesAutoresizingMaskIntoConstraints="NO" id="OlS-ga-Ngl">
+                                    <rect key="frame" x="268" y="89" width="89.5" height="89.5"/>
+                                </imageView>
+                            </subviews>
+                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                            <constraints>
+                                <constraint firstItem="Ttk-Ce-1XP" firstAttribute="width" secondItem="512-B2-6nt" secondAttribute="width" id="0QX-sh-Y62"/>
+                                <constraint firstItem="Ttk-Ce-1XP" firstAttribute="height" secondItem="512-B2-6nt" secondAttribute="height" id="39L-QV-csw"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="3xb-00-2P6"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="7T1-Hk-R35"/>
+                                <constraint firstItem="Ttk-Ce-1XP" firstAttribute="top" secondItem="512-B2-6nt" secondAttribute="bottom" id="9F0-DU-FFO"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="leading" secondItem="5Xa-Sh-XrB" secondAttribute="trailing" id="AH1-0L-nYQ"/>
+                                <constraint firstItem="1qd-jG-4Bn" firstAttribute="height" secondItem="0jq-K4-utG" secondAttribute="height" id="CUC-LH-oVM"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="leading" secondItem="0jq-K4-utG" secondAttribute="trailing" id="IM6-dv-FSu"/>
+                                <constraint firstItem="L4k-eK-pkc" firstAttribute="height" secondItem="5Xa-Sh-XrB" secondAttribute="height" id="IWg-0Z-7tO"/>
+                                <constraint firstItem="L4k-eK-pkc" firstAttribute="top" secondItem="5Xa-Sh-XrB" secondAttribute="bottom" id="Jf9-UI-kn3"/>
+                                <constraint firstItem="L4k-eK-pkc" firstAttribute="leading" secondItem="5Xa-Sh-XrB" secondAttribute="leading" id="Lkg-Ff-jNA"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="Lyv-es-d3j"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="MYA-FO-b5k"/>
+                                <constraint firstItem="1qd-jG-4Bn" firstAttribute="top" secondItem="0jq-K4-utG" secondAttribute="bottom" id="QMP-Gi-WCw"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="RPd-iR-02y"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="Z1m-CY-xaF"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="aFU-bQ-Y2T"/>
+                                <constraint firstItem="OlS-ga-Ngl" firstAttribute="leading" secondItem="wP8-1o-Rrh" secondAttribute="leading" id="aGq-AJ-HXg"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="agd-tD-Z7B"/>
+                                <constraint firstItem="L4k-eK-pkc" firstAttribute="width" secondItem="5Xa-Sh-XrB" secondAttribute="width" id="bD5-gc-RZQ"/>
+                                <constraint firstItem="OlS-ga-Ngl" firstAttribute="width" secondItem="wP8-1o-Rrh" secondAttribute="width" id="bil-4K-d7f"/>
+                                <constraint firstItem="Ttk-Ce-1XP" firstAttribute="leading" secondItem="512-B2-6nt" secondAttribute="leading" id="fMj-Zv-80b"/>
+                                <constraint firstItem="wP8-1o-Rrh" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="gjG-xf-f2v"/>
+                                <constraint firstItem="5Xa-Sh-XrB" firstAttribute="leading" secondItem="512-B2-6nt" secondAttribute="trailing" id="iay-5b-e6B"/>
+                                <constraint firstItem="1qd-jG-4Bn" firstAttribute="width" secondItem="0jq-K4-utG" secondAttribute="width" id="jDu-hC-arJ"/>
+                                <constraint firstAttribute="height" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.5" id="jGP-1G-1P3"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="lyN-c0-DOH"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="top" secondItem="wLM-VU-VYk" secondAttribute="top" id="nUV-gk-zhw"/>
+                                <constraint firstItem="0jq-K4-utG" firstAttribute="width" secondItem="wLM-VU-VYk" secondAttribute="width" multiplier="0.25" id="uCp-Vv-c61"/>
+                                <constraint firstItem="OlS-ga-Ngl" firstAttribute="top" secondItem="wP8-1o-Rrh" secondAttribute="bottom" id="vCU-hL-wuO"/>
+                                <constraint firstItem="512-B2-6nt" firstAttribute="leading" secondItem="wLM-VU-VYk" secondAttribute="leading" id="wMJ-K2-1e9"/>
+                                <constraint firstItem="OlS-ga-Ngl" firstAttribute="height" secondItem="wP8-1o-Rrh" secondAttribute="height" id="xZ5-XM-Ixz"/>
+                                <constraint firstItem="1qd-jG-4Bn" firstAttribute="leading" secondItem="0jq-K4-utG" secondAttribute="leading" id="zfP-9S-Gfc"/>
+                            </constraints>
+                            <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                            <userDefinedRuntimeAttributes>
+                                <userDefinedRuntimeAttribute type="color" keyPath="borderColor">
+                                    <color key="value" red="0.42745098039215684" green="0.41176470588235292" blue="0.56470588235294117" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                                    <real key="value" value="1"/>
+                                </userDefinedRuntimeAttribute>
+                                <userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
+                                    <real key="value" value="3"/>
+                                </userDefinedRuntimeAttribute>
+                            </userDefinedRuntimeAttributes>
+                        </view>
+                    </subviews>
+                    <constraints>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="bottom" secondItem="2hI-rc-KPm" secondAttribute="bottom" constant="10" id="39K-W7-EIE"/>
+                        <constraint firstAttribute="trailing" secondItem="wLM-VU-VYk" secondAttribute="trailing" constant="10" id="HSF-55-R5c"/>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="top" secondItem="2hI-rc-KPm" secondAttribute="top" constant="10" id="fWN-oO-QzS"/>
+                        <constraint firstItem="wLM-VU-VYk" firstAttribute="leading" secondItem="2hI-rc-KPm" secondAttribute="leading" constant="10" id="teN-oh-Db9"/>
+                    </constraints>
+                    <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
+                    <userDefinedRuntimeAttributes>
+                        <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                            <real key="value" value="0.0"/>
+                        </userDefinedRuntimeAttribute>
+                    </userDefinedRuntimeAttributes>
+                </view>
+            </subviews>
+            <constraints>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="cYi-xQ-QXA"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="clR-QU-zlD"/>
+                <constraint firstItem="2hI-rc-KPm" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="rig-k7-6bz"/>
+            </constraints>
+            <nil key="simulatedStatusBarMetrics"/>
+            <userDefinedRuntimeAttributes>
+                <userDefinedRuntimeAttribute type="number" keyPath="borderWidth">
+                    <real key="value" value="0.0"/>
+                </userDefinedRuntimeAttribute>
+            </userDefinedRuntimeAttributes>
+            <point key="canvasLocation" x="-36.5" y="-43.5"/>
+        </view>
+    </objects>
+    <resources>
+        <image name="Facebook" width="105" height="105"/>
+        <image name="GooglePlus" width="105" height="105"/>
+        <image name="Instagram" width="105" height="105"/>
+        <image name="Mail" width="105" height="105"/>
+        <image name="Phone" width="105" height="105"/>
+        <image name="Twitter" width="105" height="105"/>
+        <image name="Whatsapp" width="105" height="105"/>
+        <image name="Youtube" width="105" height="105"/>
+    </resources>
+</document>

+ 830 - 95
app/Sync.swift

@@ -23,12 +23,12 @@ import CoreData
 import UIKit
 
 /**
- Class to handle server sync.
- */
+Class to handle server sync.
+*/
 class Sync{
 	
 	/**
-	 Starts the sync process.
+	Starts the sync process.
 	*/
 	init(){
 		let url = buildUrl();
@@ -36,123 +36,632 @@ class Sync{
 	}
 	
 	/**
-	 Builds the URL to perform the sync against.
-	 :returns: The URL.
+	Builds the URL to perform the sync against.
+	:returns: The URL.
 	*/
 	func buildUrl() -> URL{
 		let url = URL(string: "https://margolariak.com/API/v1/sync.php?client=com.margolariak.app")
 		//TODO add parameters
 		return url!
-		
 	}
 	
-	
-	
 	/**
-	 Performs an asynchronous sync.
-	 It fethes the info from the server and stores as Core Data
-	 :param: url The url to sync.
+	Performs an asynchronous sync.
+	It fethes the info from the server and stores as Core Data
+	:param: url The url to sync.
 	*/
 	func sync(url: URL){
 		
+		print("SYNC:LOG: Sync started.")
+		
 		//Synchronously get data
 		let task = URLSession.shared.dataTask(with: url) { data, response, error in
 			guard error == nil else {
-				print("Sync error")
+				print("SYNC:ERROR: Unknown error.")
 				return
 			}
 			guard let data = data else {
-				print("Data is empty")
+				print("SYNC:ERROR: Data is empty.")
 				return
 			}
 			
-			print("Got the Sync JSON")
+			print("SYNC:LOG: Data received.")
 			
 			var strData = String(data:data, encoding: String.Encoding.utf8)
 			
 			let dataIdx = strData?.indexOf(target: "{\"data\"")
 			strData = strData!.subStr(start: dataIdx!, end: strData!.length - 1)
 			
-			//TODO: do something with versions
+			//TODO: do something with versions
+			
+			//Get tables
+			let dataActivity : [String] = self.getTable(data: strData!, table: "activity")
+			let dataActivityComment : [String] = self.getTable(data: strData!, table: "activity_comment")
+			let dataActivityImage : [String] = self.getTable(data: strData!, table: "activity_image")
+			let dataActivityTag : [String] = self.getTable(data: strData!, table: "activity_tag")
+			let dataActivityItinerary : [String] = self.getTable(data: strData!, table: "activity_itinerary")
+			let dataAlbum : [String] = self.getTable(data: strData!, table: "album")
+			//let dataFestival : [String] = self.getTable(data: strData!, table: "festival")
+			//let dataFestivalDay : [String] = self.getTable(data: strData!, table: "festival_day")
+			//let dataFestivalEvent : [String] = self.getTable(data: strData!, table: "festival_event")
+			//let dataFestivalEventImage : [String] = self.getTable(data: strData!, table: "festival_event_image")
+			//let dataFestivalOffer : [String] = self.getTable(data: strData!, table: "festival_offer")
+			//let dataPeople : [String] = self.getTable(data: strData!, table: "people")
+			//let dataPhoto : [String] = self.getTable(data: strData!, table: "photo")
+			//let dataPhotoAlbum : [String] = self.getTable(data: strData!, table: "photo_album")
+			//let dataPhotoComment : [String] = self.getTable(data: strData!, table: "photo_comment")
+			let dataPlace : [String] = self.getTable(data: strData!, table: "place")
+			let dataPost : [String] = self.getTable(data: strData!, table: "post")
+			let dataPostComment : [String] = self.getTable(data: strData!, table: "post_comment")
+			let dataPostImage : [String] = self.getTable(data: strData!, table: "post_image")
+			let dataPostTag : [String] = self.getTable(data: strData!, table: "post_tag")
+			//let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
+			
+			//One by one, save the received data
+			self.saveTableActivity(entries : dataActivity)
+			self.saveTableActivityComment(entries : dataActivityComment)
+			self.saveTableActivityImage(entries : dataActivityImage)
+			self.saveTableActivityTag(entries : dataActivityTag)
+			self.saveTableActivityItinerary(entries : dataActivityItinerary)
+			
+			self.saveTablePost(entries: dataPost)
+			self.saveTablePostComment(entries: dataPostComment)
+			self.saveTablePostImage(entries: dataPostImage)
+			self.saveTablePostTag(entries: dataPostTag)
+			
+			self.saveTablePlace(entries: dataPlace)
+			
+			self.saveTableAlbum(entries: dataAlbum)
+			
+			//DEBUG: Tester, Debug only
+			// Test if a entity has entries
+			let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+			let appDelegate = UIApplication.shared.delegate as! AppDelegate
+			context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+			let fetchRequest: NSFetchRequest<Post> = Post.fetchRequest()  //Entity to debug
+			
+			do {
+				//go get the results
+				let searchResults = try context.fetch(fetchRequest)
+				
+				print("SYNC:DEBUG: Num of results = \(searchResults.count).")
+				for r in searchResults as [NSManagedObject] {
+					print("SYNC:DEBUG: id: \(r.value(forKey: "id")).")
+				}
+			} catch {
+				print("SYNC:DEBUG: Error with request: \(error).")
+			}
+			//End tester
+		}
+		
+		task.resume()
+		
+	}
+	
+	/**
+	Extracts table rows from the raw data received.
+	:param: param Received data in JSON format.
+	:param: table The name of the table to look for.
+	:return: Array of strings containing the rows of the table, in JSON format.
+	*/
+	func getTable(data: String, table: String) -> [String]{
+		//Does the table exists?
+		if data.indexOf(target: "\"\(table)\":[") == nil{
+			print("SYNC:LOG: Empty table: \(table).")
+			return [String]()
+		}
+		let iS : Int? = data.indexOf(target: "\"\(table)\":[")
+		var str = data.subStr(start: iS!, end: data.length - 1)
+		let iE : Int? = str.indexOf(target: "}]}")!
+		str = str.subStr(start: 0, end: iE!)
+		str = str.subStr(start: table.length + 3,end: str.length - 1)
+		
+		//Separate the entries
+		var entries : [String] = str.components(separatedBy: "},{")
+		
+		//Modify the first and the last one to remove bracers
+		entries[0] = entries[0].subStr(start: 1, end: entries[0].length - 1)
+		entries[entries.count - 1] = entries[entries.count - 1].subStr(start: 0, end: entries[entries.count - 1].length - 2)
+		
+		print("SYNC:LOG: Table \(table) has \(entries.count) rows.")
+		
+		//Return the array
+		return entries
+	}
+	
+	// FIX: ERROR in API.
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTablePeople(entries : [String]){
+		
+		print("SYNC:LOG: Saving table People.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "People", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "People")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up People entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up People entity")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get name_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_es : String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get name_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_en : String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get name_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_eu : String = str.subStr(start : str.indexOf(target : "\"name_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get address_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_es : String = str.subStr(start : str.indexOf(target : "\"address_es\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get address_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_en : String = str.subStr(start : str.indexOf(target : "\"address_en\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get address_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_eu : String = str.subStr(start : str.indexOf(target : "\"address_eu\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get cp
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let cp : String = str.subStr(start : str.indexOf(target : "\"cp\":")! + 6, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get lat
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let lat : Float = Float(str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get lon
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let lon : Float = Float(str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2))!
+			
+			//Save CoreData
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			row.setValue(id, forKey: "id")
+			row.setValue(name_es, forKey: "name_es")
+			row.setValue(name_en, forKey: "name_en")
+			row.setValue(name_eu, forKey: "name_eu")
+			row.setValue(address_es, forKey: "address_es")
+			row.setValue(address_en, forKey: "address_en")
+			row.setValue(address_eu, forKey: "address_eu")
+			row.setValue(cp, forKey: "cp")
+			row.setValue(lat, forKey: "lat")
+			row.setValue(lon, forKey: "lon")
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Place with id \(id): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Place with id \(id).")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTablePlace(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Place.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Place", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Place")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Places entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Places entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get name_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_es : String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get name_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_en : String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get name_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_eu : String = str.subStr(start : str.indexOf(target : "\"name_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get address_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_es : String = str.subStr(start : str.indexOf(target : "\"address_es\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get address_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_en : String = str.subStr(start : str.indexOf(target : "\"address_en\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get address_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let address_eu : String = str.subStr(start : str.indexOf(target : "\"address_eu\":")! + 14, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get cp
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let cp : String = str.subStr(start : str.indexOf(target : "\"cp\":")! + 6, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get lat
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let lat : Float = Float(str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get lon
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let lon : Float = Float(str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2))!
+			
+			//Save CoreData
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			row.setValue(id, forKey: "id")
+			row.setValue(name_es, forKey: "name_es")
+			row.setValue(name_en, forKey: "name_en")
+			row.setValue(name_eu, forKey: "name_eu")
+			row.setValue(address_es, forKey: "address_es")
+			row.setValue(address_en, forKey: "address_en")
+			row.setValue(address_eu, forKey: "address_eu")
+			row.setValue(cp, forKey: "cp")
+			row.setValue(lat, forKey: "lat")
+			row.setValue(lon, forKey: "lon")
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Place with id \(id): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Place with id \(id).")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTablePost(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Post.")
+		
+		let dateFormatter = DateFormatter()
+		dateFormatter.timeZone = TimeZone.ReferenceType.local
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Post", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Post")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Post entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Post entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get permalink
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let permalink : String = str.subStr(start : str.indexOf(target : "\"permalink\":")! + 13, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get title_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let title_es : String = str.subStr(start : str.indexOf(target : "\"title_es\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get title_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let title_en : String = str.subStr(start : str.indexOf(target : "\"title_en\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get title_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let title_eu : String = str.subStr(start : str.indexOf(target : "\"title_eu\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get text_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text_es : String = str.subStr(start : str.indexOf(target : "\"text_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get text_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text_en : String = str.subStr(start : str.indexOf(target : "\"text_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get text_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text_eu : String = str.subStr(start : str.indexOf(target : "\"text_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get comments
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let comments : Int = Int(str.subStr(start : str.indexOf(target : "\"comments\":")! + 12, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get username
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let username : String = str.subStr(start : str.indexOf(target : "\"username\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get dtime
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+			let dtime = dateFormatter.date(from : str.subStr(start : str.indexOf(target : "\"dtime\":")! + 9, end : str.length - 2))!
+			
+			//Save CoreData
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			//set the entity values
+			row.setValue(id, forKey: "id")
+			row.setValue(permalink, forKey: "permalink")
+			row.setValue(dtime, forKey: "dtime")
+			row.setValue(username, forKey: "username")
+			row.setValue(comments, forKey: "comments")
+			row.setValue(title_es, forKey: "title_es")
+			row.setValue(title_en, forKey: "title_en")
+			row.setValue(title_eu, forKey: "title_eu")
+			row.setValue(text_es, forKey: "text_es")
+			row.setValue(text_en, forKey: "text_en")
+			row.setValue(text_eu, forKey: "text_eu")
+			
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Post with id \(id): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Post with id \(id).")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTablePostComment(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Post_comment.")
+		
+		let dateFormatter = DateFormatter()
+		dateFormatter.timeZone = TimeZone.ReferenceType.local
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Post_comment", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Post_comment")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Post_comment entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Post_comment entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get activity
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let post : String = str.subStr(start : str.indexOf(target : "\"post\":")! + 8, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get text
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let text : String = str.subStr(start : str.indexOf(target : "\"text\":")! + 8, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get dtime
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			dateFormatter.dateFormat = "yyyy-MM-dd"
+			let dtime = dateFormatter.date(from : str.subStr(start : str.indexOf(target : "\"dtime\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get username
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let username : String = str.subStr(start : str.indexOf(target : "\"username\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			
+			//Get lang
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let lang : String = str.subStr(start : str.indexOf(target : "\"lang\":")! + 8, end : str.length - 1)
+			
+			//Save CoreData
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			row.setValue(id, forKey: "id")
+			row.setValue(post, forKey: "post")
+			row.setValue(text, forKey: "text")
+			row.setValue(dtime, forKey: "dtime")
+			row.setValue(username, forKey: "username")
+			row.setValue(lang, forKey: "lang")
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Activity_comment with id \(id): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Activity_comment with id \(id).")
+			}
+			
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTablePostImage(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Post_image.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Post_image", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Post_image")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Post_comment entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Post_comment entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
 			
-			//Get tables
-			let dataActivity : [String] = self.getTable(data: strData!, table: "activity")
-			let dataActivityComment : [String] = self.getTable(data: strData!, table: "activity_comment")
-			let dataActivityImage : [String] = self.getTable(data: strData!, table: "activity_image")
-			let dataActivityTag : [String] = self.getTable(data: strData!, table: "activity_tag")
-			//let dataAlbum : [String] = self.getTable(data: strData!, table: "album")
-			//let dataFestival : [String] = self.getTable(data: strData!, table: "festival")
-			//let dataFestivalDay : [String] = self.getTable(data: strData!, table: "festival_day")
-			//let dataFestivalEvent : [String] = self.getTable(data: strData!, table: "festival_event")
-			//let dataFestivalEventImage : [String] = self.getTable(data: strData!, table: "festival_event_image")
-			//let dataFestivalOffer : [String] = self.getTable(data: strData!, table: "festival_offer")
-			//let dataPeople : [String] = self.getTable(data: strData!, table: "people")
-			//let dataPhoto : [String] = self.getTable(data: strData!, table: "photo")
-			//let dataPhotoAlbum : [String] = self.getTable(data: strData!, table: "photo_album")
-			//let dataPhotoComment : [String] = self.getTable(data: strData!, table: "photo_comment")
-			//let dataPlace : [String] = self.getTable(data: strData!, table: "place")
-			//let dataPost : [String] = self.getTable(data: strData!, table: "post")
-			//let dataPostComment : [String] = self.getTable(data: strData!, table: "post_comment")
-			//let dataPostImage : [String] = self.getTable(data: strData!, table: "post_image")
-			//let dataPostTag : [String] = self.getTable(data: strData!, table: "post_tag")
-			//let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
+			//Get activity
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let post : Int = Int(str.subStr(start : str.indexOf(target : "\"post\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
 			
-			//One by one, save the received data
-			self.saveTableActivity(entries : dataActivity)
-			self.saveTableActivityComment(entries : dataActivityComment)
-			self.saveTableActivityImage(entries : dataActivityImage)
-			self.saveTableActivityTag(entries : dataActivityTag)
+			//Get image
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let image : String = str.subStr(start : str.indexOf(target : "\"image\":")! + 9, end : str.indexOf(target : ",\"")! - 2)
 			
-			//TODO: Tester, Debug only
-			// Test if a entity has entries
-			let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
-			let appDelegate = UIApplication.shared.delegate as! AppDelegate
-			context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
-			let fetchRequest: NSFetchRequest<Activity_comment> = Activity_comment.fetchRequest()
+			//Get idx
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let idx : Int = Int(str.subStr(start : str.indexOf(target : "\"idx\":")! + 7, end : str.length - 2))!
 			
+			//Save CoreData
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			row.setValue(id, forKey: "id")
+			row.setValue(post, forKey: "post")
+			row.setValue(image, forKey: "image")
+			row.setValue(idx, forKey: "idx")
 			do {
-				//go get the results
-				let searchResults = try context.fetch(fetchRequest)
-				
-				print ("Num of results = \(searchResults.count)")
-				for r in searchResults as [NSManagedObject] {
-					print("\(r.value(forKey: "id"))")
-				}
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Post_image with id \(id): \(error), \(error.userInfo).")
 			} catch {
-				print("Error with request: \(error)")
+				print("SYNC:ERROR: Could not store Post_image with id \(id).")
 			}
-			//End tester
 		}
-		
-		task.resume()
-
 	}
 	
-	func getTable(data: String, table: String) -> [String]{
-			//Does the table exists?
-			if data.indexOf(target: table) == nil{
-				print("No data in table \(table)")
-				return [String]()
-			}
-			let iS : Int? = data.indexOf(target: table)
-			var str = data.subStr(start: iS!, end: data.length - 1)
-			let iE : Int? = str.indexOf(target: "}]}")!
-			str = str.subStr(start: 0, end: iE!)
-			str = str.subStr(start: table.length + 3,end: str.length - 1)
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTablePostTag(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Post_tag.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Post_tag", in: context)
 		
-			//Separate the entries
-			var entries : [String] = str.components(separatedBy: "},{")
+		var row: NSManagedObject
 		
-			//Modify the first and the last one to remove bracers
-			entries[0] = entries[0].subStr(start: 1, end: entries[0].length - 1)
-			entries[entries.count - 1] = entries[entries.count - 1].subStr(start: 0, end: entries[entries.count - 1].length - 2)
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Post_tag")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Post_tag entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Post_tag entity.")
+		}
 		
-			//Return the array
-			return entries
+		//Loop new entries
+		for entry in entries{
+			
+			//Get activity
+			var str = entry
+			let post : Int = Int(str.subStr(start : str.indexOf(target : "\"post\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
+			
+			//Get tag
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let tag : String = str.subStr(start : str.indexOf(target : "\"tag\":")! + 7, end : str.length - 1)
+			
+			//Save CoreData
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			row.setValue(post, forKey: "post")
+			row.setValue(tag, forKey: "tag")
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Post_tag for post: \(post), tag: \(tag): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Post_tag for post: \(post), tag: \(tag).")
+			}
+		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
 	func saveTableActivity(entries : [String]){
 		
+		print("SYNC:LOG: Saving table Activity.")
+		
 		let dateFormatter = DateFormatter()
 		dateFormatter.timeZone = TimeZone.ReferenceType.local
 		
@@ -171,9 +680,9 @@ class Sync{
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			print("Could not clean up Activity entity: \(error), \(error.userInfo)")
+			print("SYNC:ERROR: Could not clean up Activity entity: \(error), \(error.userInfo).")
 		} catch {
-			
+			print("SYNC:ERROR: Could not clean up Activity entity.")
 		}
 		
 		//Loop new entries
@@ -290,20 +799,26 @@ class Sync{
 			if (album != -1){
 				row.setValue(album, forKey: "album")
 			}
-
+			
 			do {
 				try context.save()
 			} catch let error as NSError  {
-				print("Could not store Activity with id \(id) \(error), \(error.userInfo)")
+				print("SYNC:ERROR: Could not store Activity with id \(id): \(error), \(error.userInfo).")
 			} catch {
-				
+				print("SYNC:ERROR: Could not store Activity with id \(id).")
 			}
-
+			
 		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
 	func saveTableActivityComment(entries : [String]){
 		
+		print("SYNC:LOG: Saving table Activity_comment.")
+		
 		let dateFormatter = DateFormatter()
 		dateFormatter.timeZone = TimeZone.ReferenceType.local
 		
@@ -322,9 +837,9 @@ class Sync{
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			print("Could not clean up Activity_comment entity: \(error), \(error.userInfo)")
+			print("SYNC:ERROR: Could not clean up Activity_comment entity: \(error), \(error.userInfo).")
 		} catch {
-			
+			print("SYNC:ERROR: Could not clean up Activity_comment entity.")
 		}
 		
 		//Loop new entries
@@ -366,16 +881,22 @@ class Sync{
 			do {
 				try context.save()
 			} catch let error as NSError  {
-				print("Could not store Activity_comment with id \(id) \(error), \(error.userInfo)")
+				print("SYNC:ERROR: Could not store Activity_comment with id \(id): \(error), \(error.userInfo).")
 			} catch {
-				
+				print("SYNC:ERROR: Could not store Activity_comment with id \(id).")
 			}
 			
 		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
 	func saveTableActivityImage(entries : [String]){
 		
+		print("SYNC:LOG: Saving table Activity_image.")
+		
 		//Set up context
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
@@ -391,9 +912,9 @@ class Sync{
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			print("Could not clean up Activity_comment entity: \(error), \(error.userInfo)")
+			print("SYNC:ERROR: Could not clean up Activity_comment entity: \(error), \(error.userInfo).")
 		} catch {
-			
+			print("SYNC:ERROR: Could not clean up Activity_comment entity.")
 		}
 		
 		//Loop new entries
@@ -424,15 +945,21 @@ class Sync{
 			do {
 				try context.save()
 			} catch let error as NSError  {
-				print("Could not store Activity_image with id \(id) \(error), \(error.userInfo)")
+				print("SYNC:ERROR: Could not store Activity_image with id \(id): \(error), \(error.userInfo).")
 			} catch {
-				
+				print("SYNC:ERROR: Could not store Activity_image with id \(id).")
 			}
 		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
 	func saveTableActivityTag(entries : [String]){
 		
+		print("SYNC:LOG: Saving table Activity_tag.")
+		
 		//Set up context
 		let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
@@ -448,9 +975,9 @@ class Sync{
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			print("Could not clean up Activity_tag entity: \(error), \(error.userInfo)")
+			print("SYNC:ERROR: Could not clean up Activity_tag entity: \(error), \(error.userInfo).")
 		} catch {
-			
+			print("SYNC:ERROR: Could not clean up Activity_tag entity.")
 		}
 		
 		//Loop new entries
@@ -471,9 +998,217 @@ class Sync{
 			do {
 				try context.save()
 			} catch let error as NSError  {
-				print("Could not store Activity_tag for activity: \(activity), tag: \(tag). Error: \(error), \(error.userInfo)")
+				print("SYNC:ERROR: Could not store Activity_tag for activity \(activity), tag: \(tag): Error: \(error), \(error.userInfo).")
 			} catch {
-				
+				print("SYNC:ERROR: Could not store Activity_tag for activity \(activity), tag: \(tag).")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	//CHECK: New (and probably better format than the others.)
+	func saveTableActivityItinerary(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Activity_itinerary.")
+		
+		let dateFormatter = DateFormatter()
+		dateFormatter.timeZone = TimeZone.ReferenceType.local
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Activity_itinerary", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Activity_itinerary")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Activity_itinerary entity: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Activity_itinerary entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(id, forKey: "id")
+			
+			//Get activity
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let activity : Int = Int(str.subStr(start : str.indexOf(target : "\"activity\":")! + 12, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(activity, forKey: "activity")
+			
+			//Get name_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_es : String = str.subStr(start : str.indexOf(target : "\"name_es\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_es, forKey: "name_es")
+			
+			//Get name_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_en : String = str.subStr(start : str.indexOf(target : "\"name_en\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_en, forKey: "name_en")
+			
+			//Get name_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let name_eu : String = str.subStr(start : str.indexOf(target : "\"name_eu\":")! + 11, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(name_eu, forKey: "name_eu")
+			
+			//Get description_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_es : String = str.subStr(start : str.indexOf(target : "\"description_es\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_es != "ul"){ //From "null"
+				row.setValue(description_es, forKey: "description_es")
+			}
+			
+			//Get description_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_en : String = str.subStr(start : str.indexOf(target : "\"description_en\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_en != "ul"){ //From "null"
+				row.setValue(description_en, forKey: "description_en")
+			}
+			
+			//Get description_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_eu : String = str.subStr(start : str.indexOf(target : "\"description_eu\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_eu != "ul"){ //From "null"
+				row.setValue(description_eu, forKey: "description_eu")
+			}
+			
+			//Get start
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"
+			let start = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(start, forKey: "start")
+			
+			//Get end
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let end = str.subStr(start : str.indexOf(target : "\"end\":")! + 7, end : str.indexOf(target : ",\"")! - 2)
+			if (end != "ul"){ //From "null"
+				row.setValue(dateFormatter.date(from: end), forKey: "end")
+			}
+			
+			//Get place
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let place : Int = Int(str.subStr(start : str.indexOf(target : "\"place\":")! + 9, end : str.length - 2))!
+			row.setValue(place, forKey: "place")
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Activity_itinerary with id \(id): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Activity_itinerary with id \(id).")
+			}
+		}
+	}
+	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	//CHECK: New (and probably better format than the others.)
+	func saveTableAlbum(entries : [String]){
+		
+		print("SYNC:LOG: Saving table Album.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Album", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Album")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			print("SYNC:ERROR: Could not clean up Album: \(error), \(error.userInfo).")
+		} catch {
+			print("SYNC:ERROR: Could not clean up Album entity.")
+		}
+		
+		//Loop new entries
+		for entry in entries{
+			
+			row = NSManagedObject(entity: entity!, insertInto: context)
+			
+			//Get id
+			var str = entry
+			let id : Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(id, forKey: "id")
+			
+			//Get permalink
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let permalink : String = str.subStr(start : str.indexOf(target : "\"permalink\":")! + 13, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(permalink, forKey: "permalink")
+			
+			//Get title_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let title_es : String = str.subStr(start : str.indexOf(target : "\"title_es\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(title_es, forKey: "title_es")
+			
+			//Get title_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let title_en : String = str.subStr(start : str.indexOf(target : "\"title_en\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(title_es, forKey: "title_es")
+			
+			//Get title_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let title_eu : String = str.subStr(start : str.indexOf(target : "\"title_eu\":")! + 12, end : str.indexOf(target : ",\"")! - 2)
+			row.setValue(title_es, forKey: "title_es")
+			
+			//Get description_es
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_es : String = str.subStr(start : str.indexOf(target : "\"description_es\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_es != "ul"){ //From "null"
+				row.setValue(description_es, forKey: "description_es")
+			}
+			
+			//Get description_en
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_en : String = str.subStr(start : str.indexOf(target : "\"description_en\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_en != "ul"){ //From "null"
+				row.setValue(description_en, forKey: "description_en")
+			}
+			
+			//Get description_eu
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let description_eu : String = str.subStr(start : str.indexOf(target : "\"description_eu\":")! + 18, end : str.indexOf(target : ",\"")! - 2)
+			if (description_eu != "ul"){ //From "null"
+				row.setValue(description_eu, forKey: "description_eu")
+			}
+			
+			//Get open
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let open : Int = Int(str.subStr(start : str.indexOf(target : "\"open\":")! + 8, end : str.length - 2))!
+			row.setValue(open, forKey: "open")
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				print("SYNC:ERROR: Could not store Album with id \(id): \(error), \(error.userInfo).")
+			} catch {
+				print("SYNC:ERROR: Could not store Album with id \(id).")
 			}
 		}
 	}

+ 42 - 0
app/UIApplcation.swift

@@ -0,0 +1,42 @@
+// Copyright (C) 2016 Inigo Valentin
+//
+// This file is part of the Gasteizko Margolariak IOS app.
+//
+// The Gasteizko Margolariak IOS app is free software: you can
+// redistribute it and/or modify it under the terms of the
+// GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your
+// option) any later version.
+//
+// The Gasteizko Margolariak IOS app is distributed in the
+// hope that it will be useful, but WITHOUT ANY WARRANTY;
+// without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+// Public License for more details.
+//
+// You should have received a copy of the GNU General Public
+// License along with the Gasteizko Margolariak IOS app.
+// If not, see <http://www.gnu.org/licenses/>.
+
+import Foundation
+import UIKit
+
+/**
+Extension of UIApplication to get the root view controller.
+*/
+extension UIApplication {
+	class func topViewController(controller: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
+		if let navigationController = controller as? UINavigationController {
+			return topViewController(controller: navigationController.visibleViewController)
+		}
+		if let tabController = controller as? UITabBarController {
+			if let selected = tabController.selectedViewController {
+				return topViewController(controller: selected)
+			}
+		}
+		if let presented = controller?.presentedViewController {
+			return topViewController(controller: presented)
+		}
+		return controller
+	}
+}

+ 16 - 0
app/UIView.swift

@@ -59,4 +59,20 @@ import UIKit
 			return layer.cornerRadius
 		}
 	}
+	
+	var parentViewController: ViewController? {
+		var parentResponder: UIResponder? = self
+		var i = 0
+		while parentResponder != nil {
+			print("UIVIEW:DEBUG: parentViewController level \(i)")
+			parentResponder = parentResponder!.next
+			if let viewController = parentResponder as? ViewController {
+				print("UIVIEW:DEBUG: parentViewController found  controller.")
+				return viewController
+			}
+		}
+		print("UIVIEW:DEBUG: parentViewController no controller found.")
+		return nil
+	}
+	
 }

+ 32 - 4
app/ViewController.swift

@@ -24,25 +24,42 @@ import CoreData
 /**
   The view controller of the app.
  */
-class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
+class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UIGestureRecognizerDelegate {
+	
+	var delegate: AppDelegate?
 	
 	//The menu collection.
 	var sectionCollection: UICollectionView!
 
 	//Each of the sections of the app.
 	@IBOutlet weak var containerViewGallery: UIView!
-	@IBOutlet weak var containerViewBlog: UIView!
+	@IBOutlet weak var containerViewBlog: BlogView!
 	@IBOutlet weak var containerViewActivities: UIView!
 	@IBOutlet weak var containerViewLablanca: UIView!
 	@IBOutlet weak var containerViewLocation: UIView!
 	@IBOutlet weak var containerViewHome: HomeView!
 	
+	var passId: Int = -1
+	
 	func getContext () -> NSManagedObjectContext {
 		//let appDelegate = UIApplication.shared.delegate as! AppDelegate
 		//return appDelegate.persistentContainer.viewContext
 		return NSManagedObjectContext(concurrencyType: .mainQueueConcurrencyType)
 	}
 	
+	func showPost(id: Int){
+		print("CONTROLLER:DEBUG: showPost \(id)")
+		self.passId = id
+		performSegue(withIdentifier: "SeguePost", sender: nil)
+	}
+	
+	override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
+		print("CONTROLLER:DEBUG: preparing for segue \(segue.identifier) with id \(self.passId)")
+		if segue.identifier == "SeguePost"{
+			(segue.destination as! PostViewController).id = passId
+		}
+	}
+	
 	/**
 	 Run when the app loads.
 	*/
@@ -54,12 +71,23 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		self.containerViewActivities.alpha = 0
 		self.containerViewBlog.alpha = 0
 		self.containerViewGallery.alpha = 0
+		
+		
+		
+		//self.containerViewBlog.isHidden = true
 				
-		print("ViewController:viewDidLoad()")
-		Sync()
+		print("CONTROLLER:LOG: viewDidLoad()")
+		print("CONTROLLER:DEBUG: Skyp sync")
+		//Sync()
 		
 		super.viewDidLoad()
 		// Do any additional setup after loading the view, typically from a nib.
+		
+		//self.containerViewBlog.setController(controller: self as ViewController)
+		
+		delegate = UIApplication.shared.delegate as! AppDelegate
+		delegate?.controller = self
+		
 	}
 
 	/**

+ 2 - 1
app/app.xcdatamodeld/app.xcdatamodel/contents

@@ -53,6 +53,7 @@
         <attribute name="tag" optional="YES" attributeType="String" syncable="YES"/>
     </entity>
     <entity name="Album" representedClassName=".Album" syncable="YES" codeGenerationType="class">
+        <attribute name="description_en" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="description_es" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="description_eu" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="id" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
@@ -224,7 +225,7 @@
         <element name="Activity_image" positionX="-36" positionY="-3897" width="128" height="105"/>
         <element name="Activity_itinerary" positionX="-18" positionY="-3888" width="128" height="210"/>
         <element name="Activity_tag" positionX="0" positionY="-3852" width="128" height="75"/>
-        <element name="Album" positionX="18" positionY="-3861" width="128" height="180"/>
+        <element name="Album" positionX="18" positionY="-3861" width="128" height="195"/>
         <element name="Festival" positionX="36" positionY="-3852" width="128" height="180"/>
         <element name="Festival_day" positionX="-9" positionY="-3906" width="128" height="135"/>
         <element name="Festival_event" positionX="0" positionY="-3897" width="128" height="225"/>