Commit e9f21bf3 authored by Andrew Gibiansky's avatar Andrew Gibiansky

Fixed `ihaskell setup` to untar a profile.tar file

parent 215668fc
...@@ -42,20 +42,12 @@ build-type: Simple ...@@ -42,20 +42,12 @@ build-type: Simple
-- Constraint on the version of Cabal needed to build this package. -- Constraint on the version of Cabal needed to build this package.
cabal-version: >=1.8 cabal-version: >=1.8
extra-source-files: data-files:
config/custom.js profile/profile.tar
config/ipython_config.py
config/ipython_console_config.py
config/ipython_notebook_config.py
config/ipython_qtconsole_config.py
deps/codecell.js
deps/tooltip.js
build-parser.sh
images/ihaskell-logo.png
HaskellParser.y.pp
library library
build-depends: base ==4.6.*, build-depends: base ==4.6.*,
tar,
ghc-parser, ghc-parser,
unix >= 2.6, unix >= 2.6,
hspec, hspec,
...@@ -83,6 +75,7 @@ library ...@@ -83,6 +75,7 @@ library
mtl == 2.1.*, mtl == 2.1.*,
template-haskell template-haskell
exposed-modules: IHaskell.Display, exposed-modules: IHaskell.Display,
Paths_ihaskell,
IHaskell.Types, IHaskell.Types,
IHaskell.Message.UUID IHaskell.Message.UUID
...@@ -111,6 +104,7 @@ executable IHaskell ...@@ -111,6 +104,7 @@ executable IHaskell
-- Other library packages from which modules are imported. -- Other library packages from which modules are imported.
build-depends: base ==4.6.*, build-depends: base ==4.6.*,
tar,
ghc-parser, ghc-parser,
unix >= 2.6, unix >= 2.6,
hspec, hspec,
...@@ -143,6 +137,7 @@ Test-Suite hspec ...@@ -143,6 +137,7 @@ Test-Suite hspec
Ghc-Options: -threaded Ghc-Options: -threaded
Main-Is: Hspec.hs Main-Is: Hspec.hs
build-depends: base ==4.6.*, build-depends: base ==4.6.*,
tar,
ghc-parser, ghc-parser,
unix >= 2.6, unix >= 2.6,
hspec, hspec,
......
...@@ -17,10 +17,12 @@ import System.Directory ...@@ -17,10 +17,12 @@ import System.Directory
import qualified Filesystem.Path.CurrentOS as FS import qualified Filesystem.Path.CurrentOS as FS
import Data.List.Utils (split) import Data.List.Utils (split)
import Data.String.Utils (rstrip) import Data.String.Utils (rstrip)
import Text.Printf
import qualified System.IO.Strict as StrictIO import qualified System.IO.Strict as StrictIO
import qualified IHaskell.Config as Config import qualified Paths_ihaskell as Paths
import qualified Codec.Archive.Tar as Tar
-- | Run IPython with any arguments. -- | Run IPython with any arguments.
ipython :: Bool -- ^ Whether to suppress output. ipython :: Bool -- ^ Whether to suppress output.
...@@ -86,7 +88,9 @@ setupIPythonProfile profile = shelly $ do ...@@ -86,7 +88,9 @@ setupIPythonProfile profile = shelly $ do
ipythonDir <- pack <$> rstrip <$> ipython True ["locate"] ipythonDir <- pack <$> rstrip <$> ipython True ["locate"]
let profileDir = ipythonDir ++ "/profile_" ++ pack profile ++ "/" let profileDir = ipythonDir ++ "/profile_" ++ pack profile ++ "/"
path <- getIHaskellPath liftIO $ copyProfile profileDir
insertIHaskellPath profileDir
{-
writeConfigFilesTo profileDir path writeConfigFilesTo profileDir path
-- | Write IPython configuration files to the profile directory. -- | Write IPython configuration files to the profile directory.
...@@ -114,6 +118,25 @@ writeConfigFilesTo profileDir ihaskellPath = do ...@@ -114,6 +118,25 @@ writeConfigFilesTo profileDir ihaskellPath = do
where where
conf filename = fromText $ profileDir ++ filename conf filename = fromText $ profileDir ++ filename
-}
-- | Copy the profile files into the IPython profile.
copyProfile :: Text -> IO ()
copyProfile profileDir = do
profileTar <- Paths.getDataFileName "profile/profile.tar"
Tar.extract (unpack profileDir) profileTar
-- | Insert the IHaskell path into the IPython configuration.
insertIHaskellPath :: Text -> Sh ()
insertIHaskellPath profileDir = do
path <- getIHaskellPath
let filename = profileDir ++ "ipython_config.py"
template = "exe = '%s'.replace(' ', '\\\\ ')"
exeLine = printf template $ unpack path :: String
liftIO $ do
contents <- StrictIO.readFile $ unpack filename
writeFile (fromText filename) $ exeLine ++ "\n" ++ contents
-- | Get the absolute path to this IHaskell executable. -- | Get the absolute path to this IHaskell executable.
getIHaskellPath :: Sh String getIHaskellPath :: Sh String
......
...@@ -16,6 +16,10 @@ build-type: Custom ...@@ -16,6 +16,10 @@ build-type: Custom
-- extra-source-files: -- extra-source-files:
cabal-version: >=1.10 cabal-version: >=1.10
extra-source-files:
build-parser.sh
HaskellParser.y.pp
library library
exposed-modules: Language.Haskell.GHC.Parser, exposed-modules: Language.Haskell.GHC.Parser,
Language.Haskell.GHC.HappyParser Language.Haskell.GHC.HappyParser
...@@ -24,3 +28,4 @@ library ...@@ -24,3 +28,4 @@ library
build-depends: base >=4.6 && <4.7, ghc == 7.6.3 build-depends: base >=4.6 && <4.7, ghc == 7.6.3
-- hs-source-dirs: -- hs-source-dirs:
default-language: Haskell2010 default-language: Haskell2010
# Available Subsitutions: # Available Variables:
# ${executable}: Path to IHaskell kernel. # exe: Path to IHaskell kernel.
c = get_config() c = get_config()
exe = '${executable}'.replace(' ', '\\\\ ')
c.KernelManager.kernel_cmd = [exe, 'kernel', '{connection_file}'] c.KernelManager.kernel_cmd = [exe, 'kernel', '{connection_file}']
c.Session.key = '' c.Session.key = ''
c.Session.keyfile = '' c.Session.keyfile = ''
...@@ -33,7 +33,7 @@ var IPython = (function (IPython) { ...@@ -33,7 +33,7 @@ var IPython = (function (IPython) {
this.time_before_tooltip = 800; this.time_before_tooltip = 800;
// handle to html // handle to html
this.tooltip = \$('#tooltip'); this.tooltip = $('#tooltip');
this._hidden = true; this._hidden = true;
// variable for consecutive call // variable for consecutive call
...@@ -48,40 +48,40 @@ var IPython = (function (IPython) { ...@@ -48,40 +48,40 @@ var IPython = (function (IPython) {
this._hide_if_no_docstring = false; this._hide_if_no_docstring = false;
// contain the button in the upper right corner // contain the button in the upper right corner
this.buttons = \$('<div/>').addClass('tooltipbuttons'); this.buttons = $('<div/>').addClass('tooltipbuttons');
// will contain the docstring // will contain the docstring
this.text = \$('<div/>').addClass('tooltiptext').addClass('smalltooltip'); this.text = $('<div/>').addClass('tooltiptext').addClass('smalltooltip');
// build the buttons menu on the upper right // build the buttons menu on the upper right
// expand the tooltip to see more // expand the tooltip to see more
var expandlink = \$('<a/>').attr('href', "#").addClass("ui-corner-all") //rounded corner var expandlink = $('<a/>').attr('href', "#").addClass("ui-corner-all") //rounded corner
.attr('role', "button").attr('id', 'expanbutton').attr('title', 'Grow the tooltip vertically (press tab 2 times)').click(function () { .attr('role', "button").attr('id', 'expanbutton').attr('title', 'Grow the tooltip vertically (press tab 2 times)').click(function () {
that.expand() that.expand()
}).append( }).append(
\$('<span/>').text('Expand').addClass('ui-icon').addClass('ui-icon-plus')); $('<span/>').text('Expand').addClass('ui-icon').addClass('ui-icon-plus'));
// open in pager // open in pager
var morelink = \$('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button').attr('title', 'show the current docstring in pager (press tab 4 times)'); var morelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button').attr('title', 'show the current docstring in pager (press tab 4 times)');
var morespan = \$('<span/>').text('Open in Pager').addClass('ui-icon').addClass('ui-icon-arrowstop-l-n'); var morespan = $('<span/>').text('Open in Pager').addClass('ui-icon').addClass('ui-icon-arrowstop-l-n');
morelink.append(morespan); morelink.append(morespan);
morelink.click(function () { morelink.click(function () {
that.showInPager(that._old_cell); that.showInPager(that._old_cell);
}); });
// close the tooltip // close the tooltip
var closelink = \$('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button'); var closelink = $('<a/>').attr('href', "#").attr('role', "button").addClass('ui-button');
var closespan = \$('<span/>').text('Close').addClass('ui-icon').addClass('ui-icon-close'); var closespan = $('<span/>').text('Close').addClass('ui-icon').addClass('ui-icon-close');
closelink.append(closespan); closelink.append(closespan);
closelink.click(function () { closelink.click(function () {
that.remove_and_cancel_tooltip(true); that.remove_and_cancel_tooltip(true);
}); });
this._clocklink = \$('<a/>').attr('href', "#"); this._clocklink = $('<a/>').attr('href', "#");
this._clocklink.attr('role', "button"); this._clocklink.attr('role', "button");
this._clocklink.addClass('ui-button'); this._clocklink.addClass('ui-button');
this._clocklink.attr('title', 'Tootip is not dismissed while typing for 10 seconds'); this._clocklink.attr('title', 'Tootip is not dismissed while typing for 10 seconds');
var clockspan = \$('<span/>').text('Close'); var clockspan = $('<span/>').text('Close');
clockspan.addClass('ui-icon'); clockspan.addClass('ui-icon');
clockspan.addClass('ui-icon-clock'); clockspan.addClass('ui-icon-clock');
this._clocklink.append(clockspan); this._clocklink.append(clockspan);
...@@ -104,7 +104,7 @@ var IPython = (function (IPython) { ...@@ -104,7 +104,7 @@ var IPython = (function (IPython) {
// we need a phony element to make the small arrow // we need a phony element to make the small arrow
// of the tooltip in css // of the tooltip in css
// we will move the arrow later // we will move the arrow later
this.arrow = \$('<div/>').addClass('pretooltiparrow'); this.arrow = $('<div/>').addClass('pretooltiparrow');
this.tooltip.append(this.buttons); this.tooltip.append(this.buttons);
this.tooltip.append(this.arrow); this.tooltip.append(this.arrow);
this.tooltip.append(this.text); this.tooltip.append(this.text);
...@@ -150,14 +150,14 @@ var IPython = (function (IPython) { ...@@ -150,14 +150,14 @@ var IPython = (function (IPython) {
Tooltip.prototype.expand = function () { Tooltip.prototype.expand = function () {
this.text.removeClass('smalltooltip'); this.text.removeClass('smalltooltip');
this.text.addClass('bigtooltip'); this.text.addClass('bigtooltip');
\$('#expanbutton').hide('slow'); $('#expanbutton').hide('slow');
} }
// deal with all the logic of hiding the tooltip // deal with all the logic of hiding the tooltip
// and reset it's status // and reset it's status
Tooltip.prototype._hide = function () { Tooltip.prototype._hide = function () {
this.tooltip.fadeOut('fast'); this.tooltip.fadeOut('fast');
\$('#expanbutton').show('slow'); $('#expanbutton').show('slow');
this.text.removeClass('bigtooltip'); this.text.removeClass('bigtooltip');
this.text.addClass('smalltooltip'); this.text.addClass('smalltooltip');
// keep scroll top to be sure to always see the first line // keep scroll top to be sure to always see the first line
...@@ -201,8 +201,8 @@ var IPython = (function (IPython) { ...@@ -201,8 +201,8 @@ var IPython = (function (IPython) {
// basicaly you shoul be able to get xxx.xxx.xxx from // basicaly you shoul be able to get xxx.xxx.xxx from
// something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2, // something(range(10), kwarg=smth) ; xxx.xxx.xxx( firstarg, rand(234,23), kwarg1=2,
// remove everything between matchin bracket (need to iterate) // remove everything between matchin bracket (need to iterate)
var matchBracket = /\\([^\\(\\)]+\\)/g; var matchBracket = /\([^\(\)]+\)/g;
var endBracket = /\\([^\\(]*\$/g; var endBracket = /\([^\(]*$/g;
var oldfunc = func; var oldfunc = func;
func = func.replace(matchBracket, ""); func = func.replace(matchBracket, "");
...@@ -213,13 +213,13 @@ var IPython = (function (IPython) { ...@@ -213,13 +213,13 @@ var IPython = (function (IPython) {
// remove everything after last open bracket // remove everything after last open bracket
func = func.replace(endBracket, ""); func = func.replace(endBracket, "");
var re = /[a-z_][0-9a-z._!]+\$/gi; // casse insensitive var re = /[a-z_][0-9a-z._!]+$/gi; // casse insensitive
var that = this var that = this
var callbacks_v2 = function(data){ var callbacks_v2 = function(data){
\$.proxy(that._show(data.content), that) $.proxy(that._show(data.content), that)
} }
var callbacks = { var callbacks = {
'object_info_reply': \$.proxy(this._show, this) 'object_info_reply': $.proxy(this._show, this)
} }
if(cell.kernel.object_info_request){ if(cell.kernel.object_info_request){
// we are on IPython 1.x and early 2.0 (before bidirectionnal js comm) // we are on IPython 1.x and early 2.0 (before bidirectionnal js comm)
...@@ -306,9 +306,9 @@ var IPython = (function (IPython) { ...@@ -306,9 +306,9 @@ var IPython = (function (IPython) {
// do some math to have the tooltip arrow on more or less on left or right // do some math to have the tooltip arrow on more or less on left or right
// width of the editor // width of the editor
var w = \$(this.code_mirror.getScrollerElement()).width(); var w = $(this.code_mirror.getScrollerElement()).width();
// ofset of the editor // ofset of the editor
var o = \$(this.code_mirror.getScrollerElement()).offset(); var o = $(this.code_mirror.getScrollerElement()).offset();
// whatever anchor/head order but arrow at mid x selection // whatever anchor/head order but arrow at mid x selection
var anchor = this.code_mirror.cursorCoords(false); var anchor = this.code_mirror.cursorCoords(false);
...@@ -364,9 +364,9 @@ var IPython = (function (IPython) { ...@@ -364,9 +364,9 @@ var IPython = (function (IPython) {
this._hidden = false; this._hidden = false;
this.text.children().remove(); this.text.children().remove();
var pre = \$('<pre/>').html(utils.fixConsole(docstring)); var pre = $('<pre/>').html(utils.fixConsole(docstring));
if (defstring) { if (defstring) {
var defstring_html = \$('<pre/>').html(utils.fixConsole(defstring)); var defstring_html = $('<pre/>').html(utils.fixConsole(defstring));
this.text.append(defstring_html); this.text.append(defstring_html);
} }
this.text.append(pre); this.text.append(pre);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment