Kaynağa Gözat

Merge branch 'BaseProject' into Lablanca

Iñigo Valentin 9 yıl önce
ebeveyn
işleme
0c43c5cf93

+ 43 - 0
README.es-ES.md

@@ -0,0 +1,43 @@
+---
+[Informazioa euskaraz](README.es-EU.md) 
+[Information in english](README.md)
+---
+
+
+# Androizko Gasteizko Margolariak aplikazioia #
+
+Una aplicacion para iOS para miembros de [Gasteizko Margolariak](https://margolariak.com/) [Vitoria-Gasteiz](http://www.vitoria-gasteiz.org/).
+
+### Durante las Fiestas ###
+
+Hay funciones diseñadas especificamente para las Fiestas de La Blanca, y solo estarán disponibles en esas fechas.
+
+* [NO IMPLEMENTADO] Consulta en tu teléfono el Programa de Fiestas, encuentra actos alrededor tuyo ydescubre como llegar hasta ellos.
+* [NO IMPLEMENTADO] Consulta el Programa de Fiestas de Gasteizko Margolariak, detallado y con la ubicación de cada actividad...
+* [NO IMPLEMENTADO] ... pero, como no somos famosos por nuestra puntualidad, comprueba nuestra ubicación en tiempo real.
+
+
+### Durante el resto del año ###
+
+* [PARCIALMENTE IMPLEMENTADO] Mantente informado de las actividades que organizamos durante el resto del año.
+* [PARCIALMENTE IMPLEMENTADO] Recibe las ultimas noticias sobre la Cuadrilla en nuestro Blog
+* [PARCIALMENTE IMPLEMENTADO] Galería de fotos de todas nuestras actividades.
+
+
+### Compatibilidad ###
+
+iOS 9.1 o superior.
+
+
+### Idiomas ###
+
+* [IMPLEMENTADO] Castellano
+* [NO IMPLEMENTADO] Inglés
+* [NO IMPLEMENTADO] Euskera 
+
+
+### Otros dispositivos ###
+
+* ¿Android? [Lo tenemos!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp) 
+* ¿Prefieres el sitio web? [No problem!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakWeb)
+

+ 43 - 0
README.es-EU.md

@@ -0,0 +1,43 @@
+---
+[Informacion en castellano](README.es-ES.md) 
+[Information in english](README.md)
+---
+
+
+# Androizko Gasteizko Margolariak aplikazioia #
+
+Una aplicacion para iOS para miembros de [Gasteizko Margolariak](https://margolariak.com/) [Vitoria-Gasteiz](http://www.vitoria-gasteiz.org/).
+
+### Durante las Fiestas ###
+
+Hay funciones diseñadas especificamente para las Fiestas de La Blanca, y solo estarán disponibles en esas fechas.
+
+* [NO IMPLEMENTADO] Consulta en tu teléfono el Programa de Fiestas, encuentra actos alrededor tuyo ydescubre como llegar hasta ellos.
+* [NO IMPLEMENTADO] Consulta el Programa de Fiestas de Gasteizko Margolariak, detallado y con la ubicación de cada actividad...
+* [NO IMPLEMENTADO] ... pero, como no somos famosos por nuestra puntualidad, comprueba nuestra ubicación en tiempo real.
+
+
+### Durante el resto del año ###
+
+* [PARCIALMENTE IMPLEMENTADO] Mantente informado de las actividades que organizamos durante el resto del año.
+* [PARCIALMENTE IMPLEMENTADO] Recibe las ultimas noticias sobre la Cuadrilla en nuestro Blog
+* [PARCIALMENTE IMPLEMENTADO] Galería de fotos de todas nuestras actividades.
+
+
+### Compatibilidad ###
+
+iOS 9.1 o superior.
+
+
+### Idiomas ###
+
+* [IMPLEMENTADO] Castellano
+* [NO IMPLEMENTADO] Inglés
+* [NO IMPLEMENTADO] Euskera 
+
+
+### Otros dispositivos ###
+
+* ¿Android? [Lo tenemos!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp) 
+* ¿Prefieres el sitio web? [No problem!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakWeb)
+

+ 33 - 14
README.md

@@ -1,26 +1,45 @@
+---
+[Información en castellano](README.es-ES.md) 
+[Informazioa euskaraz](README.es-EU.md)
+---
 
-Gasteizko Margolariak iOS App
-===
 
-An iOS app intended for members of <a href="http://margolariak.com/">Gasteizko Margolariak</a> in <a href="http://www.vitoria-gasteiz.org/">Vitoria-Gasteiz</a>, Spain.
+# Gasteizko Margolariak Android App #
 
-### Status ###
+An iOS app intended for members of [Gasteizko Margolariak](https://margolariak.com/) in [Vitoria-Gasteiz](http://www.vitoria-gasteiz.org/), Spain.
 
-In a few words: nothing works. Yet.
+### Features during the city festivals ###
 
+This features will be only available during the city festivals.
 
-### Upcaming features during the city festivals ###
+* [TODO] Check out the festival schedule, discover events all around the city, and get their location.
+* [TODO] Check out the schedule for the members of Gasteizko Margolariak, indicating the location of every event and activity...
+* [TODO] ... but, since we are not known for our puntuality, check out the location of Gasteizko Margolariak in real time.
+* [TODO] Approximate distance to important event around the city.
 
-This features wil be only available during the city festivals.
 
-* Check out the festival schedule, showing events all around the city, and indicating their location.
-* Check out the schedule for the members of Gasteizko Margolariak, indicating the location of every event and activity...
-* ... but, since we are not known for our puntuality, check out the location of Gasteizko Margolariak in real time.
+### Features for the rest of the year ###
 
+* [PARTIALLY IMPLEMENTED] Check out and be notified of all activities organized by Gasteizko Margolariak.
+* [MOSTLY IMPLEMENTED] Stay updated witho our blog.
+* [MOSTLY IMPLEMENTED] Check out our photo gallery.
 
-### Upcaming features for the rest of the year ###
 
-* Check out and be notified of all activities organized by Gasteizko Margolariak.
-* View nd comment our blog.
-* View and comment our gallery.
+### Compatibility ###
+
+iOS 9.1 or higher.
+
+
+### Languages ###
+
+* [AVAILABLE] Spanish
+* [TODO] English
+* [TODO] Basque
+
+
+### On other devices ###
+
+* Got Android? [Got you covered!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakApp) 
+* Do you prefer web pages? [No problem!](https://github.com/GasteizkoMargolariak/GasteizkoMargolariakWeb)
+
 

+ 5 - 4
Section.xib

@@ -1,5 +1,5 @@
 <?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">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -21,11 +21,11 @@
             <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="e7S-aL-6Ed" userLabel="Section">
+                <view contentMode="scaleAspectFill" translatesAutoresizingMaskIntoConstraints="NO" id="e7S-aL-6Ed" userLabel="Section">
                     <rect key="frame" x="10" y="10" width="355" height="647"/>
                     <subviews>
-                        <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" misplaced="YES" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="Titulo" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="mYX-eR-Wot">
-                            <rect key="frame" x="0.0" y="0.0" width="375" height="30"/>
+                        <textView clipsSubviews="YES" multipleTouchEnabled="YES" userInteractionEnabled="NO" contentMode="scaleToFill" bounces="NO" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" text="Titulo" textAlignment="natural" translatesAutoresizingMaskIntoConstraints="NO" id="mYX-eR-Wot">
+                            <rect key="frame" x="0.0" y="0.0" width="355" height="27"/>
                             <color key="backgroundColor" red="0.0" green="0.47058823529999999" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                             <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                             <fontDescription key="fontDescription" type="boldSystem" pointSize="14"/>
@@ -39,6 +39,7 @@
                     <color key="backgroundColor" red="0.59607843140000005" green="0.7843137255" blue="1" alpha="1" colorSpace="calibratedRGB"/>
                     <constraints>
                         <constraint firstItem="mYX-eR-Wot" firstAttribute="bottom" secondItem="hhU-TV-XGc" secondAttribute="top" id="0JC-9a-fRi" userLabel="Section_Title.bottom=Content.top"/>
+                        <constraint firstItem="mYX-eR-Wot" firstAttribute="width" secondItem="e7S-aL-6Ed" secondAttribute="width" id="0xY-43-c4D"/>
                         <constraint firstItem="mYX-eR-Wot" firstAttribute="trailing" secondItem="hhU-TV-XGc" secondAttribute="trailing" id="4VF-IP-46O" userLabel="Section_Title.trailing=Content.trailing"/>
                         <constraint firstItem="mYX-eR-Wot" firstAttribute="leading" secondItem="hhU-TV-XGc" secondAttribute="leading" id="5pZ-0J-Mc4"/>
                         <constraint firstItem="hhU-TV-XGc" firstAttribute="top" secondItem="e7S-aL-6Ed" secondAttribute="top" constant="27" id="GaL-O1-uum"/>

+ 36 - 0
app.xcodeproj/project.pbxproj

@@ -20,6 +20,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 */; };
+		935AE18A1EC6138D0055E71F /* SyncController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935AE1891EC6138D0055E71F /* SyncController.swift */; };
 		935AE18C1ECE162C0055E71F /* RowLablancaOffer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 935AE18B1ECE162B0055E71F /* RowLablancaOffer.xib */; };
 		935AE18E1ECE1F180055E71F /* RowLablancaOffer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 935AE18D1ECE1F180055E71F /* RowLablancaOffer.swift */; };
 		935D6E2D1E8678B700CED3A1 /* GalleryView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 935D6E2C1E8678B700CED3A1 /* GalleryView.xib */; };
@@ -55,6 +56,14 @@
 		93D9EA6C1DE3498500089002 /* HomeView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93D9EA6B1DE3498500089002 /* HomeView.xib */; };
 		93D9EA711DE37C7900089002 /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 93D9EA701DE37C7900089002 /* libsqlite3.tbd */; };
 		93D9EA761DE3ACBB00089002 /* Sync.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93D9EA751DE3ACBB00089002 /* Sync.swift */; };
+		93E0C5E21EB7E7F000905811 /* ActivitiesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5E11EB7E7F000905811 /* ActivitiesView.xib */; };
+		93E0C5E41EB7E94300905811 /* ActivitiesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5E31EB7E94300905811 /* ActivitiesView.swift */; };
+		93E0C5E61EBDEF2B00905811 /* RowFutureActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5E51EBDEF2B00905811 /* RowFutureActivity.swift */; };
+		93E0C5E81EBDF0E700905811 /* RowFutureActivity.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5E71EBDF0E700905811 /* RowFutureActivity.xib */; };
+		93E0C5EA1EBDFFB400905811 /* RowPastActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5E91EBDFFB300905811 /* RowPastActivity.swift */; };
+		93E0C5EC1EBE001000905811 /* RowPastActivity.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5EB1EBE000F00905811 /* RowPastActivity.xib */; };
+		93E0C5EE1EBE25BD00905811 /* RowLabel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5ED1EBE25BC00905811 /* RowLabel.swift */; };
+		93E0C5F21EBE264F00905811 /* RowLabel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93E0C5F11EBE264F00905811 /* RowLabel.xib */; };
 		93E0C5F41EBE306900905811 /* ScheduleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93E0C5F31EBE306900905811 /* ScheduleViewController.swift */; };
 		93EB2F0C1EBF5AEB00F64186 /* RowSchedule.swift in Sources */ = {isa = PBXBuildFile; fileRef = 93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */; };
 		93EB2F0E1EBF5BF500F64186 /* RowSchedule.xib in Resources */ = {isa = PBXBuildFile; fileRef = 93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */; };
