+{% endblock%}
\ No newline at end of file
diff --git a/compile_server/app/views.py b/compile_server/app/views.py
index ad3832b..a94884c 100644
--- a/compile_server/app/views.py
+++ b/compile_server/app/views.py
@@ -1,12 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-import json
-
from django.shortcuts import render
# Create your views here.
+import os
+import yaml
+
+from django.conf import settings
+
from django.contrib.auth.models import User, Group
from django.views.decorators.clickjacking import xframe_options_exempt
from rest_framework import viewsets, status
@@ -106,3 +109,59 @@ def code_embed(request, example_name):
def examples_list(request):
context = {'examples': Example.objects.all}
return render(request, 'examples_list.html', context)
+
+
+def book_list(request):
+ resources_base_path = os.path.join(settings.RESOURCES_DIR, "books")
+
+ with open(os.path.join(resources_base_path, "book_list.yaml"), 'r') as f:
+ booklist = yaml.load(f)
+ return render(request, 'book_list.html', booklist)
+
+
+def book_router(request, book, part, chapter):
+ resources_base_path = os.path.join(settings.RESOURCES_DIR, "books")
+
+ book_path = os.path.join(resources_base_path, book)
+
+ if not os.path.isdir(book_path):
+ with open(os.path.join(resources_base_path, "book_list.yaml"), 'r') as f:
+ booklist = yaml.load(f)
+ return render(request, 'book_list.html', booklist)
+
+ path = os.path.join(book_path, "chapters.yaml")
+
+ with open(path, 'r') as f:
+ bookdata = yaml.load(f)
+
+ htmldata = bookdata
+ htmldata['sel_part'] = int(part)
+ htmldata['sel_chapter'] = int(chapter)
+
+ chapter_list = []
+
+ for p in bookdata['parts']:
+ chapter_list.extend(p['chapters'])
+
+ val_search = "part%s-chapter%s" % (part, chapter)
+
+ for i, ch in enumerate(chapter_list):
+ if ch['url'] == val_search:
+ htmldata['sel_topic'] = ch
+ if i != 0:
+ htmldata['prev_topic'] = chapter_list[i - 1]
+ if i != len(chapter_list) - 1:
+ htmldata['next_topic'] = chapter_list[i + 1]
+ # TODO: handle instance where part and chapter are outside of valid range
+
+ content_page = os.path.join(book_path,
+ "pages",
+ "part%s-chapter%s.html" % (part, chapter))
+
+ if os.path.isfile(content_page):
+ with open(content_page, 'r') as f:
+ htmldata['content'] = f.read()
+ else:
+ htmldata['content'] = "
Page Under Construction
"
+
+ return render(request, 'readerpage.html', htmldata)
diff --git a/compile_server/settings.py b/compile_server/settings.py
index 93fafc6..2d755ad 100644
--- a/compile_server/settings.py
+++ b/compile_server/settings.py
@@ -14,7 +14,7 @@ import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
+RESOURCES_DIR = os.path.join(BASE_DIR, "resources")
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
diff --git a/compile_server/urls.py b/compile_server/urls.py
index 2efa43e..556f620 100644
--- a/compile_server/urls.py
+++ b/compile_server/urls.py
@@ -55,6 +55,12 @@ urlpatterns = [
# Get a list of all the examples
url(r'^examples_list/', views.examples_list),
+ # URL router for Books
+ url(r'^books/(.+)/part(\d+)-chapter(\d+)', views.book_router),
+
+ # URL router for Book landing
+ url(r'^books', views.book_list),
+
# The landing page
url(r'', views.examples_list),
]
diff --git a/resources/books/Ada_For_The_C++_Java_Developer_v2/chapters.yaml b/resources/books/Ada_For_The_C++_Java_Developer_v2/chapters.yaml
new file mode 100644
index 0000000..128b6ec
--- /dev/null
+++ b/resources/books/Ada_For_The_C++_Java_Developer_v2/chapters.yaml
@@ -0,0 +1,70 @@
+---
+parts:
+ - title: "The Basics"
+ chapters:
+ - title: "Short rationale for migrating from Ada to C"
+ url: "part1-chapter1"
+ - title: "Compilation environments, multi language builds, bare metal v.s. Embedded linux"
+ url: "part1-chapter2"
+ - title: "Preprocessor macros vs build configurations"
+ url: "part1-chapter3"
+ - title: "Introducing your first piece of Ada in an existing C application"
+ url: "part1-chapter4"
+ - title: "Overview of Ada basics (expressions, control flow, types, record, arrays)"
+ url: "part1-chapter5"
+ - title: "Structure blocks (packages, encapsulation, genericity)"
+ url: "part1-chapter6"
+ - title: "Interfacing with C"
+ url: "part1-chapter7"
+ - title: "Use case #1 mathematical computations with physical dimension checking"
+ url: "part1-chapter8"
+ - title: "The Low-Level"
+ chapters:
+ - title: "Inline Assembly"
+ url: "part2-chapter1"
+ - title: "Bit masks"
+ url: "part2-chapter2"
+ - title: "Number wrap around"
+ url: "part2-chapter3"
+ - title: "Register overlays"
+ url: "part2-chapter4"
+ - title: "Memory mapped communication"
+ url: "part2-chapter5"
+ - title: "Streams"
+ url: "part2-chapter6"
+ - title: "Endianness"
+ url: "part2-chapter7"
+ - title: "The run-times (boot loader, BSP…)"
+ url: "part2-chapter8"
+ - title: "Ravenscar tasking"
+ url: "part2-chapter9"
+ - title: "ARM environment (svd2ada)"
+ url: "part2-chapter10"
+ - title: "Use case #2 [???]"
+ url: "part2-chapter11"
+ - title: "Typical Algorithms"
+ chapters:
+ - title: "List searches"
+ url: "part3-chapter1"
+ - title: "Switch debounce"
+ url: "part3-chapter2"
+ - title: "Lookup tables"
+ url: "part3-chapter3"
+ - title: "Large number support"
+ url: "part3-chapter4"
+ - title: "Use case #3 [???]"
+ url: "part3-chapter5"
+ - title: "Verifiable Programming"
+ chapters:
+ - title: "Using SPARK subset (Stone)"
+ url: "part4-chapter1"
+ - title: "Proving data flow (Bronze)"
+ url: "part4-chapter2"
+ - title: "Installing more provers and proving Absence of Run-Time Errors (Silver)"
+ url: "part4-chapter3"
+ - title: "Specifying and verifying defensive code (Gold)"
+ url: "part4-chapter4"
+ - title: "Use case #4 The crazyflies"
+ url: "part4-chapter5"
+...
+
diff --git a/resources/books/Ada_For_The_C_Developer/chapters.yaml b/resources/books/Ada_For_The_C_Developer/chapters.yaml
new file mode 100644
index 0000000..128b6ec
--- /dev/null
+++ b/resources/books/Ada_For_The_C_Developer/chapters.yaml
@@ -0,0 +1,70 @@
+---
+parts:
+ - title: "The Basics"
+ chapters:
+ - title: "Short rationale for migrating from Ada to C"
+ url: "part1-chapter1"
+ - title: "Compilation environments, multi language builds, bare metal v.s. Embedded linux"
+ url: "part1-chapter2"
+ - title: "Preprocessor macros vs build configurations"
+ url: "part1-chapter3"
+ - title: "Introducing your first piece of Ada in an existing C application"
+ url: "part1-chapter4"
+ - title: "Overview of Ada basics (expressions, control flow, types, record, arrays)"
+ url: "part1-chapter5"
+ - title: "Structure blocks (packages, encapsulation, genericity)"
+ url: "part1-chapter6"
+ - title: "Interfacing with C"
+ url: "part1-chapter7"
+ - title: "Use case #1 mathematical computations with physical dimension checking"
+ url: "part1-chapter8"
+ - title: "The Low-Level"
+ chapters:
+ - title: "Inline Assembly"
+ url: "part2-chapter1"
+ - title: "Bit masks"
+ url: "part2-chapter2"
+ - title: "Number wrap around"
+ url: "part2-chapter3"
+ - title: "Register overlays"
+ url: "part2-chapter4"
+ - title: "Memory mapped communication"
+ url: "part2-chapter5"
+ - title: "Streams"
+ url: "part2-chapter6"
+ - title: "Endianness"
+ url: "part2-chapter7"
+ - title: "The run-times (boot loader, BSP…)"
+ url: "part2-chapter8"
+ - title: "Ravenscar tasking"
+ url: "part2-chapter9"
+ - title: "ARM environment (svd2ada)"
+ url: "part2-chapter10"
+ - title: "Use case #2 [???]"
+ url: "part2-chapter11"
+ - title: "Typical Algorithms"
+ chapters:
+ - title: "List searches"
+ url: "part3-chapter1"
+ - title: "Switch debounce"
+ url: "part3-chapter2"
+ - title: "Lookup tables"
+ url: "part3-chapter3"
+ - title: "Large number support"
+ url: "part3-chapter4"
+ - title: "Use case #3 [???]"
+ url: "part3-chapter5"
+ - title: "Verifiable Programming"
+ chapters:
+ - title: "Using SPARK subset (Stone)"
+ url: "part4-chapter1"
+ - title: "Proving data flow (Bronze)"
+ url: "part4-chapter2"
+ - title: "Installing more provers and proving Absence of Run-Time Errors (Silver)"
+ url: "part4-chapter3"
+ - title: "Specifying and verifying defensive code (Gold)"
+ url: "part4-chapter4"
+ - title: "Use case #4 The crazyflies"
+ url: "part4-chapter5"
+...
+
diff --git a/resources/books/Ada_For_The_C_Developer/pages/part1-chapter1.html b/resources/books/Ada_For_The_C_Developer/pages/part1-chapter1.html
new file mode 100644
index 0000000..b482272
--- /dev/null
+++ b/resources/books/Ada_For_The_C_Developer/pages/part1-chapter1.html
@@ -0,0 +1,34 @@
+
+
Part 1 Chapter 1
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+
+
+
Lorem Ipsum Dolor
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+
+
+
Lorem Ipsum Dolor
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
+
+
+
+
Lorem Ipsum Dolor
+
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
+ aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+ Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur
+ sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\ No newline at end of file
diff --git a/resources/books/book_list.yaml b/resources/books/book_list.yaml
new file mode 100644
index 0000000..cd85283
--- /dev/null
+++ b/resources/books/book_list.yaml
@@ -0,0 +1,7 @@
+---
+books:
+ - title: "Ada For The C Developer"
+ url: "Ada_For_The_C_Developer"
+ - title: "Ada For the C++ Java Developer v2"
+ url: "Ada_For_The_C++_Java_Developer_v2"
+...
\ No newline at end of file