Lots of work!

pull/1/head
tidusjar 9 years ago
parent 8f0ca3d1c4
commit 448cd8d92e

@ -1,27 +1,43 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using TMDbLib.Client;
using TMDbLib.Objects.General;
using TMDbLib.Objects.Movies;
using TMDbLib.Objects.Search;
namespace RequestPlex.Api
{
public class TheMovieDbApi : MovieBase
{
public TheMovieDbApi()
{
Client = new TMDbClient(ApiKey);
}
public TMDbClient Client { get; set; }
public async Task<List<SearchMovie>> SearchMovie(string searchTerm)
{
var client = new TMDbClient(ApiKey);
var results = await client.SearchMovie(searchTerm);
var results = await Client.SearchMovie(searchTerm);
return results.Results;
}
public async Task<List<SearchTv>> SearchTv(string searchTerm)
{
var client = new TMDbClient(ApiKey);
var results = await client.SearchTvShow(searchTerm);
var results = await Client.SearchTvShow(searchTerm);
return results.Results;
}
public async Task<List<MovieResult>> GetCurrentPlayingMovies()
{
var movies = await Client.GetMovieList(MovieListType.NowPlaying);
return movies.Results;
}
public async Task<List<MovieResult>> GetUpcomingMovies()
{
var movies = await Client.GetMovieList(MovieListType.Upcoming);
return movies.Results;
}
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RequestPlex.Core")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RequestPlex.Core")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("dd7dc444-d3bf-4027-8ab9-efc71f5ec581")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RequestPlex.Core</RootNamespace>
<AssemblyName>RequestPlex.Core</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Mono.Data.Sqlite">
<HintPath>..\Assemblies\Mono.Data.Sqlite.dll</HintPath>
</Reference>
<Reference Include="Nancy, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.1.4.3\lib\net40\Nancy.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Authentication.Forms, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="SettingsService.cs" />
<Compile Include="Setup.cs" />
<Compile Include="UserIdentity.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UserMapper.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
<Name>RequestPlex.Store</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Mono.Data.Sqlite;
using RequestPlex.Store;
namespace RequestPlex.Core
{
public class SettingsService
{
public void SaveSettings(int port)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new GenericRepository<SettingsModel>(db);
var existingSettings = repo.GetAll().FirstOrDefault();
if (existingSettings != null)
{
existingSettings.Port = port;
repo.Update(existingSettings);
return;
}
var newSettings = new SettingsModel { Port = port };
repo.Insert(newSettings);
}
public SettingsModel GetSettings()
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new GenericRepository<SettingsModel>(db);
var settings = repo.GetAll().FirstOrDefault();
return settings;
}
}
}