@@ -74,6 +83,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>"; };
+		935AE1891EC6138D0055E71F /* SyncController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SyncController.swift; sourceTree = "<group>"; };
 		935AE18B1ECE162B0055E71F /* RowLablancaOffer.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowLablancaOffer.xib; sourceTree = "<group>"; };
 		935AE18D1ECE1F180055E71F /* RowLablancaOffer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowLablancaOffer.swift; sourceTree = "<group>"; };
 		935D6E2C1E8678B700CED3A1 /* GalleryView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = GalleryView.xib; sourceTree = "<group>"; };
@@ -111,6 +121,14 @@
 		93D9EA6B1DE3498500089002 /* HomeView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = HomeView.xib; sourceTree = "<group>"; };
 		93D9EA701DE37C7900089002 /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
 		93D9EA751DE3ACBB00089002 /* Sync.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Sync.swift; sourceTree = "<group>"; };
+		93E0C5E11EB7E7F000905811 /* ActivitiesView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ActivitiesView.xib; sourceTree = "<group>"; };
+		93E0C5E31EB7E94300905811 /* ActivitiesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivitiesView.swift; sourceTree = "<group>"; };
+		93E0C5E51EBDEF2B00905811 /* RowFutureActivity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowFutureActivity.swift; sourceTree = "<group>"; };
+		93E0C5E71EBDF0E700905811 /* RowFutureActivity.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowFutureActivity.xib; sourceTree = "<group>"; };
+		93E0C5E91EBDFFB300905811 /* RowPastActivity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowPastActivity.swift; sourceTree = "<group>"; };
+		93E0C5EB1EBE000F00905811 /* RowPastActivity.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowPastActivity.xib; sourceTree = "<group>"; };
+		93E0C5ED1EBE25BC00905811 /* RowLabel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowLabel.swift; sourceTree = "<group>"; };
+		93E0C5F11EBE264F00905811 /* RowLabel.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowLabel.xib; sourceTree = "<group>"; };
 		93E0C5F31EBE306900905811 /* ScheduleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScheduleViewController.swift; sourceTree = "<group>"; };
 		93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RowSchedule.swift; sourceTree = "<group>"; };
 		93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = RowSchedule.xib; sourceTree = "<group>"; };
@@ -194,9 +212,18 @@
 				938D211E1EA2306300C47EC3 /* LablancaView.swift */,
 				9326C4F31EA51C39007DF2A4 /* RowLablancaDay.xib */,
 				9326C4F51EA5279D007DF2A4 /* RowLablancaDay.swift */,
+				93E0C5E11EB7E7F000905811 /* ActivitiesView.xib */,
+				93E0C5E31EB7E94300905811 /* ActivitiesView.swift */,
+				93E0C5E51EBDEF2B00905811 /* RowFutureActivity.swift */,
+				93E0C5E71EBDF0E700905811 /* RowFutureActivity.xib */,
+				93E0C5E91EBDFFB300905811 /* RowPastActivity.swift */,
+				93E0C5EB1EBE000F00905811 /* RowPastActivity.xib */,
+				93E0C5ED1EBE25BC00905811 /* RowLabel.swift */,
+				93E0C5F11EBE264F00905811 /* RowLabel.xib */,
 				93E0C5F31EBE306900905811 /* ScheduleViewController.swift */,
 				93EB2F0B1EBF5AEB00F64186 /* RowSchedule.swift */,
 				93EB2F0D1EBF5BF500F64186 /* RowSchedule.xib */,
+				935AE1891EC6138D0055E71F /* SyncController.swift */,
 				935AE18B1ECE162B0055E71F /* RowLablancaOffer.xib */,
 				935AE18D1ECE1F180055E71F /* RowLablancaOffer.swift */,
 			);
@@ -272,13 +299,17 @@
 			isa = PBXResourcesBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				93E0C5E21EB7E7F000905811 /* ActivitiesView.xib in Resources */,
 				931AA5AE1E218D0E003A2290 /* Entry.xib in Resources */,
+				93E0C5E81EBDF0E700905811 /* RowFutureActivity.xib in Resources */,
 				938D211D1EA2275300C47EC3 /* LablancaView.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 */,
+				93E0C5F21EBE264F00905811 /* RowLabel.xib in Resources */,
+				93E0C5EC1EBE001000905811 /* RowPastActivity.xib in Resources */,
 				936966EF1E9848D600A11055 /* RowAlbum.xib in Resources */,
 				93D9EA601DE271E700089002 /* Section.xib in Resources */,
 				93075C6A1E59CAB000396389 /* BlogView.xib in Resources */,
@@ -308,6 +339,7 @@
 				936966F11E984B5000A11055 /* RowAlbum.swift in Sources */,
 				93D9EA641DE273FD00089002 /* Section.swift in Sources */,
 				93D9EA6A1DE3491100089002 /* HomeView.swift in Sources */,
+				93E0C5EE1EBE25BD00905811 /* RowLabel.swift in Sources */,
 				93BEB6D21E7E878300C68DE5 /* PostViewController.swift in Sources */,
 				93BAD2F81E586741009DF853 /* RowHomeSocial.swift in Sources */,
 				9326C4F61EA5279D007DF2A4 /* RowLablancaDay.swift in Sources */,
@@ -316,8 +348,10 @@
 				93B5C01A1E872B4B0069BFF8 /* RowHomeGallery.swift in Sources */,
 				935892D01E493C2300E1CD5F /* UIImageView.swift in Sources */,
 				93D9EA761DE3ACBB00089002 /* Sync.swift in Sources */,
+				93E0C5EA1EBDFFB400905811 /* RowPastActivity.swift in Sources */,
 				93BAD2F41E585EE6009DF853 /* RowHomeFutureActivities.swift in Sources */,
 				931AA5891E1AFF8C003A2290 /* String.swift in Sources */,
+				935AE18A1EC6138D0055E71F /* SyncController.swift in Sources */,
 				93B84B9C1D9C31AB006C0F67 /* ViewController.swift in Sources */,
 				93075C6C1E59CB6B00396389 /* BlogView.swift in Sources */,
 				93B84B9A1D9C31AB006C0F67 /* AppDelegate.swift in Sources */,
@@ -329,7 +363,9 @@
 				938D211F1EA2306300C47EC3 /* LablancaView.swift in Sources */,
 				935AE18E1ECE1F180055E71F /* RowLablancaOffer.swift in Sources */,
 				93075C701E59D04A00396389 /* RowBlog.swift in Sources */,
+				93E0C5E41EB7E94300905811 /* ActivitiesView.swift in Sources */,
 				93B408031D9ED44C000FBC99 /* MenuCollectionViewCell.swift in Sources */,
