Skip to content

Commit

Permalink
revert Actex behaviour to default minimized
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacdontjelindell committed May 29, 2013
1 parent e1547cc commit 6e82767
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 57 deletions.
18 changes: 10 additions & 8 deletions modules/luther/sphinx/activecode/activecode.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,27 +234,29 @@ def run(self):



EXEDIT = '''
<button id="butt_%(divid)s" onclick="createActiveCode('%(divid)s','%(source)s'); $('#butt_%(divid)s').hide();">Open Editor</button>
<div id="%(divid)s"></div>
<br />
'''

class ActiveExercise(Directive):
required_arguments = 1
optional_arguments = 0
has_content = True
option_spec = {}

def run(self):
self.options['divid'] = self.arguments[0]
self.options['caption'] = ''
self.options['include'] = 'undefined'

if self.content:
source = "\\n".join(self.content)

else:
source = ''
self.options['source'] = source.replace('"','%22').replace("'",'%27')

res = EXEDIT

self.options['initialcode'] = source.replace('"','%22').replace("'",'%27')
return [nodes.raw('',res % self.options,format='html')]

return_node = ActivcodeNode(self.options)
return [return_node]


if __name__ == '__main__':
Expand Down
15 changes: 15 additions & 0 deletions overview/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ from scratch and write your own interactive textbook using the tools that we pro
In order to see how the tools work, the following sections will show them in action.


.. tabbed:: randomdiv

.. tab:: Tab1

.. video:: videoinfo
:controls:
:thumb: _static/activecodethumb.png

http://media.interactivepython.org/thinkcsVideos/activecodelens.mov
http://media.interactivepython.org/thinkcsVideos/activecodelens.webm

.. tab:: Tab 2

hello world

Embedded Videos
---------------

Expand Down
1 change: 1 addition & 0 deletions source/Lists/lists.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ item when counting the length of the list.


.. code-block:: python
alist = [3, 67, "cat", [56, 57, "dog"], [ ], 3.14, False]
print(len(alist))
Expand Down
54 changes: 35 additions & 19 deletions source/SimplePythonData/simpledata.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1256,25 +1256,41 @@ Glossary
Exercises
---------

1. Evaluate the following numerical expressions in your head, then use
the active code window to check your results:

#. ``5 ** 2``
#. ``9 * 5``
#. ``15 / 12``
#. ``12 / 15``
#. ``15 // 12``
#. ``12 // 15``
#. ``5 % 2``
#. ``9 % 5``
#. ``15 % 12``
#. ``12 % 15``
#. ``6 % 6``
#. ``0 % 7``

.. activecode:: ch02_ex1

print(5**2)
1.

.. tabbed:: q1

.. tab:: Question

Evaluate the following numerical expressions in your head, then use
the active code window to check your results:

#. ``5 ** 2``
#. ``9 * 5``
#. ``15 / 12``
#. ``12 / 15``
#. ``15 // 12``
#. ``12 // 15``
#. ``5 % 2``
#. ``9 % 5``
#. ``15 % 12``
#. ``12 % 15``
#. ``6 % 6``
#. ``0 % 7``

.. activecode:: ch02_ex1

print(5**2)

.. tab:: Answer

Put some sort of answer here!

.. tab:: Discussion

.. disqus::
:shortname: interactivepython
:identifier: q1disqus

2. You look at the clock and it is exactly 2pm. You set an alarm to go off
in 51 hours. At what time does the alarm go off?
Expand Down
29 changes: 0 additions & 29 deletions source/_static/bookfuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,35 +301,6 @@ function loadEditor(data, status, whatever) {
// need to get the divId back with the result...
}

function createOddActiveCode(divid,suppliedSource,sid) {
/* Create 3 tabs for this exercise: an editor, containing a normal activecode block,
an Answer tab, containing an answer provided by the author, and a discussion tab
containing a Disqus commenting/discussion block specific to this exercise.
*/

// #divid will hold all 3 tabs
tabDiv = $("#"+divid);

// create the 3 tabs
tabList = tabDiv.append("<ul></ul>").find("ul");
tabList.append("<li><a href='#" + divid + "-editor'><span>Editor</span></a></li>");
tabList.append("<li><a href='#" + divid + "-answer'><span>Answer</span></a></li>");
tabList.append("<li><a href='#" + divid + "-discussion'><span>Discussion</span></a></li>");

// create the 3 divs corresponding to the 3 tabs
tabDiv.append("<div id='" + divid + "-editor'>Editor</div>");
tabDiv.append("<div id='" + divid + "-answer'>Answer</div>");
tabDiv.append("<div id='" + divid + "-discussion'>Discussion</div>");

// insert the activecode editor in the editor tab
createActiveCode(divid + '-editor', suppliedSource, sid)

// init the jQuery tabs plugin
$(function() {
$( "#"+divid ).tabs();
});

}

function createActiveCode(divid,suppliedSource,sid) {
var eNode;
Expand Down
2 changes: 1 addition & 1 deletion thinkcspy/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.mathjax','luther.sphinx.video','luther.sphinx.codelens','luther.sphinx.activecode', 'luther.sphinx.assess', 'luther.sphinx.animation','luther.sphinx.meta', 'gatech.parsons']
extensions = ['sphinx.ext.mathjax','luther.sphinx.disqus','luther.sphinx.video','luther.sphinx.codelens','luther.sphinx.activecode','luther.sphinx.tabbedStuff', 'luther.sphinx.assess', 'luther.sphinx.animation','luther.sphinx.meta', 'gatech.parsons']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['../source/_templates']
Expand Down

0 comments on commit 6e82767

Please sign in to comment.