@ -0,0 +1,17 @@
using Mono.Data.Sqlite;
using RequestPlex.Store;
namespace RequestPlex.Core
{
public class Setup
{
public void SetupDb()
{
var db = new DbConfiguration(new SqliteFactory());
db.CreateDatabase();
TableCreation.CreateTables(db.DbConnection());
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nancy.Security;
namespace RequestPlex.Core
{
public class UserIdentity : IUserIdentity
{
public string UserName { get; set; }
public IEnumerable<string> Claims { get; set; }
}
}

@ -0,0 +1,71 @@
using System;
using System.Linq;
using Mono.Data.Sqlite;
using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Security;
using RequestPlex.Store;
namespace RequestPlex.Core
{
public class UserMapper : IUserMapper
{
public IUserIdentity GetUserFromIdentifier(Guid identifier, NancyContext context)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var user = repo.Get(identifier.ToString());
if (user == null)
{
return null;
}
return new UserIdentity
{
UserName = user.UserName,
};
}
public static Guid? ValidateUser(string username, string password)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var users = repo.GetAll();
var userRecord = users.FirstOrDefault(u => u.UserName == username && u.Password == password); // TODO hashing
if (userRecord == null)
{
return null;
}
return new Guid(userRecord.User);
}
public static bool DoUsersExist()
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var users = repo.GetAll();
return users.Any();
}
public static Guid? CreateUser(string username, string password)
{
var db = new DbConfiguration(new SqliteFactory());
var repo = new UserRepository<UserModel>(db);
var userModel = new UserModel { UserName = username, User = Guid.NewGuid().ToString(), Password = password };
repo.Insert(userModel);
var userRecord = repo.Get(userModel.User);
return new Guid(userRecord.User);
}
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Nancy" version="1.4.3" targetFramework="net452" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net452" />
</packages>

@ -0,0 +1,87 @@
#region Copyright
// ***********************************************************************
// Copyright (c) 2016 Jamie Rees
// File: DbConfiguration.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
#endregion
using System;
using System.Data;
using System.IO;
using Mono.Data.Sqlite;
namespace RequestPlex.Store
{
public class DbConfiguration : ISqliteConfiguration
{
public DbConfiguration(SqliteFactory provider)
{
Factory = provider;
}
private SqliteFactory Factory { get; set; }
public virtual void CheckDb()
{
if (!File.Exists(DbFile))
{
CreateDatabase();
}
}
public string DbFile = "RequestPlex.sqlite";
/// <summary>
/// Gets the database connection.
/// </summary>
/// <returns><see cref="IDbConnection"/></returns>
/// <exception cref="System.Exception">Factory returned null</exception>
public virtual IDbConnection DbConnection()
{
var fact = Factory.CreateConnection();
if (fact == null)
{
throw new SqliteException("Factory returned null");
}
fact.ConnectionString = "Data Source=" + DbFile;
return fact;
}
/// <summary>
/// Create the database file.
/// </summary>
public virtual void CreateDatabase()
{
try
{
using (File.Create(DbFile))
{
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper.Contrib.Extensions;
namespace RequestPlex.Store
{
public class Entity
{
[Key]
public int Id { get; set; }
}
}

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper.Contrib.Extensions;
namespace RequestPlex.Store
{
public class GenericRepository<T> : IRepository<T> where T : Entity
{
public GenericRepository(ISqliteConfiguration config)
{
Config = config;
}
private ISqliteConfiguration Config { get; set; }
public long Insert(T entity)
{
using (var cnn = Config.DbConnection())
{
cnn.Open();
return cnn.Insert(entity);
}
}
public IEnumerable<T> GetAll()
{
using (var db = Config.DbConnection())
{
db.Open();
var result = db.GetAll<T>();
return result;
}
}
public T Get(string id)
{
throw new NotImplementedException();
}
public T Get(int id)
{
using (var db = Config.DbConnection())
{
db.Open();
return db.Get<T>(id);
}
}
public void Delete(T entity)
{
using (var db = Config.DbConnection())
{
db.Open();
db.Delete(entity);
}
}
public bool Update(T entity)
{
using (var db = Config.DbConnection())
{
db.Open();
return db.Update(entity);
}
}
}
}

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RequestPlex.Store
{
public interface IRepository<T>
{
/// <summary>
/// Inserts the specified entity.
/// </summary>
/// <param name="entity">The entity.</param>
long Insert(T entity);
/// <summary>
/// Gets all.
/// </summary>
/// <returns></returns>
IEnumerable<T> GetAll();
/// <summary>
/// Gets the specified identifier.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns></returns>
T Get(string id);
T Get(int id);
/// <summary>
/// Deletes the specified entity.
/// </summary>
/// <param name="entity">The entity.</param>
void Delete(T entity);
/// <summary>
/// Updates the specified entity.
/// </summary>
/// <param name="entity">The entity.</param>
/// <returns></returns>
bool Update(T entity);
}
}

@ -0,0 +1,50 @@
#region Copyright
// ***********************************************************************
// Copyright (c) 2016 Jamie Rees
// File: ISqliteConfiguration.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
#endregion
using System.Data;
namespace RequestPlex.Store
{
public interface ISqliteConfiguration
{
/// <summary>
/// Checks the database.
/// </summary>
void CheckDb();
/// <summary>
/// Returns the database connection.
/// </summary>
/// <returns></returns>
IDbConnection DbConnection();
/// <summary>
/// Creates the database.
/// </summary>
void CreateDatabase();
}
}

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RequestPlex.Store")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RequestPlex.Store")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("92433867-2b7b-477b-a566-96c382427525")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{92433867-2B7B-477B-A566-96C382427525}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RequestPlex.Store</RootNamespace>
<AssemblyName>RequestPlex.Store</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Dapper, Version=1.40.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.1.42\lib\net45\Dapper.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Dapper.Contrib, Version=1.40.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapper.Contrib.1.42\lib\net45\Dapper.Contrib.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Mono.Data.Sqlite">
<HintPath>..\Assemblies\Mono.Data.Sqlite.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DbConfiguration.cs" />
<Compile Include="Entity.cs" />
<Compile Include="ISqliteConfiguration.cs" />
<Compile Include="IRepository.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsModel.cs" />
<Compile Include="GenericRepository.cs" />
<Compile Include="UserRepository.cs" />
<Compile Include="Sql.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Sql.resx</DependentUpon>
</Compile>
<Compile Include="TableCreation.cs" />
<Compile Include="UserModel.cs" />
</ItemGroup>
<ItemGroup>
<None Include="sqlite3.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="SqlTables.sql" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Sql.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Sql.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,12 @@
using System;
using Dapper.Contrib.Extensions;
namespace RequestPlex.Store
{
[Table("Settings")]
public class SettingsModel : Entity
{
public int Port { get; set; }
}
}

@ -0,0 +1,79 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace RequestPlex.Store {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Sql {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Sql() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("RequestPlex.Store.Sql", typeof(Sql).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to --Any DB changes need to be made in this file.
///
///CREATE TABLE IF NOT EXISTS User
///(
/// UserID varchar PRIMARY KEY,
/// UserName varchar(50) NOT NULL,
/// Password varchar(100) NOT NULL
///);.
/// </summary>
internal static string SqlTables {
get {
return ResourceManager.GetString("SqlTables", resourceCulture);
}
}
}
}

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="SqlTables" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>sqltables.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>

@ -0,0 +1,15 @@
--Any DB changes need to be made in this file.
CREATE TABLE IF NOT EXISTS User
(
Id INTEGER PRIMARY KEY AUTOINCREMENT,
User varchar(50) NOT NULL ,
UserName varchar(50) NOT NULL,
Password varchar(100) NOT NULL
);
CREATE TABLE IF NOT EXISTS Settings
(
Id INTEGER PRIMARY KEY AUTOINCREMENT,
Port INTEGER NOT NULL
);

@ -0,0 +1,58 @@
#region Copyright
// ***********************************************************************
// Copyright (c) 2016 Jamie Rees
// File: TableCreation.cs
// Created By: Jamie Rees
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// ***********************************************************************
#endregion
using System.Data;
using Dapper;
using Dapper.Contrib.Extensions;
namespace RequestPlex.Store
{
public static class TableCreation
{
/// <summary>
/// Creates the tables located in the SqlTables.sql file.
/// </summary>
/// <param name="connection">The connection.</param>
public static void CreateTables(IDbConnection connection)
{
connection.Open();
connection.Execute(Sql.SqlTables);
connection.Close();
}
[Table("sqlite_master")]
public class SqliteMasterTable
{
public string type { get; set; }
public string name { get; set; }
public string tbl_name { get; set; }
[Key]
public long rootpage { get; set; }
public string sql { get; set; }
}
}
}

@ -0,0 +1,14 @@
using System;
using Dapper.Contrib.Extensions;
namespace RequestPlex.Store
{
[Table("User")]
public class UserModel : Entity
{
public string User { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
}
}

@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dapper.Contrib.Extensions;
namespace RequestPlex.Store
{
public class UserRepository<T> : IRepository<T> where T : UserModel
{
public UserRepository(ISqliteConfiguration config)
{
Config = config;
}
private ISqliteConfiguration Config { get; set; }
public long Insert(T entity)
{
using (var cnn = Config.DbConnection())
{
cnn.Open();
return cnn.Insert(entity);
}
}
public IEnumerable<T> GetAll()
{
using (var db = Config.DbConnection())
{
db.Open();
var result = db.GetAll<T>();
return result;
}
}
public T Get(string id)
{
using (var db = Config.DbConnection())
{
db.Open();
var result = db.GetAll<T>();
var selected = result.FirstOrDefault(x => x.User == id);
return selected;
}
}
public T Get(int id)
{
throw new NotImplementedException();
}
public void Delete(T entity)
{
using (var db = Config.DbConnection())
{
db.Open();
db.Delete(entity);
}
}
public bool Update(T entity)
{
using (var db = Config.DbConnection())
{
db.Open();
return db.Update(entity);
}
}
}
}

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Dapper" version="1.42" targetFramework="net452" />
<package id="Dapper.Contrib" version="1.42" targetFramework="net452" />
</packages>

@ -1,4 +1,11 @@
using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Bootstrapper;
using Nancy.TinyIoc;
using RequestPlex.Core;
using FormsAuthentication = Nancy.Authentication.Forms.FormsAuthentication;
namespace RequestPlex.UI
{
@ -7,5 +14,25 @@ namespace RequestPlex.UI
// The bootstrapper enables you to reconfigure the composition of the framework,
// by overriding the various methods and properties.
// For more information https://github.com/NancyFx/Nancy/wiki/Bootstrapper
protected override void ConfigureRequestContainer(TinyIoCContainer container, NancyContext context)
{
base.ConfigureRequestContainer(container, context);
container.Register<IUserMapper, UserMapper>();
}
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
// Enable forms auth
var formsAuthConfiguration = new FormsAuthenticationConfiguration
{
RedirectUrl = "~/login",
UserMapper = container.Resolve<IUserMapper>()
};
FormsAuthentication.Enable(pipelines, formsAuthConfiguration);
}
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 16 KiB

@ -0,0 +1,89 @@
var searchSource = $("#search-template").html();
var searchTemplate = Handlebars.compile(searchSource);
var movieTimer = 0;
var tvimer = 0;
$("#movieSearchContent").on("keyup", function (e) {
if (movieTimer) {
clearTimeout(movieTimer);
}
movieTimer = setTimeout(movieSearch, 400);
});
$("#tvSearchContent").on("keyup", function (e) {
if (tvimer) {
clearTimeout(tvimer);
}
tvimer = setTimeout(tvSearch(), 400);
});
function movieSearch() {
$("#movieList").html("");
var query = $("#movieSearchContent").val();
$.ajax("/search/movie/" + query).success(function (results) {
results.forEach(function (result) {
var context = buildMovieContext(result);
var html = searchTemplate(context);
$("#movieList").append(html);
});
});
};
function tvSearch() {
$("#tvList").html("");
var query = $("#tvSearchContent").val();
$.ajax("/search/tv/" + query).success(function (results) {
results.forEach(function (result) {
var context = buildTvShowContext(result);
var html = searchTemplate(context);
$("#tvList").append(html);
});
});
};
function buildMovieContext(result) {
var date = new Date(result.releaseDate);
var year = date.getFullYear();
var context = {
posterPath: result.posterPath,
id: result.id,
title: result.title,
overview: result.overview,
voteCount: result.voteCount,
voteAverage: result.voteAverage,
year: year,
type : "movie"
};
return context;
}
function buildTvShowContext(result) {
var date = new Date(result.firstAirDate);
var year = date.getFullYear();
var context = {
posterPath: result.posterPath,
id: result.id,
title: result.name,
overview: result.overview,
voteCount: result.voteCount,
voteAverage: result.voteAverage,
year: year,
type: "tv"
};
return context;
}
function generateNotify(message, type) {
// type = danger, warning, info, successs
$.notify({
// options
message: message
}, {
// settings
type: type
});
}

@ -1,4 +1,10 @@
using System.Dynamic;
using Nancy;
using Nancy.Extensions;
using Nancy.Security;
using RequestPlex.Core;
namespace RequestPlex.UI.Modules
{
@ -6,7 +12,39 @@ namespace RequestPlex.UI.Modules
{
public AdminModule()
{
Get["admin/"] = _ => "Hello!";
this.RequiresAuthentication();
Get["admin/"] = _ =>
{
dynamic model = new ExpandoObject();
model.Errored = Request.Query.error.HasValue;
var s = new SettingsService();
var settings = s.GetSettings();
if (settings != null)
{
model.Port = settings.Port;
}
return View["/Admin/Settings", model];
};
Post["admin/"] = _ =>
{
var portString = (string)Request.Form.portNumber;
int port;
if (!int.TryParse(portString, out port))
{
return Context.GetRedirect("~/admin?error=true");
}
var s = new SettingsService();
s.SaveSettings(port);
return Context.GetRedirect("~/admin");
};
}
}
}

@ -8,12 +8,6 @@ namespace RequestPlex.UI.Modules
{
Get["/"] = parameters => View["Index"];
Get["/Index"] = parameters => View["Index"];
Get["/test"] = parameters =>
{
var model = "this is my model";
return View["Test", model];
};
}
}
}

@ -1,4 +1,11 @@
using System;
using System.Dynamic;
using Nancy;
using Nancy.Authentication.Forms;
using Nancy.Extensions;
using RequestPlex.Core;
namespace RequestPlex.UI.Modules
{
@ -6,7 +13,58 @@ namespace RequestPlex.UI.Modules
{
public LoginModule()
{
Get["/"] = _ => View["Login/Index"];
Get["/login"] = _ =>
{
{
dynamic model = new ExpandoObject();
model.Errored = Request.Query.error.HasValue;
return View["Login/Index", model];
}
};
Get["/logout"] = x => this.LogoutAndRedirect("~/");
Post["/login"] = x =>
{
var userId = UserMapper.ValidateUser((string)this.Request.Form.Username, (string)this.Request.Form.Password);
if (userId == null)
{
return this.Context.GetRedirect("~/login?error=true&username=" + (string)this.Request.Form.Username);
}
DateTime? expiry = null;
if (Request.Form.RememberMe.HasValue)
{
expiry = DateTime.Now.AddDays(7);
}
return this.LoginAndRedirect(userId.Value, expiry);
};
Get["/register"] = x => {
{
dynamic model = new ExpandoObject();
model.Errored = Request.Query.error.HasValue;
return View["Login/Register", model];
}
};
Post["/register"] = x =>
{
var exists = UserMapper.DoUsersExist();
if (exists)
{
return Context.GetRedirect("~/register?error=true&username=" + (string)Request.Form.Username);
}
var userId = UserMapper.CreateUser(Request.Form.Username, Request.Form.Password);
return this.LoginAndRedirect((Guid)userId);
};
}
}
}

@ -1,12 +0,0 @@
using Nancy;
namespace RequestPlex.UI.Modules
{
public class ManageModule : NancyModule
{
public ManageModule()
{
Get["manage/"] = _ => "Hello!";
}
}
}

@ -1,49 +0,0 @@
using Nancy;
using Nancy.ModelBinding;
using Nancy.Responses.Negotiation;
using RequestPlex.Api;
namespace RequestPlex.UI.Modules
{
public class RequestModule : NancyModule
{
public RequestModule()
{
Get["request/"] = parameters => RequestLoad();
Get["request/movie/{searchTerm}"] = parameters =>
{
var search = (string)parameters.searchTerm;
return SearchMovie(search);
};
Get["request/tv/{searchTerm}"] = parameters =>
{
var search = (string)parameters.searchTerm;
return SearchTvShow(search);
};
}
private Negotiator RequestLoad()
{
return View["Request/Index"];
}
private Response SearchMovie(string searchTerm)
{
var api = new TheMovieDbApi();
var movies = api.SearchMovie(searchTerm);
var result = movies.Result;
return Response.AsJson(result);
}
private Response SearchTvShow(string searchTerm)
{
var api = new TheMovieDbApi();
var tvShow = api.SearchTv(searchTerm);
var result = tvShow.Result;
return Response.AsJson(result);
}
}
}

@ -0,0 +1,12 @@
using Nancy;
namespace RequestPlex.UI.Modules
{
public class RequestsModule : NancyModule
{
public RequestsModule()
{
Get["requests/"] = _ => "Hello!";
}
}
}

@ -0,0 +1,90 @@
using Nancy;
using Nancy.Responses.Negotiation;
using RequestPlex.Api;
namespace RequestPlex.UI.Modules
{
public class SearchModule : NancyModule
{
public SearchModule()
{
Get["search/"] = parameters => RequestLoad();
Get["search/movie/{searchTerm}"] = parameters =>
{
var search = (string)parameters.searchTerm;
return SearchMovie(search);
};
Get["search/tv/{searchTerm}"] = parameters =>
{
var search = (string)parameters.searchTerm;
return SearchTvShow(search);
};
Get["search/movie/upcoming"] = parameters => UpcomingMovies();
Get["search/movie/playing"] = parameters => CurrentlyPlayingMovies();
Post["search/request/movie"] = parameters =>
{
var movieId = (int)Request.Form.movieId;
return RequestMovie(movieId);
};
Post["search/request/tv"] = parameters =>
{
var tvShowId = (int)Request.Form.showId;
var latest = (bool)Request.Form.latestSeason;
return RequestTvShow(tvShowId, latest);
};
}
private Negotiator RequestLoad()
{
return View["Search/Index"];
}
private Response SearchMovie(string searchTerm)
{
var api = new TheMovieDbApi();
var movies = api.SearchMovie(searchTerm);
var result = movies.Result;
return Response.AsJson(result);
}
private Response SearchTvShow(string searchTerm)
{
var api = new TheMovieDbApi();
var tvShow = api.SearchTv(searchTerm);
var result = tvShow.Result;
return Response.AsJson(result);
}
private Response UpcomingMovies()
{
var api = new TheMovieDbApi();
var movies = api.GetUpcomingMovies();
var result = movies.Result;
return Response.AsJson(result);
}
private Response CurrentlyPlayingMovies()
{
var api = new TheMovieDbApi();
var movies = api.GetCurrentPlayingMovies();
var result = movies.Result;
return Response.AsJson(result);
}
private Response RequestMovie(int movieId)
{
return Response.AsJson("");
}
private Response RequestTvShow(int showId, bool latest)
{
return Response.AsJson("");
}
}
}

@ -4,14 +4,22 @@ using Microsoft.Owin.Hosting;
using Nancy.Hosting.Self;
using RequestPlex.Core;
namespace RequestPlex.UI
{
class Program
{
static void Main(string[] args)
{
var uri =
"http://localhost:3579";
var service = new SettingsService();
var settings = service.GetSettings();
var uri = "http://localhost:3579/";
if (settings != null)
{
uri = $"http://localhost:{settings.Port}";
}
using (WebApp.Start<Startup>(uri))
{

@ -53,6 +53,14 @@
<Reference Include="Nancy">
<HintPath>..\packages\Nancy.1.4.1\lib\net40\Nancy.dll</HintPath>
</Reference>
<Reference Include="Nancy.Authentication.Basic, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Authentication.Basic.1.4.1\lib\net40\Nancy.Authentication.Basic.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Authentication.Forms, Version=1.4.1.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nancy.Authentication.Forms.1.4.1\lib\net40\Nancy.Authentication.Forms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Nancy.Hosting.Self">
<HintPath>..\packages\Nancy.Hosting.Self.1.4.1\lib\net40\Nancy.Hosting.Self.dll</HintPath>
</Reference>
@ -91,6 +99,9 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Bootstrapper.cs" />
<Content Include="Content\bootstrap-notify.min.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\bootstrap.css">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -100,8 +111,8 @@
<Compile Include="Modules\AdminModule.cs" />
<Compile Include="Modules\IndexModule.cs" />
<Compile Include="Modules\LoginModule.cs" />
<Compile Include="Modules\ManageModule.cs" />
<Compile Include="Modules\RequestModule.cs" />
<Compile Include="Modules\RequestsModule.cs" />
<Compile Include="Modules\SearchModule.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Startup.cs" />
@ -119,28 +130,31 @@
<Content Include="Content\fonts\fontawesome-webfont.svg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\handlebars.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\jquery-2.2.1.min.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="icon.png" />
<None Include="app.config" />
<Content Include="packages.config" />
<None Include="sqlite3.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Content Include="Views\Index.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="web.config">
<SubType>Designer</SubType>
</Content>
<Content Include="Views\Test.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Shared\_Layout.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\_ViewStart.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Request\Index.cshtml">
<Content Include="Views\Search\Index.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Login\Index.cshtml">
@ -161,6 +175,15 @@
<None Include="Content\fonts\FontAwesome.otf">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<Content Include="Views\Admin\Settings.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Admin\_Sidebar.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Views\Login\Register.cshtml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Web.Debug.config">
<DependentUpon>web.config</DependentUpon>
</None>
@ -169,18 +192,28 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Auth\" />
<Folder Include="Models\" />
</ItemGroup>
<ItemGroup>
<Content Include="Content\nancy-logo.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Folder Include="Views\Requests\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\RequestPlex.Api\RequestPlex.Api.csproj">
<Project>{8cb8d235-2674-442d-9c6a-35fcaeeb160d}</Project>
<Name>RequestPlex.Api</Name>
</ProjectReference>
<ProjectReference Include="..\RequestPlex.Core\RequestPlex.Core.csproj">
<Project>{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}</Project>
<Name>RequestPlex.Core</Name>
</ProjectReference>
<ProjectReference Include="..\RequestPlex.Store\RequestPlex.Store.csproj">
<Project>{92433867-2B7B-477B-A566-96C382427525}</Project>
<Name>RequestPlex.Store</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="Content\search.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>

@ -1,5 +1,7 @@
using Owin;
using RequestPlex.Core;
namespace RequestPlex.UI
{
public class Startup
@ -7,6 +9,9 @@ namespace RequestPlex.UI
public void Configuration(IAppBuilder app)
{
app.UseNancy();
var s = new Setup();
s.SetupDb();
}
}
}

@ -0,0 +1,32 @@
@Html.Partial("/Admin/_Sidebar")
@{
var port = Model.Port ?? 0;
}
<div class="col-sm-8">
<form class="form-horizontal" method="POST">
<fieldset>
<legend>Request Plex Settings</legend>
<div class="form-group">
<label for="portNumber" class="col-lg-2 control-label">Port</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="portNumber" name="portNumber" placeholder="Port Number" value="@port">
</div>
</div>
<div class="form-group">
<div class="col-lg-10 col-lg-offset-2">
<button type="reset" class="btn btn-default">Cancel</button>
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</fieldset>
</form>
</div>
@if (Model.Errored)
{
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-times"></i></button>
Please enter in a correct port number
</div>
}

@ -0,0 +1,9 @@
<div class="col-lg-3 col-md-3 col-sm-4">
<div class="list-group table-of-contents">
<a class="list-group-item" href="/admin">Request Plex Settings</a>
<a class="list-group-item" href="/couchpotato">CouchPotato Settings</a>
<a class="list-group-item" href="/sonarr">Sonarr Settings</a>
<a class="list-group-item" href="/sickbeard">Sickbeard Settings</a>
<a class="list-group-item" href="/userauth">Authentication</a>
</div>
</div>

@ -1 +1,19 @@

<form method="POST">
Username <input class="form-control" type="text" name="Username"/>
<br/>
Password <input class="form-control" name="Password" type="password"/>
<br/>
Remember Me <input name="RememberMe" type="checkbox" value="True"/>
<br/>
<input class="btn btn-success" type="submit" value="Login"/>
</form>
If you have not yet created an Admin account you can do here: <a href="/register">Register</a>
@if (Model.Errored)
{
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-times"></i></button>
Invalid Username or Password!
</div>
}

@ -0,0 +1,15 @@
<form method="POST">
Username <input class="form-control" type="text" name="Username" />
<br />
Password <input class="form-control" name="Password" type="password" />
<br />
<br />
<input class="btn btn-success" type="submit" value="Create User" />
</form>
@if (Model.Errored)
{
<div class="alert alert-dismissible alert-danger">
<button type="button" class="close" data-dismiss="alert"><i class="fa fa-times"></i></button>
An admin account already exists!
</div>
}

@ -1,126 +0,0 @@
<div>
<h2>Search</h2>
<!-- Nav tabs -->
<ul id="nav-tabs" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab">Movies</a></li>
<li role="presentation"><a href="#TvShowTab" aria-controls="profile" role="tab" data-toggle="tab">TV Shows</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="MoviesTab">
<div class="input-group">
<input id="movieSearchContent" type="text" class="form-control">
<div class="input-group-addon">
<i class="fa fa-search"></i>
</div>
</div>
<br />
<br />
<div id="movieList">
</div>
</div>
<div role="tabpanel" class="tab-pane" id="TvShowTab">
<div class="input-group">
<input id="tvSearchContent" type="text" class="form-control">
<div class="input-group-addon">
<i class="fa fa-search"></i>
</div>
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="tvSearchButton">Search</button>
</span>
</div>
<div id="tvList">
</div>
</div>
</div>
</div>
<script id="movie-template" type="text/x-handlebars-template">
<div class="row">
<div class="col-sm-2">
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
</div>
<div class="col-sm-5">
<div id="{{id}}">
<a href="https://www.themoviedb.org/movie/{{id}}">
<h4>{{title}} ({{year}})</h4>
</a>
</div>
<p>{{overview}}.</p>
</div>
<div class="col-sm-5">
<small>Vote Average: {{voteAverage}}</small>
<small>Vote Count: {{voteCount}}</small>
<button style="text-align: right" class="btn btn-primary bottom-align-text">
<i class="fa fa-plus"></i>Request
</button>
</div>
</div>
<hr />
</script>
<script>
$(function () {
var movieSource = $("#movie-template").html();
var movieTemplate = Handlebars.compile(movieSource);
var movieTimer = 0;
var tvimer = 0;
$('#movieSearchContent').on('keyup', function (e) {
if (movieTimer) {
clearTimeout(movieTimer);
}
movieTimer = setTimeout(movieSearch, 400);
});
$('#tvSearchContent').on('keyup', function (e) {
if (tvimer) {
clearTimeout(tvimer);
}
tvimer = setTimeout(tvSearch(), 400);
});
function movieSearch() {
$('#movieList').html("");
var query = $('#movieSearchContent').val();
$.ajax("/request/movie/" + query).success(function (results) {
results.forEach(function (result) {
var date = new Date(result.releaseDate);
var year = date.getFullYear();
var context = { posterPath: result.posterPath, id: result.id, title: result.title, overview: result.overview, voteCount: result.voteCount, voteAverage: result.voteAverage, year: year };
var html = movieTemplate(context);
$('#movieList').append(html);
});
});
};
function tvSearch() {
$('#tvList').html("");
var query = $('#tvSearchContent').val();
$.ajax("/request/tv/" + query).success(function (results) {
results.forEach(function (result) {
var date = new Date(result.airDate);
var year = date.getFullYear();
var context = { posterPath: result.posterPath, id: result.id, title: result.title, overview: result.overview, voteCount: result.voteCount, voteAverage: result.voteAverage, year : year };
var html = movieTemplate(context);
$('#tvList').append(html);
});
});
};
});
</script>

@ -0,0 +1,75 @@
<div>
<h2>Search</h2>
<!-- Nav tabs -->
<ul id="nav-tabs" class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#MoviesTab" aria-controls="home" role="tab" data-toggle="tab">Movies</a></li>
<li role="presentation"><a href="#TvShowTab" aria-controls="profile" role="tab" data-toggle="tab">TV Shows</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<!-- Movie tab -->
<div role="tabpanel" class="tab-pane active" id="MoviesTab">
<div class="input-group">
<input id="movieSearchContent" type="text" class="form-control">
<div class="input-group-addon">
<i class="fa fa-search"></i>
</div>
</div>
<br />
<br />
<!-- Movie content -->
<div id="movieList">
</div>
</div>
<!-- TV tab -->
<div role="tabpanel" class="tab-pane" id="TvShowTab">
<div class="input-group">
<input id="tvSearchContent" type="text" class="form-control">
<div class="input-group-addon">
<i class="fa fa-search"></i>
</div>
</div>
<br />
<br />
<!-- TV content -->
<div id="tvList">
</div>
</div>
</div>
</div>
<script id="search-template" type="text/x-handlebars-template">
<div class="row">
<div class="col-sm-2">
{{#if posterPath}}
<img src="http://image.tmdb.org/t/p/w150/{{posterPath}}" alt="poster">
{{/if}}
</div>
<div class="col-sm-5">
<div id="{{id}}">
<a href="https://www.themoviedb.org/{{type}}/{{id}}">
<h4>{{title}} ({{year}})</h4>
</a>
</div>
<p>{{overview}}.</p>
</div>
<div class="col-sm-5">
<small>Vote Average: {{voteAverage}}</small>
<small>Vote Count: {{voteCount}}</small>
<button style="text-align: right" class="btn btn-primary bottom-align-text">
<i class="fa fa-plus"></i>Request
</button>
</div>
</div>
<hr />
</script>
<script src="/Content/search.js" type="text/javascript"></script>

@ -1,10 +1,17 @@
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase
<link rel="stylesheet" href="/Content/custom.css" type="text/css"/>
<link rel="stylesheet" href="/Content/bootstrap.css" type="text/css"/>
<link rel="stylesheet" href="/Content/font-awesome.css" type="text/css"/>
@using Nancy.Security
@inherits Nancy.ViewEngines.Razor.NancyRazorViewBase
<!-- Styles -->
<link rel="stylesheet" href="~/Content/custom.css" type="text/css"/>
<link rel="stylesheet" href="~/Content/bootstrap.css" type="text/css"/>
<link rel="stylesheet" href="~/Content/font-awesome.css" type="text/css"/>
<!-- Scripts -->
<script src="/Content/jquery-2.2.1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.5/handlebars.js"></script>
<script src="/Content/handlebars.js"></script>
<script src="/Content/bootstrap.min.js"></script>
<script src="/Content/bootstrap-notify.min.js"></script>
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
@ -19,12 +26,23 @@
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="/request">Search</a></li>
<li><a href="/admin">Admin</a></li>
<li><a href="/admin">Requested</a></li>
<li class="active"><a href="/search">Search</a></li>
@if (Context.CurrentUser.IsAuthenticated())
{
<li><a href="/admin">Admin</a></li>
}
<li><a href="/requests">Requests</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Login</a></li>
@if (!Context.CurrentUser.IsAuthenticated())
{
<li><a href="/login">Login</a></li>
}
else
{
<li><a href="/logout">Logout</a></li>
}
</ul>
</div>
</div>

@ -1,25 +0,0 @@
@Model string;
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>RequestPlex.UI</title>
<style type="text/css">
body {
text-align: center;
}
</style>
</head>
<body>
<img src="~/Content/nancy-logo.png" alt="Nancy logo" /><br />
This view was rendered using the Nancy Razor view engine
@if (1 == 1)
{
<div>@Model</div>
}
</body>
</html>

@ -5,6 +5,8 @@
<package id="Microsoft.Owin.Host.HttpListener" version="3.0.1" targetFramework="net452" />
<package id="Microsoft.Owin.Hosting" version="3.0.1" targetFramework="net452" />
<package id="Nancy" version="1.4.1" requireReinstallation="true" />
<package id="Nancy.Authentication.Basic" version="1.4.1" targetFramework="net452" />
<package id="Nancy.Authentication.Forms" version="1.4.1" targetFramework="net452" />
<package id="Nancy.Hosting.Self" version="1.4.1" requireReinstallation="true" />
<package id="Nancy.Owin" version="1.4.1" targetFramework="net452" />
<package id="Nancy.Viewengines.Razor" version="1.4.1" requireReinstallation="true" />

@ -9,6 +9,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RequestPlex.Api", "RequestP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RequestPlex.Api.Interfaces", "RequestPlex.Api.Interfaces\RequestPlex.Api.Interfaces.csproj", "{95834072-A675-415D-AA8F-877C91623810}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RequestPlex.Core", "RequestPlex.Core\RequestPlex.Core.csproj", "{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RequestPlex.Store", "RequestPlex.Store\RequestPlex.Store.csproj", "{92433867-2B7B-477B-A566-96C382427525}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -27,6 +31,14 @@ Global
{95834072-A675-415D-AA8F-877C91623810}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95834072-A675-415D-AA8F-877C91623810}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95834072-A675-415D-AA8F-877C91623810}.Release|Any CPU.Build.0 = Release|Any CPU
{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD7DC444-D3BF-4027-8AB9-EFC71F5EC581}.Release|Any CPU.Build.0 = Release|Any CPU
{92433867-2B7B-477B-A566-96C382427525}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92433867-2B7B-477B-A566-96C382427525}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92433867-2B7B-477B-A566-96C382427525}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92433867-2B7B-477B-A566-96C382427525}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

Loading…
Cancel
Save