+				93E0C5E61EBDEF2B00905811 /* RowFutureActivity.swift in Sources */,
 				935D6E2F1E86792000CED3A1 /* GalleryView.swift in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

+ 10 - 0
app.xcodeproj/xcuserdata/seavenois.xcuserdatad/xcschemes/app.xcscheme

@@ -39,6 +39,11 @@
          </BuildableReference>
       </MacroExpansion>
       <AdditionalOptions>
+         <AdditionalOption
+            key = "NSZombieEnabled"
+            value = "YES"
+            isEnabled = "YES">
+         </AdditionalOption>
       </AdditionalOptions>
    </TestAction>
    <LaunchAction
@@ -62,6 +67,11 @@
          </BuildableReference>
       </BuildableProductRunnable>
       <AdditionalOptions>
+         <AdditionalOption
+            key = "NSZombieEnabled"
+            value = "YES"
+            isEnabled = "YES">
+         </AdditionalOption>
       </AdditionalOptions>
    </LaunchAction>
    <ProfileAction

+ 254 - 0
app/ActivitiesView.swift

@@ -0,0 +1,254 @@
+// 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 ActivitiesView: UIView {
+	
+	@IBOutlet var container: ActivitiesView!
+	@IBOutlet weak var futureSection: Section!
+	@IBOutlet weak var pastSection: Section!
+
+	var delegate: AppDelegate? = nil
+	var storyboard: UIStoryboard? = nil
+	var controller: ViewController? = nil
+	var lang: String? = nil
+	var futureList: UIStackView? = nil
+	var pastList: UIStackView? = nil
+	var context: NSManagedObjectContext? = nil
+	
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+	
+	/**
+	Run when the view is started.
+	*/
+	required init?(coder aDecoder: NSCoder) {
+		
+		super.init(coder: aDecoder)
+		
+		NSLog(":ACTIVITIES:DEBUG: init.")
+		
+		//Load the contents of the HomeView.xib file.
+		Bundle.main.loadNibNamed("ActivitiesView", owner: self, options: nil)
+		self.addSubview(container)
+		self.container.frame = self.bounds
+		self.futureSection.setTitle(text: "Próximas actividades")
+		self.pastSection.setTitle(text: "Últimas actividades")
+		self.futureList = self.futureSection.getContentStack()
+		self.pastList = self.pastSection.getContentStack()
+		
+		// Get viewController from StoryBoard
+		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
+		self.controller = self.storyboard?.instantiateViewController(withIdentifier: "GMViewController") as? ViewController
+		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.lang = self.getLanguage()
+		self.context?.persistentStoreCoordinator = self.delegate?.persistentStoreCoordinator
+
+		// Populate activity lists.
+		populate()
+	}
+		
+	func populate(){
+		// Show future activities
+		var fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
+		var sortDescriptor = NSSortDescriptor(key: "date", ascending: true)
+		var sortDescriptors = [sortDescriptor]
+		fetchRequest.sortDescriptors = sortDescriptors
+		fetchRequest.predicate = NSPredicate(format: "date > %@", NSDate())
+		
+		do {
+			let searchResults = try self.context?.fetch(fetchRequest)
+			NSLog(":ACTIVITIES:DEBUG: Total future activities: \(String(describing: searchResults?.count))")
+			if searchResults?.count == 0{
+				NSLog(":ACTIVITIES:DEBUG: No future activities: \(String(describing: searchResults?.count))")
+				let row: RowLabel = RowLabel.init(s: "rowFutureActivity0", i: 0)
+				row.setText(text: "No hay actividades planeadas proximamente. Pronto organizaremos algo!")
+				self.futureList?.addArrangedSubview(row)
+			}
+			else{
+			
+				var row : RowFutureActivity
+				var count = 0
+				var id: Int
+				var title: String
+				var text: String
+				var image: String
+				var city: String
+				var price: Int
+				var date: NSDate
+			
+				for r in searchResults! {
+					count = count + 1
+					NSLog(":ACTIVITIES:DEBUG: Activity perm: \(String(describing: r.value(forKey: "permalink")))")
+				
+					// Create a new row
+					row = RowFutureActivity.init(s: "rowFutureActivity\(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
+					city = r.value(forKey: "city")! as! String
+					price = r.value(forKey: "price")! as! Int
+					date = r.value(forKey: "date")! as! NSDate
+					row.setTitle(text: title)
+					row.setText(text: text)
+					row.setPrice(price: price)
+					row.setCity(text: city)
+					row.setDate(date: date, lang: lang!)
+				
+					// 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 self.context?.fetch(imgFetchRequest)
+						for imgR in imgSearchResults!{
+							image = imgR.value(forKey: "image")! as! String
+							NSLog(":ACTIVITIES:DEBUG: Image: \(image)")
+							row.setImage(filename: image)
+						}
+					} catch {
+						NSLog(":ACTIVITIES:ERROR: Error getting image for activity \(id): \(error)")
+					}
+				
+					self.futureList?.addArrangedSubview(row)
+					//row.setNeedsLayout()
+					//row.layoutIfNeeded()
+				
+					// TODO: Do this on the row didLoad method
+					// Set tap recognizer
+					//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openActivity(_:)))
+					//row.isUserInteractionEnabled = true
+					//row.addGestureRecognizer(tapRecognizer)
+				}
+				self.futureList?.setNeedsLayout()
+				self.futureList?.layoutIfNeeded()
+			}
+		}
+		catch {
+			NSLog(":ACTIVITIES:ERROR: Error with request: \(error)")
+		}
+		
+		
+		
+		// Show past activities
+		fetchRequest = Activity.fetchRequest()
+		sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
+		sortDescriptors = [sortDescriptor]
+		fetchRequest.sortDescriptors = sortDescriptors
+		fetchRequest.predicate = NSPredicate(format: "date < %@", NSDate())
+		
+		do {
+			let searchResults = try self.context?.fetch(fetchRequest)
+			NSLog(":ACTIVITIES:DEBUG: Total past activities: \(String(describing: searchResults?.count))")
+			
+			var row: RowPastActivity
+			var count: Int = 0
+			var id: Int
+			var title: String
+			var text: String
+			var image: String
+			
+			for r in searchResults! {
+				count = count + 1
+				NSLog(":ACTIVITIES:DEBUG: Activity perm: \(String(describing: r.value(forKey: "permalink")))")
+				
+				// Create a new row
+				row = RowPastActivity.init(s: "rowPastActivity\(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<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 self.context?.fetch(imgFetchRequest)
+					for imgR in imgSearchResults!{
+						image = imgR.value(forKey: "image")! as! String
+						NSLog(":ACTIVITIES:DEBUG: Image: \(image)")
+						row.setImage(filename: image)
+					}
+				}
+				catch {
+					NSLog(":ACTIVITIES:ERROR: Error getting image for activity \(id): \(error)")
+				}
+				
+				NSLog(":ACTIVITIES:DEBUG: Row height: \(row.frame.height)")
+				
+				self.pastList?.addArrangedSubview(row)
+				//row.setNeedsLayout()
+				//row.layoutIfNeeded()
+				
+				// TODO: Do this on the row didLoad method
+				// Set tap recognizer
+				//let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openActivity(_:)))
+				//row.isUserInteractionEnabled = true
+				//row.addGestureRecognizer(tapRecognizer)
+			}
+			self.pastList?.setNeedsLayout()
+			self.pastList?.layoutIfNeeded()
+		} catch {
+			NSLog(":ACTIVITIES:ERROR: Error with request: \(error)")
+		}
+		NSLog(":ACTIVITIES:DEBUG: Finished loading ActivitiesView")
+	}
+	
+	/*func openActivity(){//(_ sender:UITapGestureRecognizer? = nil){
+		NSLog(":ACTIVITIES:DEBUG: getting delegate and showing activity.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showActivity(id: 4)
+		NSLog(":ACTIVITIES:DEBUG: Activity should be shown.")
+	}
+	
+	func openActivity(_ sender:UITapGestureRecognizer? = nil){
+		NSLog(":ACTIVITIES:DEBUG: getting delegate and showing activity.")
+		let delegate: AppDelegate = UIApplication.shared.delegate as! AppDelegate
+		delegate.controller?.showActivity(id: 4)
+		NSLog(":ACTIVITIES:DEBUG: Activity 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"
+		}
+	}
+}

+ 60 - 0
app/ActivitiesView.xib

@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" 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="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="ActivitiesView" customModule="app">
+            <connections>
+                <outlet property="container" destination="iN0-l3-epB" id="7AX-8i-BPU"/>
+                <outlet property="futureSection" destination="Jdf-74-tJS" id="WNV-uv-XXg"/>
+                <outlet property="pastSection" destination="0Su-Ex-4hq" id="3vd-uB-fTu"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
+            <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+            <subviews>
+                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xyM-cc-W1r">
+                    <rect key="frame" x="0.0" y="0.0" width="375" height="666"/>
+                    <subviews>
+                        <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="gvi-ij-s5Q">
+                            <rect key="frame" x="0.0" y="0.0" width="375" height="306"/>
+                            <subviews>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Jdf-74-tJS" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="0.0" width="375" height="50"/>
+                                </view>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="0Su-Ex-4hq" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="50" width="375" height="256"/>
+                                </view>
+                            </subviews>
+                            <constraints>
+                                <constraint firstItem="0Su-Ex-4hq" firstAttribute="top" secondItem="Jdf-74-tJS" secondAttribute="bottom" constant="10" id="Vwq-bc-l9J"/>
+                                <constraint firstAttribute="bottom" secondItem="0Su-Ex-4hq" secondAttribute="bottom" id="YXW-7I-LlA"/>
+                            </constraints>
+                        </stackView>
+                    </subviews>
+                    <constraints>
+                        <constraint firstAttribute="bottom" secondItem="gvi-ij-s5Q" secondAttribute="bottom" id="dLo-VU-AFT"/>
+                        <constraint firstAttribute="trailing" secondItem="gvi-ij-s5Q" secondAttribute="trailing" id="iKv-jf-8lN"/>
+                        <constraint firstItem="gvi-ij-s5Q" firstAttribute="top" secondItem="xyM-cc-W1r" secondAttribute="top" id="nBi-D9-aFk"/>
+                    </constraints>
+                </scrollView>
+            </subviews>
+            <constraints>
+                <constraint firstItem="gvi-ij-s5Q" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="4bi-AV-eh4"/>
+                <constraint firstItem="xyM-cc-W1r" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="6Qm-1G-beA"/>
+                <constraint firstItem="xyM-cc-W1r" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="92C-lK-w4Q"/>
+                <constraint firstItem="gvi-ij-s5Q" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Iab-hX-fdC"/>
+                <constraint firstItem="xyM-cc-W1r" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="iKU-OG-Vpz"/>
+                <constraint firstItem="xyM-cc-W1r" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="q5m-cP-yKY"/>
+            </constraints>
+        </view>
+    </objects>
+</document>

+ 12 - 8
app/Base.lproj/Main.storyboard

@@ -257,10 +257,10 @@
                         <viewControllerLayoutGuide type="top" id="OhA-Gv-fwb"/>
                         <viewControllerLayoutGuide type="bottom" id="3Yd-97-laW"/>
                     </layoutGuides>
-                    <view key="view" contentMode="scaleToFill" id="e8E-bp-zJI">
+                    <view key="view" contentMode="scaleToFill" id="e8E-bp-zJI" customClass="ActivitiesView" 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="0.4079896717" green="1" blue="0.34807942549999998" 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="iuX-Se-nlc" userLabel="First Responder" sceneMemberID="firstResponder"/>
@@ -326,7 +326,7 @@
                                         </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"/>
+                                        <rect key="frame" x="48" y="0.0" width="224" height="30"/>
                                         <fontDescription key="fontDescription" type="boldSystem" pointSize="17"/>
                                         <color key="textColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
                                         <nil key="highlightedColor"/>
@@ -959,7 +959,7 @@
         <!--Sync-->
         <scene sceneID="cqg-BI-2xm">
             <objects>
-                <viewController title="Sync" id="3o1-ab-AT4" sceneMemberID="viewController">
+                <viewController title="Sync" id="3o1-ab-AT4" customClass="SyncController" customModule="app" customModuleProvider="target" sceneMemberID="viewController">
                     <layoutGuides>
                         <viewControllerLayoutGuide type="top" id="RYy-ax-Nya"/>
                         <viewControllerLayoutGuide type="bottom" id="rXD-89-8EQ"/>
@@ -969,10 +969,10 @@
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <subviews>
                             <imageView userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="Logo" translatesAutoresizingMaskIntoConstraints="NO" id="dxh-Z0-luU">
-                                <rect key="frame" x="48" y="242.5" width="224" height="83"/>
+                                <rect key="frame" x="48" y="243" width="224" height="83"/>
                             </imageView>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Sincronizando..." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="up0-1V-tTd">
-                                <rect key="frame" x="0.0" y="335.5" width="320" height="30"/>
+                                <rect key="frame" x="0.0" y="336" width="320" height="30"/>
                                 <constraints>
                                     <constraint firstAttribute="height" constant="30" id="mIj-oN-tq7"/>
                                 </constraints>
@@ -981,10 +981,10 @@
                                 <nil key="highlightedColor"/>
                             </label>
                             <progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="VkR-DT-y3S">
-                                <rect key="frame" x="48" y="375.5" width="224" height="2"/>
+                                <rect key="frame" x="48" y="376" width="224" height="2"/>
                             </progressView>
                             <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Message" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pgU-dx-MvQ">
-                                <rect key="frame" x="48" y="385.5" width="224" height="18"/>
+                                <rect key="frame" x="48" y="386" width="224" height="18"/>
                                 <fontDescription key="fontDescription" type="italicSystem" pointSize="15"/>
                                 <color key="textColor" red="0.31238102791878175" green="0.31238102791878175" blue="0.31238102791878175" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
                                 <nil key="highlightedColor"/>
@@ -1006,6 +1006,10 @@
                             <constraint firstItem="pgU-dx-MvQ" firstAttribute="top" secondItem="VkR-DT-y3S" secondAttribute="bottom" constant="8" id="wts-Yk-LsB"/>
                         </constraints>
                     </view>
+                    <connections>
+                        <outlet property="lb" destination="pgU-dx-MvQ" id="ATL-SS-rxd"/>
+                        <outlet property="pb" destination="VkR-DT-y3S" id="NMd-7R-Rlc"/>
+                    </connections>
                 </viewController>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="fRm-1Y-Xmm" userLabel="First Responder" sceneMemberID="firstResponder"/>
             </objects>

+ 51 - 77
app/BlogView.swift

@@ -26,20 +26,18 @@ Class to handle the home view.
 */
 class BlogView: UIView {
 	
-	//var window:UIWindow?
 	
-	//The main scroll view.
+	// Outlets
 	@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
+	var postList: UIStackView? = nil
+	var storyboard: UIStoryboard? = nil
+	var controller: ViewController? = nil
+	var context: NSManagedObjectContext? = nil;
+	var lang: String? = nil
 	
 	override init(frame: CGRect){
 		super.init(frame: frame)
@@ -51,37 +49,44 @@ class BlogView: UIView {
 	required init?(coder aDecoder: NSCoder) {
 		
 		super.init(coder: aDecoder)
+		NSLog(":BLOG:DEBUG: init (coder).")
 		
-		print("BLOG:DEBUG: init.")
-		
-		//Load the contents of the HomeView.xib file.
+		// 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()
+		self.addSubview(self.container)
+		self.container.frame = self.bounds
+		self.section.setTitle(text: "Blog")
+		self.postList = self.section.getContentStack()
 		
 		// Get viewController from StoryBoard
-		let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
-		let controller = storyboard.instantiateViewController(withIdentifier: "GMViewController") as! ViewController
+		self.storyboard = UIStoryboard(name: "Main", bundle: nil)
+		self.controller = storyboard?.instantiateViewController(withIdentifier: "GMViewController") as? ViewController
+		self.context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.lang = getLanguage()
+		self.context?.persistentStoreCoordinator = delegate?.persistentStoreCoordinator
 		
-		// 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
+		populate()
+		
+		NSLog(":BLOG:DEBUG: Finished loading BlogView")
+		
+	}
+	
+	func populate(){
 		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)
+			// Clear the list
+			for v in (self.postList?.subviews)!{
+				v.removeFromSuperview()
+			}
 			
-			//I like to check the size of the returned results!
-			print ("BLOG:DEBUG: Total posts: \(searchResults.count)")
+			// Get the results
+			let searchResults = try self.context?.fetch(fetchRequest)			
+			NSLog(":BLOG:DEBUG: Total posts: \(String(describing: searchResults?.count))")
 			
 			var row : RowBlog
 			var count = 0
@@ -90,18 +95,15 @@ class BlogView: UIView {
 			var text: String
 			var image: String
 			
-			//You need to convert to NSManagedObject to use 'for' loops
-			for r in searchResults as [NSManagedObject] {
+			for r in searchResults! {
 				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"))")
-				
-				
+				NSLog(":BLOG:DEBUG: Post perm: \(String(describing: 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
+				title = r.value(forKey: "title_\(lang!)")! as! String
+				text = r.value(forKey: "text_\(lang!)")! as! String
 				row.setTitle(text: title)
 				row.setText(text: text)
 				
@@ -114,21 +116,20 @@ class BlogView: UIView {
 				imgFetchRequest.predicate = NSPredicate(format: "post == %i", id)
 				imgFetchRequest.fetchLimit = 1
 				do{
-					let imgSearchResults = try context.fetch(imgFetchRequest)
-					for imgR in imgSearchResults as [NSManagedObject]{
+					let imgSearchResults = try context?.fetch(imgFetchRequest)
+					for imgR in imgSearchResults!{
 						image = imgR.value(forKey: "image")! as! String
-						print ("BLOG:DEBUG: Image: \(image)")
+						NSLog(":BLOG:DEBUG: Image: \(image)")
 						row.setImage(filename: image)
 					}
 				} catch {
-					print("BLOG:ERROR: Error getting image for post \(id): \(error)")
+					NSLog(":BLOG:ERROR: Error getting image for post \(id): \(error)")
 				}
 				
-				print("BLOG:DEBUG: Row height: \(row.frame.height)")
 				
-				parent.addArrangedSubview(row)
-				row.setNeedsLayout()
-				row.layoutIfNeeded()
+				self.postList?.addArrangedSubview(row)
+				//row.setNeedsLayout()
+				//row.layoutIfNeeded()
 				
 				// TODO: Do this on the row didLoad method
 				// Set tap recognizer
@@ -139,37 +140,15 @@ class BlogView: UIView {
 				
 				
 			}
+
+			// Trigger a layout update
+			postList?.setNeedsLayout()
+			postList?.layoutIfNeeded()
+
 		} 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)")
+			NSLog(":BLOG:ERROR: Error with request: \(error)")
 		}
-		// 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")
+		NSLog(":BLOG:DEBUG: Finished populating BlogView")
 	}
 	
 	/*func openPost(){//(_ sender:UITapGestureRecognizer? = nil){
@@ -195,9 +174,4 @@ class BlogView: UIView {
 			return "es"
 		}
 	}
-	
-	func setController(controller: ViewController){
-		
-		//self.controller = controller
-	}
 }

+ 17 - 14
app/BlogView.xib

@@ -1,6 +1,6 @@
 <?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">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
+    <device id="retina5_5" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
     <dependencies>
@@ -18,33 +18,33 @@
         </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"/>
+            <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
             <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"/>
+                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="V2d-fd-cjO">
+                    <rect key="frame" x="0.0" y="0.0" width="414" height="736"/>
                     <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"/>
+                        <stackView contentMode="scaleToFill" ambiguous="YES" misplaced="YES" axis="vertical" alignment="center" translatesAutoresizingMaskIntoConstraints="NO" id="Iqa-PQ-TOo">
+                            <rect key="frame" x="0.0" y="0.0" width="414" 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>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="xlt-p5-m6w" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="0.0" width="414" height="2200"/>
                                     <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"/>
+                                <constraint firstItem="xlt-p5-m6w" firstAttribute="centerX" secondItem="Iqa-PQ-TOo" secondAttribute="centerX" id="cHf-jr-BYh"/>
+                                <constraint firstItem="xlt-p5-m6w" firstAttribute="width" secondItem="Iqa-PQ-TOo" secondAttribute="width" id="i9f-Kl-gsH"/>
                             </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="trailing" secondItem="V2d-fd-cjO" secondAttribute="trailing" id="NAr-lB-8Ty"/>
+                        <constraint firstItem="xlt-p5-m6w" firstAttribute="width" secondItem="V2d-fd-cjO" secondAttribute="width" id="beG-GV-zBi"/>
+                        <constraint firstItem="xlt-p5-m6w" firstAttribute="centerX" secondItem="V2d-fd-cjO" secondAttribute="centerX" id="tjw-ff-7cu"/>
                         <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>
@@ -54,8 +54,11 @@
                 <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="Iqa-PQ-TOo" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="iYG-LX-UH4"/>
                 <constraint firstItem="V2d-fd-cjO" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="kdV-ei-kvf"/>
+                <constraint firstItem="Iqa-PQ-TOo" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="uJX-4Y-e2l"/>
             </constraints>
+            <point key="canvasLocation" x="35.5" y="53.5"/>
         </view>
     </objects>
 </document>

+ 10 - 9
app/GalleryView.xib

@@ -1,5 +1,5 @@
 <?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">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
     <device id="retina4_7" orientation="portrait">
         <adaptation id="fullscreen"/>
     </device>
@@ -21,17 +21,14 @@
             <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
             <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
             <subviews>
-                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aoy-Mh-gpR">
+                <scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" alwaysBounceVertical="YES" showsHorizontalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="aoy-Mh-gpR">
                     <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                     <subviews>
-                        <stackView opaque="NO" contentMode="scaleToFill" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ULw-PH-L95">
-                            <rect key="frame" x="0.0" y="0.0" width="320" height="3000"/>
+                        <stackView opaque="NO" contentMode="scaleToFill" ambiguous="YES" misplaced="YES" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="ULw-PH-L95">
+                            <rect key="frame" x="0.0" y="0.0" width="375" height="3000"/>
                             <subviews>
-                                <view autoresizesSubviews="NO" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3TY-0K-6q1" customClass="Section" customModule="app">
-                                    <rect key="frame" x="0.0" y="0.0" width="320" height="3000"/>
-                                    <constraints>
-                                        <constraint firstAttribute="height" constant="3000" id="vPf-aG-EZ9"/>
-                                    </constraints>
+                                <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="3TY-0K-6q1" customClass="Section" customModule="app">
+                                    <rect key="frame" x="0.0" y="0.0" width="375" height="3000"/>
                                     <edgeInsets key="layoutMargins" top="8" left="8" bottom="8" right="8"/>
                                 </view>
                             </subviews>
@@ -55,7 +52,11 @@
                 <constraint firstItem="aoy-Mh-gpR" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" id="53f-dW-QfI"/>
                 <constraint firstItem="aoy-Mh-gpR" firstAttribute="height" secondItem="iN0-l3-epB" secondAttribute="height" id="JAc-a5-eSB"/>
                 <constraint firstItem="aoy-Mh-gpR" firstAttribute="top" secondItem="iN0-l3-epB" secondAttribute="top" id="KbH-35-FjR"/>
+                <constraint firstItem="ULw-PH-L95" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="Pmm-8v-Nel"/>
+                <constraint firstItem="3TY-0K-6q1" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="SuI-4Q-EhS"/>
                 <constraint firstItem="aoy-Mh-gpR" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="ftc-db-cKU"/>
+                <constraint firstItem="3TY-0K-6q1" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="uuX-zc-aKY"/>
+                <constraint firstItem="ULw-PH-L95" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="xne-RG-cs4"/>
             </constraints>
         </view>
     </objects>

+ 125 - 95
app/HomeView.swift

@@ -21,45 +21,55 @@
 import Foundation
 import CoreData
 import UIKit
+
+
 /**
- Class to handle the home view.
- */
+Class to handle the home view.
+*/
 class HomeView: UIView {
 	
-	//The main scroll view.
-	@IBOutlet weak var scrollView: UIScrollView!
+	// Outlets
+	@IBOutlet var scrollView: UIScrollView!
+	@IBOutlet var container: UIView!
+	@IBOutlet var locationSection: Section!
+	@IBOutlet var lablancaSection: Section!
+	@IBOutlet var futureActivitiesSection: Section!
+	@IBOutlet var blogSection: Section!
+	@IBOutlet var gallerySection: Section!
+	@IBOutlet var pastActivitiesSection: Section!
+	@IBOutlet var socialSection: Section!
+
+	var lang: String? = nil
+	var moc: NSManagedObjectContext? = nil
+	var appDelegate: AppDelegate? = nil
 	
-	//The container of the view.
-	@IBOutlet weak var container: UIView!
+	let dbgTxt = "IVV"
 	
-	//Each of the sections of the view.
-	@IBOutlet weak var locationSection: Section!
-	@IBOutlet weak var lablancaSection: Section!
-	@IBOutlet weak var futureActivitiesSection: Section!
-	@IBOutlet weak var blogSection: Section!
-	@IBOutlet weak var gallerySection: Section!
-	@IBOutlet weak var pastActivitiesSection: Section!
-	@IBOutlet weak var socialSection: Section!
 	
+	/**
+	Run when the view is started.
+	:param: frame Frame for the view.
+	*/
 	override init(frame: CGRect){
 		super.init(frame: frame)
 	}
 	
+	
 	/**
-	 Run when the view is started.
+	Run when the view is started.
+	:param: coder Application decoder.
 	*/
 	required init?(coder aDecoder: NSCoder) {
 		
 		super.init(coder: aDecoder)
 		
-		//Load the contents of the HomeView.xib file.
+		// Load the contents of the HomeView.xib file.
 		Bundle.main.loadNibNamed("HomeView", owner: self, options: nil)
 		self.addSubview(container)
-		container.frame = self.bounds
+		self.container.frame = self.bounds
 		
 
-		
-		//Set titles for each section
+		// Set titles for each section
 		locationSection.setTitle(text: "Encuentranos")
 		lablancaSection.setTitle(text: "La Blanca")
 		futureActivitiesSection.setTitle(text: "Proximas actividades")
@@ -68,35 +78,53 @@ class HomeView: UIView {
 		pastActivitiesSection.setTitle(text: "Ultimas actividades")
 		socialSection.setTitle(text: "Siguenos")
 		
-		//Get info to populate sections
-		let moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		// Get info to populate sections
+		self.moc = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		self.appDelegate = UIApplication.shared.delegate as! AppDelegate
+		self.moc?.persistentStoreCoordinator = appDelegate?.persistentStoreCoordinator
+		self.lang = getLanguage()
 		
-		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())
-		setUpGallery(context: moc, delegate: appDelegate, parent: gallerySection.getContentStack())
-		
-		
-		pastActivitiesSection.expandSection()
+		// Populate sections
+		self.populate()
 		
 		
 		//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("curh: \(h)")
-		}
+		//var h: Int = 0
+		//for view in scrollView.subviews {
+		//	//contentRect = contentRect.union(view.frame);
+		//	h = h + Int(view.frame.height) + 30 //Why 30?
+		//	print("curh: \(h)")
+		//}
 		// TODO: Calculate at the end
-		self.scrollView.contentSize.height = 1300// CGFloat(h);
+		//self.scrollView.contentSize.height = 1300// CGFloat(h);
 	}
+
 	
+	func populate2(){
+		NSLog(":HOME:DEBUG: Dummy Populating home view.")
+	}
+	
+	/**
+	Triggers a reloading (or initial loading) of all sections.
+	*/
+	open func populate(){
+		
+		NSLog(":HOME:DEBUG: Populating home view.")
+		
+		//Populate sections
+		self.setUpPastActivities(context: self.moc!, delegate: appDelegate!, lang: self.lang!, parent: self.pastActivitiesSection.getContentStack())
+		self.setUpBlog(context: self.moc!, delegate: self.appDelegate!, lang: self.lang!, parent: self.blogSection.getContentStack())
+		self.setUpFutureActivities(context: self.moc!, delegate: self.appDelegate!, lang: self.lang!, parent: self.futureActivitiesSection.getContentStack())
+		self.setUpSocial(parent: self.socialSection.getContentStack())
+		self.setUpGallery(context: self.moc!, delegate: self.appDelegate!, parent: self.gallerySection.getContentStack())
+		self.pastActivitiesSection.expandSection()
+	}
+	
+	
+	/**
+	Retrieves the device language. The only available ones are Spanish, English and Basque.
+	:return: Two letter language code (en, eu, es). If other, spanish will be selected.
+	*/
 	func getLanguage() -> String{
 		let pre = NSLocale.preferredLanguages[0].subStr(start: 0, end: 1)
 		if(pre == "es" || pre == "en" || pre == "eu"){
@@ -107,9 +135,17 @@ class HomeView: UIView {
 		}
 	}
 	
+	
+	/**
+	Sets the future activities section.
+	Loads up to two future activities.
+	:param: context Aplication context.
+	:param: delegate Application delegate.
+	:param: lang Device language. Two letter code. Accepts 'es', 'en' and 'eu'.
+	:param: parent View where the rows will be loaded.
+	*/
 	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]
@@ -118,11 +154,8 @@ class HomeView: UIView {
 		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)")
+			NSLog(":HOME:DEBUG: Future activity count: \(searchResults.count)")
 			
 			var row : RowHomePastActivities
 			var count = 0
@@ -131,19 +164,14 @@ class HomeView: UIView {
 			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)
 				
@@ -159,26 +187,30 @@ class HomeView: UIView {
 					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)")
+					NSLog(":HOME:ERROR: Error getting image for futureactivity \(id): \(error)")
 				}
-				
-				print("Row height: \(row.frame.height)")
-				
 				parent.addArrangedSubview(row)
 				
 			}
 		} catch {
-			print("Error with request: \(error)")
+			NSLog(":HOME:ERROR: Error setting the future activities section up: \(error)")
 		}
 	}
 	
+	
+	/**
+	Sets the blog section.
+	Loads up to two posts.
+	:param: context Aplication context.
+	:param: delegate Application delegate.
+	:param: lang Device language. Two letter code. Accepts 'es', 'en' and 'eu'.
+	:param: parent View where the rows will be loaded.
+	*/
 	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]
@@ -186,11 +218,8 @@ class HomeView: UIView {
 		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)")
+			NSLog(":HOME:DEBUG: Post count: \(searchResults.count)")
 			
 			var row : RowHomeBlog
 			var count = 0
@@ -199,12 +228,8 @@ class HomeView: UIView {
 			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)
@@ -228,15 +253,12 @@ class HomeView: UIView {
 					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)")
+					NSLog(":HOME:ERROR: Error getting image for post \(id): \(error)")
 				}
 				
-				print("Row height: \(row.frame.height)")
-				
 				parent.addArrangedSubview(row)
 				
 				let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(openPost(_:)))
@@ -245,13 +267,21 @@ class HomeView: UIView {
 				
 			}
 		} catch {
-			print("Error with request: \(error)")
+			NSLog(":HOME:ERROR: Error setting the blog section up: \(error)")
 		}
 	}
 	
+	
+	/**
+	Sets the past activities section.
+	Loads up to two past activities.
+	:param: context Aplication context.
+	:param: delegate Application delegate.
+	:param: lang Device language. Two letter code. Accepts 'es', 'en' and 'eu'.
+	:param: parent View where the rows will be loaded.
+	*/
 	func setUpPastActivities(context : NSManagedObjectContext, delegate: AppDelegate, lang: String, parent : UIStackView){
 		
-		//context.persistentStoreCoordinator = delegate.persistentStoreCoordinator
 		let fetchRequest: NSFetchRequest<Activity> = Activity.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "date", ascending: false)
 		let sortDescriptors = [sortDescriptor]
@@ -260,11 +290,8 @@ class HomeView: UIView {
 		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)")
+			NSLog(":HOME:LOG: Setting past activities up. Count: \(searchResults.count)")
 			
 			var row : RowHomePastActivities
 			var count = 0
@@ -273,12 +300,8 @@ class HomeView: UIView {
 			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: "rowHomePastActivities\(count)", i: count)
@@ -302,32 +325,35 @@ class HomeView: UIView {
 					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)")
+					NSLog(":HOME:ERROR: Error getting image for past activity \(id): \(error)")
 				}
 				
-				print("Row height: \(row.frame.height)")
-				
 				parent.addArrangedSubview(row)
 				
 			}
 		} catch {
-			print("Error with request: \(error)")
+			NSLog(":HOME:ERROR: Error setting the past activities section up: \(error)")
 		}
 	}
 	
+	/**
+	Sets the fgallery section.
+	Loads up to four photos.
+	:param: context Aplication context.
+	:param: delegate Application delegate.
+	:param: parent View where the rows will be loaded.
+	*/
 	func setUpGallery(context : NSManagedObjectContext, delegate: AppDelegate,parent: UIStackView){
-		print("HOME:LOG: Setting up gallery.")
+		NSLog(":HOME:LOG: Setting gallery section up.")
 		
 		// Create the row
 		var row: RowHomeGallery
 		row = RowHomeGallery.init(s: "rowHomeGallery", i: 0)
 		parent.addArrangedSubview(row)
 		
-		
 		// Set images
 		let fetchRequest: NSFetchRequest<Photo> = Photo.fetchRequest()
 		let sortDescriptor = NSSortDescriptor(key: "uploaded", ascending: false)
@@ -336,10 +362,7 @@ class HomeView: UIView {
 		fetchRequest.fetchLimit = 4
 		
 		do {
-			//go get the results
 			let searchResults = try context.fetch(fetchRequest)
-	
-			var id: Int
 			var image: String
 			
 			// Loop images
@@ -356,24 +379,31 @@ class HomeView: UIView {
 			
 		}
 		catch{
-			print("HOME:ERROR: Error setting gallery up: \(error)")
+			NSLog(":HOME:ERROR: Error setting gallery up: \(error)")
 		}
 		
 	}
 	
+	/**
+	Sets the social section.
+	:param: parent View where the rows will be loaded.
+	*/
 	func setUpSocial(parent : UIStackView){
-		print("SETING UP SOCIAL")
+		NSLog(":HOME:LOG: Setting soceial section up.")
 		//Create a new row
 		var row : RowHomeSocial
 		row = RowHomeSocial.init(s: "rowHomeSocial", i: 0)
-		print("ROW CREATED")
 		parent.addArrangedSubview(row)
 	}
 	
+	/**
+	opens the blog section, showing a post.
+	:param: sender: View calling the function.
+	*/
 	func openPost(_ sender:UITapGestureRecognizer? = nil){
-		print("HOME:DEBUG: getting delegate and showing post.")
+		NSLog(":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.")
+		NSLog(":HOME:DEBUG: Post should be shown.")
 	}
 }

+ 6 - 6
app/HomeView.xib

@@ -1,15 +1,15 @@
 <?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">
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" 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"/>
+        <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
         <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
     </dependencies>
     <objects>
-        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HomeView" customModule="app" customModuleProvider="target">
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner">
             <connections>
                 <outlet property="blogSection" destination="uHa-Mu-U68" id="RUp-Jg-AxI"/>
                 <outlet property="container" destination="iN0-l3-epB" id="cfT-rm-jA0"/>
@@ -23,17 +23,17 @@
             </connections>
         </placeholder>
         <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
-        <view contentMode="scaleToFill" id="iN0-l3-epB">
+        <view contentMode="scaleToFill" id="iN0-l3-epB" customClass="HomeView" customModule="app">
             <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" 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" ambiguous="YES" misplaced="YES" axis="vertical" alignment="center" spacing="10" translatesAutoresizingMaskIntoConstraints="NO" id="gOz-rr-CeQ">
+                        <stackView opaque="NO" contentMode="scaleToFill" ambiguous="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" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Ljm-NP-c4e" customClass="Section" customModule="app">
+                                <view 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" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="9nu-j1-wGI" customClass="Section" customModule="app">

+ 2 - 2
app/Info.plist

@@ -17,9 +17,9 @@
 	<key>CFBundlePackageType</key>
 	<string>APPL</string>
 	<key>CFBundleShortVersionString</key>
-	<string>1.0</string>
+	<string>0.0.3</string>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>4</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>UILaunchStoryboardName</key>

+ 197 - 0
app/RowFutureActivity.swift

@@ -0,0 +1,197 @@
+// 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 RowFutureActivity: UIView {
+	
+	//This view
+	var v: UIView!
+
+	// Outlets
+	@IBOutlet weak var container: UIView!
+	@IBOutlet weak var title: UILabel!
+	@IBOutlet weak var image: UIImageView!
+	@IBOutlet weak var descript: UILabel!
+	@IBOutlet weak var date: UILabel!
+	@IBOutlet weak var city: UILabel!
+	@IBOutlet weak var price: UILabel!
+	
+	/**
+	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
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = self.bounds
+		self.addSubview(container)
+		
+		// Set tap recognizer
+		/*print("ROW_FUTURE_ACTIVITY:DEBUG: set tap recognizer")
+		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (self.openActivity (_:)))
+		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 activity. Decodes HTML.
+	:param: text The new title.
+	*/
+	func setTitle(text: String){
+		self.title.text = text.stripHtml()
+	}
+	
+	/**
+	Sets the city of the activity.
+	:param: text The city.
+	*/
+	func setCity(text: String){
+		self.city.text = text
+	}
+	
+	/**
+	Sets the price of the activity.
+	:param: price The price, in Euros. If 0, nothing is shown.
+	*/
+	func setPrice(price: Int){
+		if price != 0{
+			self.price.text = "\(price) €"
+		}
+		else{
+			self.price.text = ""
+		}
+	}
+	
+	/**
+	Changes the description of the activity. Decodes HTML.
+	:param: text The new text.
+	*/
+	func setText(text: String){
+		self.descript.text = text.stripHtml()
+	}
+	
+	/**
+	Sets the date of the activity in a human readable format.
+	:param: text The date.
+	:param: lang Device language.
+	*/
+	func setDate(date: NSDate, lang: String){
+		
+		let dateformatter = DateFormatter()
+		
+		let months_es = ["0index", "enero", "febrero", "marzo", "abril", "mayo", "junio", "julio", "agosto", "septiembre", "octubre", "noviembre", "diciembre"]
+		let months_en = ["0index", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
+		let months_eu = ["0index", "urtarrilaren", "otsailaren", "martxoaren", "abrilaren", "maiatzaren", "ekainaren", "ustailaren", "abustuaren", "irailaren", "urriaren", "azaroaren", "abenduaren"]
+		let days_es = ["0index", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sábado", "Domingo"]
+		let days_en = ["0index", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
+		let days_eu = ["0index", "Astelehena", "Asteartea", "Asteazkena", "Osteguna", "Ostirala", "Larumbata", "Igandea"]
+		
+		let calendar = Calendar.current
+		let day = calendar.component(.day, from: date as Date)
+		let month = calendar.component(.month, from: date as Date)
+		let weekday = calendar.component(.weekday, from: date as Date)
+		var strDate = ""
+		
+		switch lang{
+			case "en":
+				
+				var dayNum = ""
+				switch day{
+					case 1:
+						dayNum = "1th"
+						break
+					case 2:
+						dayNum = "2nd"
+						break;
+					case 3:
+						dayNum = "3rd"
+						break;
+					default:
+						dayNum = "\(weekday)th"
+				}
+				
+				strDate = "\(days_en[weekday]), \(months_en[month]) \(dayNum)"
+				break
+			case "eu":
+				strDate = "\(days_eu[weekday]) \(months_eu[month]) \(day)an"
+				break
+			default:
+				strDate = "\(days_es[weekday]) \(day) de \(months_es[month])"
+		}
+		
+		self.date.text = strDate
+	}
+	
+	/**
+	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 == ""){
+			NSLog("ROW_FUTURE_ACTIVITY:DEBUG: No image")
+			//TODO hide the imageview
+		}
+		else{
+			NSLog(":ROW_FUTURE_ACTIVITY:DEBUG: Set image \(filename)")
+			let path = "img/actividades/thumb/\(filename)"
+			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+		}
+	}
+	
+	func openActivity(_ sender:UITapGestureRecognizer? = nil){
+		NSLog(":ROW_FUTURE_ACTIVITY:DEBUG: open activity")
+	}
+}

+ 135 - 0
app/RowFutureActivity.xib

@@ -0,0 +1,135 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" 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="RowFutureActivity" customModule="app">
+            <connections>
+                <outlet property="city" destination="VQF-xA-wca" id="evN-BP-6An"/>
+                <outlet property="container" destination="LXM-17-fy1" id="4qg-I3-wo0"/>
+                <outlet property="date" destination="pCj-dq-5rF" id="4Cg-kn-D3p"/>
+                <outlet property="descript" destination="m6I-vy-k36" id="9rq-LM-8kb"/>
+                <outlet property="image" destination="xIf-kY-gPW" id="Kzl-DN-26C"/>
+                <outlet property="price" destination="U3K-kD-4pK" id="aV5-sa-dbD"/>
+                <outlet property="title" destination="Vd3-c0-iYd" id="jnK-lJ-Fav"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <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="LXM-17-fy1" userLabel="Container">
+                    <rect key="frame" x="0.0" y="263.5" width="375" height="140"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Oax-mA-mEd" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="140"/>
+                            <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="Vd3-c0-iYd" 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>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="pCj-dq-5rF" userLabel="Date">
+                                    <rect key="frame" x="14.5" y="32" width="325" height="21"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <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="xIf-kY-gPW" userLabel="Image">
+                                    <rect key="frame" x="10" y="53" width="71" height="64"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="64" id="GGt-lC-syI"/>
+                                    </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="m6I-vy-k36" userLabel="Text">
+                                    <rect key="frame" x="97" y="53" width="248" height="21"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <nil key="textColor"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VQF-xA-wca" userLabel="City">
+                                    <rect key="frame" x="20" y="119" width="275" height="21"/>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="U3K-kD-4pK" userLabel="Price">
+                                    <rect key="frame" x="285" y="119" width="50" height="21"/>
+                                    <constraints>
+                                        <constraint firstAttribute="width" constant="50" id="uI7-D4-q0g"/>
+                                    </constraints>
+                                    <fontDescription key="fontDescription" type="system" pointSize="17"/>
+                                    <color key="textColor" red="0.1529411765" green="0.33333333329999998" blue="0.45098039220000002" alpha="1" colorSpace="calibratedRGB"/>
+                                    <nil key="highlightedColor"/>
+                                </label>
+                            </subviews>
+                            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+                            <constraints>
+                                <constraint firstItem="VQF-xA-wca" firstAttribute="width" secondItem="Oax-mA-mEd" secondAttribute="width" constant="-80" id="1bi-lD-f66"/>
+                                <constraint firstItem="pCj-dq-5rF" firstAttribute="top" secondItem="Vd3-c0-iYd" secondAttribute="bottom" id="2SS-dr-xRe"/>
+                                <constraint firstItem="Vd3-c0-iYd" firstAttribute="top" secondItem="Oax-mA-mEd" secondAttribute="top" constant="10" id="6ON-9I-XV5"/>
+                                <constraint firstItem="xIf-kY-gPW" firstAttribute="width" secondItem="Oax-mA-mEd" secondAttribute="width" multiplier="0.2" id="7yL-vu-0hi"/>
+                                <constraint firstItem="m6I-vy-k36" firstAttribute="width" secondItem="Oax-mA-mEd" secondAttribute="width" multiplier="0.7" id="G5a-55-w2d"/>
+                                <constraint firstItem="Vd3-c0-iYd" firstAttribute="leading" secondItem="Oax-mA-mEd" secondAttribute="leading" constant="10" id="Igf-ZR-anh"/>
+                                <constraint firstItem="pCj-dq-5rF" firstAttribute="centerX" secondItem="Oax-mA-mEd" secondAttribute="centerX" id="LiY-tJ-HN8"/>
+                                <constraint firstAttribute="trailing" secondItem="Vd3-c0-iYd" secondAttribute="trailing" constant="10" id="QqW-8x-l8D"/>
+                                <constraint firstAttribute="trailing" secondItem="m6I-vy-k36" secondAttribute="trailing" constant="10" id="d6m-wH-hZ4"/>
+                                <constraint firstItem="pCj-dq-5rF" firstAttribute="width" secondItem="Oax-mA-mEd" secondAttribute="width" constant="-30" id="ec5-Em-Hvc"/>
+                                <constraint firstItem="VQF-xA-wca" firstAttribute="leading" secondItem="Oax-mA-mEd" secondAttribute="leading" constant="20" id="fKa-XB-zgY"/>
+                                <constraint firstAttribute="trailing" secondItem="U3K-kD-4pK" secondAttribute="trailing" constant="20" id="fib-sq-y5t"/>
+                                <constraint firstItem="U3K-kD-4pK" firstAttribute="centerY" secondItem="VQF-xA-wca" secondAttribute="centerY" id="fxM-45-fab"/>
+                                <constraint firstItem="m6I-vy-k36" firstAttribute="top" secondItem="pCj-dq-5rF" secondAttribute="bottom" id="jKd-mD-fFn"/>
+                                <constraint firstAttribute="bottom" secondItem="VQF-xA-wca" secondAttribute="bottom" id="rUq-Gl-Ma0"/>
+                                <constraint firstItem="xIf-kY-gPW" firstAttribute="leading" secondItem="Oax-mA-mEd" secondAttribute="leading" constant="10" id="xRs-gP-CBO"/>
+                                <constraint firstItem="xIf-kY-gPW" firstAttribute="top" secondItem="pCj-dq-5rF" secondAttribute="bottom" id="xYq-wH-6dd"/>
+                            </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="Oax-mA-mEd" firstAttribute="leading" secondItem="LXM-17-fy1" secondAttribute="leading" constant="10" id="1DE-sl-oYv"/>
+                        <constraint firstItem="Oax-mA-mEd" firstAttribute="bottom" secondItem="LXM-17-fy1" secondAttribute="bottom" constant="10" id="cGe-u0-Et9"/>
+                        <constraint firstAttribute="top" secondItem="Oax-mA-mEd" secondAttribute="top" constant="-10" id="dfL-CJ-4Ja"/>
+                        <constraint firstAttribute="trailing" secondItem="Oax-mA-mEd" secondAttribute="trailing" constant="10" id="mgX-om-hx4"/>
+                        <constraint firstAttribute="height" constant="140" id="pnJ-Mv-tz4"/>
+                    </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>
+            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <constraints>
+                <constraint firstItem="LXM-17-fy1" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="GTl-bf-vFg"/>
+                <constraint firstItem="LXM-17-fy1" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="TQ0-Rk-U3O"/>
+                <constraint firstItem="LXM-17-fy1" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="l7x-fz-B1I"/>
+            </constraints>
+        </view>
+    </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
+</document>

+ 83 - 0
app/RowLabel.swift

@@ -0,0 +1,83 @@
+// 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 RowLabel: UIView {
+	
+	//This view
+	var v: UIView!
+	
+	// Outlets
+	@IBOutlet weak var container: UIView!
+	@IBOutlet weak var text: UILabel!
+	
+	/**
+	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
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = self.bounds
+		self.addSubview(container)
+	}
+	
+	/**
+	Default constructor for the interface builder
+	*/
+	override init(frame: CGRect){
+		super.init(frame: frame)
+	}
+
+	
+	/**
+	Changes the text of The label. Decodes HTML.
+	:param: text The new text.
+	*/
+	func setText(text: String){
+		self.text.text = text.stripHtml()
+	}
+}

+ 79 - 0
app/RowLabel.xib

@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" 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="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+        <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="RowLabel" customModule="app">
+            <connections>
+                <outlet property="container" destination="sWl-jd-g1w" id="uN3-0d-wln"/>
+                <outlet property="text" destination="cAu-3X-Tbx" id="J1F-St-t3M"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <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="sWl-jd-g1w" userLabel="Container">
+                    <rect key="frame" x="0.0" y="313.5" width="375" height="40.5"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="9wy-u8-pKj" userLabel="Entry">
+                            <rect key="frame" x="10" y="10" width="355" height="40.5"/>
+                            <subviews>
+                                <label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="3" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="cAu-3X-Tbx" userLabel="Text">
+                                    <rect key="frame" x="10" y="10" width="335" height="20.5"/>
+                                    <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="cAu-3X-Tbx" firstAttribute="width" secondItem="9wy-u8-pKj" secondAttribute="width" constant="-20" id="8vk-yq-iYR"/>
+                                <constraint firstItem="cAu-3X-Tbx" firstAttribute="centerY" secondItem="9wy-u8-pKj" secondAttribute="centerY" id="gGp-W9-8FT"/>
+                                <constraint firstItem="cAu-3X-Tbx" firstAttribute="height" secondItem="9wy-u8-pKj" secondAttribute="height" constant="-20" id="if1-Pg-hNH"/>
+                                <constraint firstItem="cAu-3X-Tbx" firstAttribute="centerX" secondItem="9wy-u8-pKj" secondAttribute="centerX" id="mED-iI-aHq"/>
+                            </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 firstAttribute="top" secondItem="9wy-u8-pKj" secondAttribute="top" constant="-10" id="E6z-L4-kxl"/>
+                        <constraint firstItem="9wy-u8-pKj" firstAttribute="bottom" secondItem="sWl-jd-g1w" secondAttribute="bottom" constant="10" id="mr3-wn-Fhg"/>
+                        <constraint firstAttribute="trailing" secondItem="9wy-u8-pKj" secondAttribute="trailing" constant="10" id="qfZ-sB-04Y"/>
+                        <constraint firstItem="9wy-u8-pKj" firstAttribute="leading" secondItem="sWl-jd-g1w" secondAttribute="leading" constant="10" id="wlF-xl-Kb8"/>
+                    </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>
+            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <constraints>
+                <constraint firstItem="sWl-jd-g1w" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="i65-Nb-Seg"/>
+                <constraint firstItem="sWl-jd-g1w" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="q8B-3g-WjE"/>
+                <constraint firstItem="sWl-jd-g1w" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="z0m-TJ-Jig"/>
+            </constraints>
+        </view>
+    </objects>
+</document>

+ 121 - 0
app/RowPastActivity.swift

@@ -0,0 +1,121 @@
+// 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 RowPastActivity: UIView {
+	
+	//This view
+	var v: UIView!
+	
+	// Outlets
+	@IBOutlet weak var container: UIView!
+	@IBOutlet weak var title: UILabel!
+	@IBOutlet weak var image: UIImageView!
+	@IBOutlet weak var descript: UILabel!
+	
+	/**
+	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
+		self.frame = self.bounds
+		self.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		self.translatesAutoresizingMaskIntoConstraints = true
+		container.autoresizingMask = [.flexibleWidth, .flexibleHeight]
+		container.translatesAutoresizingMaskIntoConstraints = true
+		
+		container.frame = self.bounds
+		self.addSubview(container)
+		
+		// Set tap recognizer
+		/*print("ROW_PAST_ACTIVITY:DEBUG: set tap recognizer")
+		let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector (self.openActivity (_:)))
+		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 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){
+		descript.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 == ""){
+			NSLog("ROW_PAST_ACTIVITY:DEBUG: No image")
+			//TODO hide the imageview
+		}
+		else{
+			NSLog(":ROW_PAST_ACTIVITY:DEBUG: Set image \(filename)")
+			let path = "img/actividades/thumb/\(filename)"
+			image.setImage(localPath: path, remotePath: "https://margolariak.com/\(path)")
+		}
+	}
+	
+	func openActivity(_ sender:UITapGestureRecognizer? = nil){
+		NSLog(":ROW_PAST_ACTIVITY:DEBUG: open activity")
+	}
+}

+ 103 - 0
app/RowPastActivity.xib

@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11762" systemVersion="16E195" 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="RowPastActivity" customModule="app">
+            <connections>
+                <outlet property="container" destination="0f3-n8-snP" id="8j2-8w-POc"/>
+                <outlet property="descript" destination="LX0-An-ebo" id="z3b-XC-PGL"/>
+                <outlet property="image" destination="dtJ-G2-LyM" id="XkE-dY-Uil"/>
+                <outlet property="title" destination="5y2-jo-1Ha" id="Axu-Cg-JJ5"/>
+            </connections>
+        </placeholder>
+        <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
+        <view contentMode="scaleToFill" id="iN0-l3-epB">
+            <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="0f3-n8-snP" userLabel="Container">
+                    <rect key="frame" x="0.0" y="273.5" width="375" height="120"/>
+                    <subviews>
+                        <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="m2C-OM-hgM" 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="5y2-jo-1Ha" 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="dtJ-G2-LyM" userLabel="Image">
+                                    <rect key="frame" x="10" y="40" width="71" height="64"/>
+                                    <constraints>
+                                        <constraint firstAttribute="height" constant="64" id="5JB-2b-om6"/>
+                                    </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="LX0-An-ebo" 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="5y2-jo-1Ha" firstAttribute="leading" secondItem="m2C-OM-hgM" secondAttribute="leading" constant="10" id="5t3-5D-Bw9"/>
+                                <constraint firstAttribute="trailing" secondItem="5y2-jo-1Ha" secondAttribute="trailing" constant="10" id="8e4-5r-Akk"/>
+                                <constraint firstItem="dtJ-G2-LyM" firstAttribute="width" secondItem="m2C-OM-hgM" secondAttribute="width" multiplier="0.2" id="GYq-dz-9OC"/>
+                                <constraint firstAttribute="trailing" secondItem="LX0-An-ebo" secondAttribute="trailing" constant="10" id="STs-WD-4SU"/>
+                                <constraint firstItem="dtJ-G2-LyM" firstAttribute="leading" secondItem="m2C-OM-hgM" secondAttribute="leading" constant="10" id="UPa-J0-dqk"/>
+                                <constraint firstItem="LX0-An-ebo" firstAttribute="top" secondItem="m2C-OM-hgM" secondAttribute="top" constant="40" id="cuE-pv-oLu"/>
+                                <constraint firstItem="dtJ-G2-LyM" firstAttribute="top" secondItem="m2C-OM-hgM" secondAttribute="top" constant="40" id="ed0-bE-O9g"/>
+                                <constraint firstItem="5y2-jo-1Ha" firstAttribute="top" secondItem="m2C-OM-hgM" secondAttribute="top" constant="10" id="nZ9-2T-9r8"/>
+                                <constraint firstItem="LX0-An-ebo" firstAttribute="width" secondItem="m2C-OM-hgM" secondAttribute="width" multiplier="0.7" id="yaA-lG-dUP"/>
+                            </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 firstAttribute="trailing" secondItem="m2C-OM-hgM" secondAttribute="trailing" constant="10" id="1dr-q7-OCF"/>
+                        <constraint firstAttribute="top" secondItem="m2C-OM-hgM" secondAttribute="top" constant="-10" id="2wX-Nf-cYh"/>
+                        <constraint firstAttribute="height" constant="120" id="Btv-5Q-hKb"/>
+                        <constraint firstItem="m2C-OM-hgM" firstAttribute="bottom" secondItem="0f3-n8-snP" secondAttribute="bottom" constant="10" id="lgl-YA-QZP"/>
+                        <constraint firstItem="m2C-OM-hgM" firstAttribute="leading" secondItem="0f3-n8-snP" secondAttribute="leading" constant="10" id="zBz-05-y7c"/>
+                    </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>
+            <color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
+            <constraints>
+                <constraint firstItem="0f3-n8-snP" firstAttribute="width" secondItem="iN0-l3-epB" secondAttribute="width" id="9st-8M-YFq"/>
+                <constraint firstItem="0f3-n8-snP" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="centerY" id="cwD-TG-T2H"/>
+                <constraint firstItem="0f3-n8-snP" firstAttribute="centerX" secondItem="iN0-l3-epB" secondAttribute="centerX" id="iW1-1C-Wc1"/>
+            </constraints>
+        </view>
+    </objects>
+    <resources>
+        <image name="PhotoPlaceholder" width="170" height="108"/>
+    </resources>
+</document>

+ 3 - 3
app/Section.swift

@@ -27,13 +27,13 @@ import UIKit
 class Section: UIView {
 	
 	//The container.
-	@IBOutlet weak var container: UIView!
+	@IBOutlet var container: UIView!
 	
 	//The section title.
-	@IBOutlet weak var title: UITextView!
+	@IBOutlet var title: UITextView!
 	
 	//The content of the section.
-	@IBOutlet weak var content: UIStackView!
+	@IBOutlet var content: UIStackView!
 	
 	
 	

+ 278 - 54
app/Sync.swift

@@ -101,8 +101,8 @@ class Sync{
 			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 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")
@@ -111,7 +111,7 @@ class Sync{
 			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")
+			let dataSponsor : [String] = self.getTable(data: strData!, table: "sponsor")
 			let dataSettings: [String] = self.getTable(data: strData!, table: "settings")
 			
 			//One by one, save the received data
@@ -127,6 +127,7 @@ class Sync{
 			self.saveTablePostTag(entries: dataPostTag)
 			
 			self.saveTablePlace(entries: dataPlace)
+			self.saveTablePeople(entries: dataPeople)
 			
 			self.saveTableAlbum(entries: dataAlbum)
 			self.saveTablePhoto(entries: dataPhoto)
@@ -134,8 +135,11 @@ class Sync{
 			
 			self.saveTableFestival(entries: dataFestival)
 			self.saveTableFestivalDay(entries: dataFestivalDay)
+			self.saveTableFestivalOffer(entries: dataFestivalOffer)
 			self.saveTableFestivalEvent(entries: dataFestivalEvent)
 			
+			self.saveTableSponsor(entries: dataSponsor)
+			
 			self.saveSettings(entries: dataSettings)
 			
 			
@@ -207,28 +211,28 @@ class Sync{
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	*/
-	func saveTablePeople(entries : [String]){
+	func saveTablePlace(entries : [String]){
 		
-		NSLog(":SYNC:LOG: Saving table People.")
+		NSLog(":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: "People", in: context)
+		let entity =  NSEntityDescription.entity(forEntityName: "Place", in: context)
 		
 		var row: NSManagedObject
 		
 		//Delete all previous entries
-		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "People")
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Place")
 		let request = NSBatchDeleteRequest(fetchRequest: fetch)
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			NSLog(":SYNC:ERROR: Could not clean up People entity: \(error), \(error.userInfo).")
+			NSLog(":SYNC:ERROR: Could not clean up Places entity: \(error), \(error.userInfo).")
 		} catch {
-			NSLog(":SYNC:ERROR: Could not clean up People entity")
+			NSLog(":SYNC:ERROR: Could not clean up Places entity.")
 		}
 		
 		//Loop new entries
@@ -300,85 +304,61 @@ class Sync{
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
 	*/
-	func saveTablePlace(entries : [String]){
+	func saveTablePeople(entries : [String]){
 		
-		NSLog(":SYNC:LOG: Saving table Place.")
+		NSLog(":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: "Place", in: context)
+		let entity =  NSEntityDescription.entity(forEntityName: "People", in: context)
 		
 		var row: NSManagedObject
 		
 		//Delete all previous entries
-		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Place")
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "People")
 		let request = NSBatchDeleteRequest(fetchRequest: fetch)
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			NSLog(":SYNC:ERROR: Could not clean up Places entity: \(error), \(error.userInfo).")
+			NSLog(":SYNC:ERROR: Could not clean up People entity: \(error), \(error.userInfo).")
 		} catch {
-			NSLog(":SYNC:ERROR: Could not clean up Places entity.")
+			NSLog(":SYNC:ERROR: Could not clean up People 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))!
+			let id: Int = Int(str.subStr(start : str.indexOf(target : "\"id\":")! + 6, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(id, forKey: "id")
 			
 			//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)
+			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)
+			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 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
+			//Get link
 			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))!
+			let link : String = str.subStr(start : str.indexOf(target : "\"link\":")! + 8, end : str.length - 2)
+			row.setValue(link, forKey: "link")
 			
 			//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  {
@@ -1126,7 +1106,7 @@ class Sync{
 			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)
@@ -1527,9 +1507,9 @@ class Sync{
 		do {
 			try context.execute(request)
 		} catch let error as NSError  {
-			NSLog(":SYNC:ERROR: Could not clean up Festival: \(error), \(error.userInfo).")
+			NSLog(":SYNC:ERROR: Could not clean up Festival_day: \(error), \(error.userInfo).")
 		} catch {
-			NSLog(":SYNC:ERROR: Could not clean up Festival entity.")
+			NSLog(":SYNC:ERROR: Could not clean up Festival_day entity.")
 		}
 		
 		//Loop new entries
@@ -1579,6 +1559,106 @@ class Sync{
 		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTableFestivalOffer(entries : [String]){
+		
+		NSLog(":SYNC:LOG: Saving table FestivalOffer.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Festival_offer", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Festival_offer")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			NSLog(":SYNC:ERROR: Could not clean up Festival_offer: \(error), \(error.userInfo).")
+		} catch {
+			NSLog(":SYNC:ERROR: Could not clean up Festival_offer 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 year
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let year: Int = Int(str.subStr(start : str.indexOf(target : "\"year\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(year, forKey: "year")
+			
+			// 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 days
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let days: Int = Int(str.subStr(start : str.indexOf(target : "\"days\":")! + 8, end : str.indexOf(target : ",\"")! - 2))!
+			row.setValue(days, forKey: "days")
+			
+			//Get price
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let price: Int = Int(str.subStr(start : str.indexOf(target : "\"price\":")! + 9, end : str.length - 2))!
+			row.setValue(price, forKey: "price")
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				NSLog(":SYNC:ERROR: Could not store Festival_offer entry \(error.userInfo).")
+			} catch {
+				NSLog(":SYNC:ERROR: Could not store Festival_offer entry.")
+			}
+		}
+	}
+	
 	/**
 	Saves the data in the table.
 	:param: entries Array of strings containing the rows of the table, in JSON format.
@@ -1679,6 +1759,20 @@ class Sync{
 			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 day
+			// Special item, not in the sync content
+			dateFormatter.dateFormat = "yyyy-MM-dd"
+			var day = dateFormatter.date(from: str.subStr(start : str.indexOf(target : "\"start\":")! + 9, end : str.indexOf(target : ",\"")! - 11))!
+			// If on the first hours of the next day...
+			let calendar = Calendar.current
+			let hours = calendar.component(.hour, from: day as! Date)
+			// ... the event belongs to the previous day.
+			if hours < 6{
+				day = Calendar.current.date(byAdding: .day, value: -1, to: day)!	
+			}
+			row.setValue(day, forKey: "day")
+
 			
 			//Get end
 			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
@@ -1700,6 +1794,136 @@ class Sync{
 		}
 	}
 	
+	/**
+	Saves the data in the table.
+	:param: entries Array of strings containing the rows of the table, in JSON format.
+	*/
+	func saveTableSponsor(entries : [String]){
+		
+		NSLog(":SYNC:LOG: Saving table Sponsor.")
+		
+		//Set up context
+		let appDelegate = UIApplication.shared.delegate as! AppDelegate
+		let context = NSManagedObjectContext(concurrencyType: .privateQueueConcurrencyType)
+		context.persistentStoreCoordinator = appDelegate.persistentStoreCoordinator
+		
+		let entity =  NSEntityDescription.entity(forEntityName: "Sponsor", in: context)
+		
+		var row: NSManagedObject
+		
+		//Delete all previous entries
+		let fetch = NSFetchRequest<NSFetchRequestResult>(entityName: "Sponsor")
+		let request = NSBatchDeleteRequest(fetchRequest: fetch)
+		do {
+			try context.execute(request)
+		} catch let error as NSError  {
+			NSLog(":SYNC:ERROR: Could not clean up Sponsor: \(error), \(error.userInfo).")
+		} catch {
+			NSLog(":SYNC:ERROR: Could not clean up Sponsor 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 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 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)
+			row.setValue(text_es, forKey: "text_es")
+			
+			// 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)
+			row.setValue(text_en, forKey: "text_en")
+			
+			// 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)
+			row.setValue(text_eu, forKey: "text_eu")
+			
+			// 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)
+			if (image != "ul"){ //From "null"
+				row.setValue(image, forKey: "image")
+			}
+			
+			// 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)
+			if (address_es != "ul"){ //From "null"
+				row.setValue(address_es, forKey: "address_es")
+			}
+			
+			// 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)
+			if (address_en != "ul"){ //From "null"
+				row.setValue(address_en, forKey: "address_en")
+			}
+			
+			// 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)
+			if (address_eu != "ul"){ //From "null"
+				row.setValue(address_eu, forKey: "address_eu")
+			}
+			
+			//Get link
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let link: String = str.subStr(start : str.indexOf(target : "\"link\":")! + 8, end : str.indexOf(target : ",\"")! - 2)
+			if (link != "ul"){ //From "null"
+				row.setValue(link, forKey: "link")
+			}
+			
+			//Get lat
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let strLat: String = str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2)
+			if (strLat != "ul"){ //From "null"
+				let lat: Float = Float(str.subStr(start : str.indexOf(target : "\"lat\":")! + 7, end : str.indexOf(target : ",\"")! - 2))!
+				row.setValue(lat, forKey: "lat")
+			}
+			
+			//Get lon
+			str = str.subStr(start : str.indexOf(target : ",\"")! + 1, end : str.length - 1)
+			let strLon: String = str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2)
+			if (strLon != "ul"){ //From "null"
+				let lon: Float = Float(str.subStr(start : str.indexOf(target : "\"lon\":")! + 7, end : str.length - 2))!
+				row.setValue(lon, forKey: "lon")
+			}
+			
+			//Save CoreData
+			do {
+				try context.save()
+			} catch let error as NSError  {
+				NSLog(":SYNC:ERROR: Could not store Sponsor entry \(error.userInfo).")
+			} catch {
+				NSLog(":SYNC:ERROR: Could not store Sponsor entry.")
+			}
+		}
+	}
+	
 	/**
 	Saves the received settings.
 	:param: entries Array of strings containing the rows of the table, in JSON format.

+ 72 - 0
app/SyncController.swift

@@ -0,0 +1,72 @@
+// 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 SyncController: UIViewController{
+	
+	@IBOutlet weak var pb: UIProgressView!
+	@IBOutlet weak var lb: UILabel!
+	
+	var completion: Float = 0.0
+	let messages: [String] = ["Contactando con Don Margolo...", "Arrancando la furgo...", "Preparando kalimotxos...",
+	"Tú eres el piloto", "Afinando la tuba...", "Margolari camina pa'lante, margolari camina pa'trás.", "Ari ari ari!", "Llegando tarde", "¿Cabe más gente en el Foro Margolari?"]
+	
+	
+	/**
+	Run when the app loads.
+	*/
+	override func viewDidLoad() {
+		
+		NSLog(":SYNC:LOG: SyncController shown.")
+		
+		super.viewDidLoad()
+		
+		// Initial setup
+		pb.progress = 0
+		
+		// Start the timer
+		Timer.scheduledTimer(timeInterval: 0.1, target: self, selector: #selector(progress), userInfo: nil, repeats: true)
+		
+	}
+	
+	func progress(){
+		
+		if (Int(completion * 100) % 20) == 0 {
+			let rnd = Int(arc4random_uniform(UInt32(messages.count)));
+			lb.text = messages[rnd]
+		}
+		
+		completion = completion + 0.02
+		
+		if completion >= 1.0{
+			completion = 0.0
+		}
+		pb.progress = completion
+		
+		
+		
+	}
+	
+}

+ 28 - 7
app/ViewController.swift

@@ -37,7 +37,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	//Each of the sections of the app.
 	@IBOutlet var containerViewGallery: GalleryView!
 	@IBOutlet var containerViewBlog: BlogView!
-	@IBOutlet var containerViewActivities: UIView!
+	@IBOutlet var containerViewActivities: ActivitiesView!
 	@IBOutlet var containerViewLablanca: LablancaView!
 	@IBOutlet var containerViewLocation: UIView!
 	@IBOutlet var containerViewHome: HomeView!
@@ -48,6 +48,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	 Controller initializer.
 	*/
 	required init?(coder aDecoder: NSCoder) {
+		NSLog(":CONTROLLER:DEBUG: Init!")
 		super.init(coder: aDecoder)
 	}
 	
@@ -105,7 +106,9 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 			Sync(synchronous: true)
 		}
 		else{
-			NSLog(":CONTROLLER:DEBUG: Hidding initial sync screen.")
+			NSLog(":CONTROLLER:DEBUG: Re-populating views and hidding initial sync screen.")
+			NSLog(":CONTROLLER:DEBUG: Re-populating disabled: Throws error.")
+			//self.populate()
 			syncSegue?.destination.dismiss(animated: true, completion: nil)
 		}
 	}
@@ -141,7 +144,7 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 	 Run when the app loads.
 	*/
 	override func viewDidLoad() {
-				
+						
 		//Hide all sections, except for the first one
 		self.containerViewLocation.alpha = 0
 		self.containerViewLablanca.alpha = 0
@@ -152,16 +155,34 @@ class ViewController: UIViewController, UICollectionViewDataSource, UICollection
 		NSLog(":CONTROLLER:LOG: viewDidLoad()")
 		NSLog(":CONTROLLER:DEBUG: Skyp sync")
 		//Sync()
-		
-		super.viewDidLoad()
 
 		//self.containerViewBlog.setController(controller: self as ViewController)
 		
-		delegate = UIApplication.shared.delegate as! AppDelegate
-		delegate?.controller = self
+		self.delegate = UIApplication.shared.delegate as? AppDelegate
+		self.delegate?.controller = self
 		
+		NSLog(":CONTROLLER:DEBUG: NOT Forcing a call to populate")
+		//self.populate()
+		
+		super.viewDidLoad()
 		
 	}
+
+	func populate(){
+		if (self.containerViewHome != nil){
+			//(self.containerViewHome as HomeView).populate2()
+			let ng = self.containerViewHome.dbgTxt
+			NSLog("AAAAA \(ng)")
+		}
+		else{
+			NSLog("CONTROLLER:ERROR: containerViewHome couldn't be populated: It is nil.")
+		}
+		//self.containerLocation.populate()
+		//self.containerLablanca.populate()
+		//self.containerViewActivities.populate()
+		//self.containerViewBlog.populate()
+		//self.containerGallery.populate()
+	}
 	
 	/**
 	 Executed when the view is actually shown.

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

@@ -84,6 +84,7 @@
         <attribute name="price" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
     </entity>
     <entity name="Festival_event" representedClassName=".Festival_event" syncable="YES" codeGenerationType="class">
+        <attribute name="day" optional="YES" attributeType="Date" usesScalarValueType="NO" syncable="YES"/>
         <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"/>
@@ -134,6 +135,13 @@
         <attribute name="title_es" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="title_eu" optional="YES" attributeType="String" syncable="YES"/>
     </entity>
+    <entity name="People" representedClassName="People" syncable="YES" codeGenerationType="class">
+        <attribute name="id" optional="YES" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="YES" syncable="YES"/>
+        <attribute name="link" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="name_en" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="name_es" optional="YES" attributeType="String" syncable="YES"/>
+        <attribute name="name_eu" optional="YES" attributeType="String" syncable="YES"/>
+    </entity>
     <entity name="Photo" representedClassName=".Photo" syncable="YES" codeGenerationType="class">
         <attribute name="description_en" optional="YES" attributeType="String" syncable="YES"/>
         <attribute name="description_es" optional="YES" attributeType="String" syncable="YES"/>
@@ -228,7 +236,7 @@
         <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"/>
+        <element name="Festival_event" positionX="0" positionY="-3897" width="128" height="240"/>
         <element name="Festival_event_image" positionX="9" positionY="-3888" width="128" height="105"/>
         <element name="Festival_offer" positionX="18" positionY="-3879" width="128" height="195"/>
         <element name="Location" positionX="27" positionY="-3870" width="128" height="90"/>
@@ -242,5 +250,6 @@
         <element name="Post_tag" positionX="45" positionY="-3852" width="128" height="75"/>
         <element name="Sponsor" positionX="-9" positionY="-3906" width="128" height="255"/>
         <element name="Version" positionX="-9" positionY="-3906" width="128" height="75"/>
+        <element name="People" positionX="-9" positionY="-3906" width="128" height="120"/>
     </elements>
 </model>